diff --git a/backend/app/src/main/kotlin/io/tolgee/postgresRunners/PostgresRunnerFactory.kt b/backend/app/src/main/kotlin/io/tolgee/postgresRunners/PostgresRunnerConfiguration.kt similarity index 96% rename from backend/app/src/main/kotlin/io/tolgee/postgresRunners/PostgresRunnerFactory.kt rename to backend/app/src/main/kotlin/io/tolgee/postgresRunners/PostgresRunnerConfiguration.kt index 058869e0da..bd4e00ab23 100644 --- a/backend/app/src/main/kotlin/io/tolgee/postgresRunners/PostgresRunnerFactory.kt +++ b/backend/app/src/main/kotlin/io/tolgee/postgresRunners/PostgresRunnerConfiguration.kt @@ -7,7 +7,7 @@ import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @Configuration -class PostgresRunnerConfiguration() { +class PostgresRunnerConfiguration { @Bean fun postgresRunner( postgresAutostartProperties: PostgresAutostartProperties, diff --git a/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/V2ExportControllerTest.kt b/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/V2ExportControllerTest.kt index b6cf339daa..3a6437a96d 100644 --- a/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/V2ExportControllerTest.kt +++ b/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/V2ExportControllerTest.kt @@ -83,18 +83,23 @@ class V2ExportControllerTest : ProjectAuthControllerTest("/v2/projects/") { retries = 10, exceptionMatcher = { it is ConcurrentModificationException || it is DataIntegrityViolationException } ) { - executeInNewTransaction { - initBaseData() - } - performExport() - performExport() - waitForNotThrowing(pollTime = 50, timeout = 3000) { - verify(postHog, times(1)).capture(any(), eq("EXPORT"), any()) - } - setForcedDate(currentDateProvider.date.addDays(1)) - performExport() - waitForNotThrowing(pollTime = 50, timeout = 3000) { - verify(postHog, times(2)).capture(any(), eq("EXPORT"), any()) + initBaseData() + try { + executeInNewTransaction { + } + performExport() + performExport() + waitForNotThrowing(pollTime = 50, timeout = 3000) { + verify(postHog, times(1)).capture(any(), eq("EXPORT"), any()) + } + setForcedDate(currentDateProvider.date.addDays(1)) + performExport() + waitForNotThrowing(pollTime = 50, timeout = 3000) { + verify(postHog, times(2)).capture(any(), eq("EXPORT"), any()) + } + } finally { + Mockito.reset(postHog) + testDataService.cleanTestData(testData.root) } } } diff --git a/backend/app/src/test/kotlin/io/tolgee/controllers/AbstractApiKeyTest.kt b/backend/app/src/test/kotlin/io/tolgee/controllers/AbstractApiKeyTest.kt index 7fecd6ab75..3631804777 100644 --- a/backend/app/src/test/kotlin/io/tolgee/controllers/AbstractApiKeyTest.kt +++ b/backend/app/src/test/kotlin/io/tolgee/controllers/AbstractApiKeyTest.kt @@ -4,13 +4,13 @@ import io.tolgee.dtos.response.ApiKeyDTO.ApiKeyDTO import io.tolgee.fixtures.generateUniqueString import io.tolgee.model.enums.Scope import io.tolgee.testing.AbstractControllerTest -import io.tolgee.testing.assertions.UserApiAppAction +import io.tolgee.testing.assertions.PakAction import org.springframework.test.web.servlet.MvcResult import org.springframework.test.web.servlet.result.MockMvcResultMatchers @Deprecated("This is too complicated") abstract class AbstractApiKeyTest : AbstractControllerTest() { - fun performAction(action: UserApiAppAction): MvcResult { + fun performAction(action: PakAction): MvcResult { return try { var resultActions = mvc.perform(action.requestBuilder) if (action.expectedStatus != null) { diff --git a/backend/app/src/test/kotlin/io/tolgee/security/ProjectApiKeyAuthenticationTest.kt b/backend/app/src/test/kotlin/io/tolgee/security/ProjectApiKeyAuthenticationTest.kt index 731c54bbd1..5f16548a3a 100644 --- a/backend/app/src/test/kotlin/io/tolgee/security/ProjectApiKeyAuthenticationTest.kt +++ b/backend/app/src/test/kotlin/io/tolgee/security/ProjectApiKeyAuthenticationTest.kt @@ -13,7 +13,7 @@ import io.tolgee.model.enums.Scope import io.tolgee.security.authentication.JwtService import io.tolgee.testing.assert import io.tolgee.testing.assertions.Assertions -import io.tolgee.testing.assertions.UserApiAppAction +import io.tolgee.testing.assertions.PakAction import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc @@ -35,7 +35,7 @@ class ProjectApiKeyAuthenticationTest : AbstractApiKeyTest() { @Test fun accessWithApiKey_failure() { val mvcResult = mvc.perform(MockMvcRequestBuilders.get("/v2/projects/translations")) - .andExpect(MockMvcResultMatchers.status().isForbidden).andReturn() + .andExpect(MockMvcResultMatchers.status().isUnauthorized).andReturn() Assertions.assertThat(mvcResult).error() } @@ -57,14 +57,14 @@ class ProjectApiKeyAuthenticationTest : AbstractApiKeyTest() { val base = dbPopulator.createBase(generateUniqueString()) val apiKey = apiKeyService.create(base.userAccount, setOf(*Scope.values()), base.project) performAction( - UserApiAppAction( + PakAction( apiKey = apiKey.key, url = "/v2/projects", expectedStatus = HttpStatus.FORBIDDEN ) ) mvc.perform(MockMvcRequestBuilders.get("/v2/projects")) - .andIsForbidden + .andIsUnauthorized } @Test diff --git a/backend/testing/src/main/kotlin/io/tolgee/testing/assertions/UserApiAppAction.kt b/backend/testing/src/main/kotlin/io/tolgee/testing/assertions/PakAction.kt similarity index 98% rename from backend/testing/src/main/kotlin/io/tolgee/testing/assertions/UserApiAppAction.kt rename to backend/testing/src/main/kotlin/io/tolgee/testing/assertions/PakAction.kt index 2d281e1046..aed189e04d 100644 --- a/backend/testing/src/main/kotlin/io/tolgee/testing/assertions/UserApiAppAction.kt +++ b/backend/testing/src/main/kotlin/io/tolgee/testing/assertions/PakAction.kt @@ -8,7 +8,7 @@ import org.springframework.test.web.servlet.RequestBuilder import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder import org.springframework.test.web.servlet.request.MockMvcRequestBuilders -class UserApiAppAction( +class PakAction( var method: HttpMethod? = null, var body: Any? = null, var apiKey: String? = null,