diff --git a/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/V2InvitationControllerTest.kt b/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/V2InvitationControllerTest.kt index 7c437ec5e3..36c939fbda 100644 --- a/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/V2InvitationControllerTest.kt +++ b/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/V2InvitationControllerTest.kt @@ -42,7 +42,6 @@ class V2InvitationControllerTest : AuthorizedControllerTest() { fun `deletes translate invitation with languages`() { val base = dbPopulator.createBase() val project = base.project - tolgeeProperties.frontEndUrl = "https://dummyUrl.com" val invitation = createTranslateInvitation(project) performAuthDelete("/v2/invitations/${invitation.id}").andIsOk @@ -54,7 +53,6 @@ class V2InvitationControllerTest : AuthorizedControllerTest() { fun `project invitation contains creator info`() { val base = dbPopulator.createBase() val project = base.project - tolgeeProperties.frontEndUrl = "https://dummyUrl.com" val invitation = createTranslateInvitation(project) assertThat(invitation.createdBy?.name).isEqualTo("admin") } @@ -62,7 +60,6 @@ class V2InvitationControllerTest : AuthorizedControllerTest() { @Test fun `organization invitation contains creator info`() { val base = dbPopulator.createBase() - tolgeeProperties.frontEndUrl = "https://dummyUrl.com" val invitation = createOrganizationInvitation(base.organization) assertThat(invitation.createdBy?.name).isEqualTo("admin") } @@ -70,7 +67,6 @@ class V2InvitationControllerTest : AuthorizedControllerTest() { @Test fun `deletes invitations created by deleted user`() { val base = dbPopulator.createBase() - tolgeeProperties.frontEndUrl = "https://dummyUrl.com" val newUser = dbPopulator.createUserIfNotExists("manager") permissionService.grantFullAccessToProject(newUser, base.project) diff --git a/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/V2UserControllerTest.kt b/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/V2UserControllerTest.kt index 2011eef4bd..b4aeafb0b7 100644 --- a/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/V2UserControllerTest.kt +++ b/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/V2UserControllerTest.kt @@ -5,12 +5,7 @@ import io.tolgee.development.testDataBuilder.data.SensitiveOperationProtectionTe import io.tolgee.development.testDataBuilder.data.UserDeletionTestData import io.tolgee.dtos.request.UserUpdatePasswordRequestDto import io.tolgee.dtos.request.UserUpdateRequestDto -import io.tolgee.fixtures.EmailTestUtil -import io.tolgee.fixtures.andAssertThatJson -import io.tolgee.fixtures.andIsBadRequest -import io.tolgee.fixtures.andIsForbidden -import io.tolgee.fixtures.andIsOk -import io.tolgee.fixtures.node +import io.tolgee.fixtures.* import io.tolgee.model.UserAccount import io.tolgee.testing.AuthorizedControllerTest import io.tolgee.testing.ContextRecreatingTest @@ -26,11 +21,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers import java.util.* @ContextRecreatingTest -@SpringBootTest( - properties = [ - "tolgee.front-end-url=https://fake.frontend.url", - ], -) +@SpringBootTest class V2UserControllerTest : AuthorizedControllerTest() { @Autowired override lateinit var tolgeeProperties: TolgeeProperties diff --git a/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/organizationController/OrganizationControllerInvitingTest.kt b/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/organizationController/OrganizationControllerInvitingTest.kt index d188069a90..2d6e154694 100644 --- a/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/organizationController/OrganizationControllerInvitingTest.kt +++ b/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/organizationController/OrganizationControllerInvitingTest.kt @@ -6,12 +6,7 @@ import io.tolgee.dtos.misc.CreateOrganizationInvitationParams import io.tolgee.dtos.request.organization.OrganizationDto import io.tolgee.dtos.request.organization.OrganizationInviteUserDto import io.tolgee.exceptions.BadRequestException -import io.tolgee.fixtures.EmailTestUtil -import io.tolgee.fixtures.andAssertThatJson -import io.tolgee.fixtures.andGetContentAsString -import io.tolgee.fixtures.andIsBadRequest -import io.tolgee.fixtures.andIsOk -import io.tolgee.fixtures.andPrettyPrint +import io.tolgee.fixtures.* import io.tolgee.model.Organization import io.tolgee.model.enums.OrganizationRoleType import io.tolgee.testing.AuthorizedControllerTest @@ -45,7 +40,6 @@ class OrganizationControllerInvitingTest : AuthorizedControllerTest() { "This is description", "test-org", ) - tolgeeProperties.frontEndUrl = null emailTestUtil.initMocks() } @@ -172,7 +166,7 @@ class OrganizationControllerInvitingTest : AuthorizedControllerTest() { val messageContent = emailTestUtil.messageContents.single() assertThat(messageContent).contains(code) - assertThat(messageContent).contains("http://localhost/") + assertThat(messageContent).contains("https://dummy-url.com") emailTestUtil.assertEmailTo.isEqualTo(INVITED_EMAIL) } diff --git a/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/v2ProjectsController/ProjectsControllerInvitationTest.kt b/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/v2ProjectsController/ProjectsControllerInvitationTest.kt index 4febd1d31a..8c904358bf 100644 --- a/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/v2ProjectsController/ProjectsControllerInvitationTest.kt +++ b/backend/app/src/test/kotlin/io/tolgee/api/v2/controllers/v2ProjectsController/ProjectsControllerInvitationTest.kt @@ -8,13 +8,7 @@ import io.tolgee.development.testDataBuilder.data.BaseTestData import io.tolgee.dtos.misc.CreateProjectInvitationParams import io.tolgee.dtos.request.project.LanguagePermissions import io.tolgee.dtos.request.project.ProjectInviteUserDto -import io.tolgee.fixtures.EmailTestUtil -import io.tolgee.fixtures.andAssertThatJson -import io.tolgee.fixtures.andGetContentAsString -import io.tolgee.fixtures.andHasErrorMessage -import io.tolgee.fixtures.andIsBadRequest -import io.tolgee.fixtures.andIsOk -import io.tolgee.fixtures.node +import io.tolgee.fixtures.* import io.tolgee.model.Invitation import io.tolgee.model.Permission import io.tolgee.model.Project @@ -41,7 +35,6 @@ class ProjectsControllerInvitationTest : ProjectAuthControllerTest("/v2/projects @BeforeEach @AfterEach fun reset() { - tolgeeProperties.frontEndUrl = null emailTestUtil.initMocks() } @@ -56,7 +49,6 @@ class ProjectsControllerInvitationTest : ProjectAuthControllerTest("/v2/projects fun `returns project invitations`() { val base = dbPopulator.createBase() val project = base.project - tolgeeProperties.frontEndUrl = "https://dummyUrl.com" createTranslateInvitation(project) performAuthGet("/v2/projects/${project.id}/invitations").andIsOk.andAssertThatJson { node("_embedded.invitations[0]") { @@ -162,19 +154,18 @@ class ProjectsControllerInvitationTest : ProjectAuthControllerTest("/v2/projects val messageContent = emailTestUtil.messageContents.single() assertThat(messageContent).contains(code) - assertThat(messageContent).contains("http://localhost/") + assertThat(messageContent).contains("https://dummy-url.com") emailTestUtil.assertEmailTo.isEqualTo(INVITED_EMAIL) } @Test @ProjectJWTAuthTestMethod fun `uses frontEnd url when possible`() { - tolgeeProperties.frontEndUrl = "dummy_fe_url" inviteWithUserWithNameAndEmail() emailTestUtil.verifyEmailSent() val messageContent = emailTestUtil.messageContents.single() - assertThat(messageContent).contains("dummy_fe_url") + assertThat(messageContent).contains("https://dummy-url.com") } @Test diff --git a/backend/app/src/test/kotlin/io/tolgee/controllers/MarketingEmailingTest.kt b/backend/app/src/test/kotlin/io/tolgee/controllers/MarketingEmailingTest.kt index 2d1fbe2213..035c4dcae2 100644 --- a/backend/app/src/test/kotlin/io/tolgee/controllers/MarketingEmailingTest.kt +++ b/backend/app/src/test/kotlin/io/tolgee/controllers/MarketingEmailingTest.kt @@ -73,7 +73,6 @@ class MarketingEmailingTest : AuthorizedControllerTest() { @BeforeEach fun setup() { Mockito.clearInvocations(mailjetEmailServiceManager) - tolgeeProperties.frontEndUrl = "https://aaa" tolgeeProperties.smtp.from = "aa@aa.com" emailTestUtil.initMocks() } @@ -82,7 +81,6 @@ class MarketingEmailingTest : AuthorizedControllerTest() { fun cleanUp() { sendInBlueProperties.listId = null tolgeeProperties.authentication.needsEmailVerification = false - tolgeeProperties.frontEndUrl = null } private val testMail = "mail@test.com" @@ -98,7 +96,6 @@ class MarketingEmailingTest : AuthorizedControllerTest() { @Test fun `adds contact after verification when needs-verification is on`() { - tolgeeProperties.frontEndUrl = "https://aaa" tolgeeProperties.authentication.needsEmailVerification = true val dto = SignUpDto(name = testName, password = "aaaaaaaaaa", email = testMail) performPost("/api/public/sign_up", dto) diff --git a/backend/app/src/test/kotlin/io/tolgee/controllers/resetPassword/ResetPasswordControllerTest.kt b/backend/app/src/test/kotlin/io/tolgee/controllers/resetPassword/ResetPasswordControllerTest.kt index 817f14ff5e..9313820cf9 100644 --- a/backend/app/src/test/kotlin/io/tolgee/controllers/resetPassword/ResetPasswordControllerTest.kt +++ b/backend/app/src/test/kotlin/io/tolgee/controllers/resetPassword/ResetPasswordControllerTest.kt @@ -3,13 +3,13 @@ package io.tolgee.controllers.resetPassword import com.posthog.java.PostHog import io.tolgee.development.testDataBuilder.data.BaseTestData import io.tolgee.dtos.request.auth.ResetPasswordRequest -import io.tolgee.fixtures.* +import io.tolgee.fixtures.EmailTestUtil +import io.tolgee.fixtures.andIsOk import io.tolgee.testing.AbstractControllerTest import io.tolgee.testing.assert import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import org.mockito.kotlin.times import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc import org.springframework.boot.test.mock.mockito.MockBean @@ -17,19 +17,19 @@ import org.springframework.boot.test.mock.mockito.MockBean @AutoConfigureMockMvc class ResetPasswordControllerTest : AbstractControllerTest() { - private var frontEndUrlBefore: String? = null + private var defaultFrontendUrl: String? = null @BeforeEach fun setup() { + defaultFrontendUrl = tolgeeProperties.frontEndUrl emailTestUtil.initMocks() - frontEndUrlBefore = tolgeeProperties.frontEndUrl testData = BaseTestData() saveTestData() } @AfterEach fun tearDown() { - tolgeeProperties.frontEndUrl = frontEndUrlBefore + tolgeeProperties.frontEndUrl = defaultFrontendUrl } private lateinit var testData: BaseTestData @@ -43,15 +43,15 @@ class ResetPasswordControllerTest : @Test fun `email contains correct callback url with frontend url provided`() { - tolgeeProperties.frontEndUrl = "http://dummy-url.com/" executePasswordChangeRequest() - emailTestUtil.firstMessageContent.assert.contains("http://dummy-url.com/reset_password/") + emailTestUtil.firstMessageContent.assert.contains("https://dummy-url.com/reset_password/") // We don't want double slashes emailTestUtil.firstMessageContent.assert.doesNotContain("reset_password//") } @Test fun `email contains correct callback url without frontend url provided`() { + tolgeeProperties.frontEndUrl = null executePasswordChangeRequest() emailTestUtil.firstMessageContent.assert.contains("https://hello.com/aa/") // We don't want double slashes diff --git a/backend/app/src/test/kotlin/io/tolgee/security/EmailVerificationTest.kt b/backend/app/src/test/kotlin/io/tolgee/security/EmailVerificationTest.kt index 40be051008..0cf949f8eb 100644 --- a/backend/app/src/test/kotlin/io/tolgee/security/EmailVerificationTest.kt +++ b/backend/app/src/test/kotlin/io/tolgee/security/EmailVerificationTest.kt @@ -24,8 +24,11 @@ class EmailVerificationTest : AbstractControllerTest() { @Autowired override lateinit var tolgeeProperties: TolgeeProperties + private var defaultFrontendUrl: String? = null + @BeforeEach fun setup() { + defaultFrontendUrl = tolgeeProperties.frontEndUrl resetProperties() tolgeeProperties.authentication.needsEmailVerification = true emailTestUtil.initMocks() @@ -38,7 +41,7 @@ class EmailVerificationTest : AbstractControllerTest() { private fun resetProperties() { tolgeeProperties.authentication.needsEmailVerification = false - tolgeeProperties.frontEndUrl = "dummy_frontend_url" + tolgeeProperties.frontEndUrl = defaultFrontendUrl tolgeeProperties.smtp.from = "aaa@aaa.aa" } @@ -120,7 +123,7 @@ class EmailVerificationTest : AbstractControllerTest() { assertThat(emailTestUtil.messageArgumentCaptor.firstValue.subject).isEqualTo("Tolgee e-mail verification") - assertThat(getMessageContent()).contains("dummy_frontend_url/login/verify_email/${user.id}/") + assertThat(getMessageContent()).contains("https://dummy-url.com/login/verify_email/${user.id}/") assertThat(userAccountService.findActive(user.id)).isNotNull } @@ -131,7 +134,7 @@ class EmailVerificationTest : AbstractControllerTest() { perform() val user = userAccountService.findActive(signUpDto.email) ?: throw NotFoundException() - assertThat(getMessageContent()).contains("dummy_frontend_url/login/verify_email/${user.id}/") + assertThat(getMessageContent()).contains("https://dummy-url.com/login/verify_email/${user.id}/") assertThat(userAccountService.findActive(user.id)).isNotNull } diff --git a/backend/app/src/test/resources/application.yaml b/backend/app/src/test/resources/application.yaml index 784c8169cb..ab4ec3b180 100644 --- a/backend/app/src/test/resources/application.yaml +++ b/backend/app/src/test/resources/application.yaml @@ -83,3 +83,4 @@ tolgee: server: http://localhost:8080 batch: concurrency: 10 + front-end-url: https://dummy-url.com