Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HAI Profile overhaul #397

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ services:
HAITATON_EMAIL_FILTER_USE: false
CLAMAV_BASE_URL: http://clamav-api:3030
HAITATON_TESTDATA_ENABLED: true
HAITATON_FEATURE_HANKE_EDITING: true
HAITATON_FEATURE_USER_MANAGEMENT: true
depends_on:
- db
- clamav-api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private const val BASE_URL = "/hankkeet"

@WebMvcTest(HankeController::class, properties = ["haitaton.features.hanke-editing=false"])
@Import(IntegrationTestConfiguration::class)
@ActiveProfiles("itest")
@ActiveProfiles("test")
@WithMockUser(USERNAME)
class HankeControllerHankeEditingDisabledITests(@Autowired override val mockMvc: MockMvc) :
ControllerTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private const val BASE_URL = "/hankkeet"
*/
@WebMvcTest(HankeController::class)
@Import(IntegrationTestConfiguration::class)
@ActiveProfiles("itest")
@ActiveProfiles("test")
@WithMockUser(USERNAME)
class HankeControllerITests(@Autowired override val mockMvc: MockMvc) : ControllerTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.testcontainers.junit.jupiter.Testcontainers

@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("default")
@ActiveProfiles("test")
internal class HankeRepositoryITests : DatabaseTest() {

@Autowired private lateinit var hankeRepository: HankeRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private const val NAME_SOMETHING = "Som Et Hing"

@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("default")
@ActiveProfiles("test")
@WithMockUser(USER_NAME)
class HankeServiceITests : DatabaseTest() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.testcontainers.junit.jupiter.Testcontainers

@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("default")
@ActiveProfiles("test")
internal class HanketunnusServiceImplITest : DatabaseTest() {

@Autowired lateinit var hanketunnusService: HanketunnusService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ import io.sentry.protocol.SentryId
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.test.context.TestConfiguration
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Profile
import org.springframework.context.event.ContextRefreshedEvent
import org.springframework.context.event.EventListener
import org.springframework.jdbc.core.JdbcOperations
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.web.SecurityFilterChain

@TestConfiguration
@Profile("itest")
@EnableConfigurationProperties(GdprProperties::class, FeatureFlags::class)
class IntegrationTestConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.testcontainers.junit.jupiter.Testcontainers

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Testcontainers
@ActiveProfiles("default")
@ActiveProfiles("test")
@AutoConfigureMockMvc
class SpringdocITest(@Autowired override val mockMvc: MockMvc) : ControllerTest, DatabaseTest() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers

@WebMvcTest(StatusController::class)
@Import(IntegrationTestConfiguration::class)
@ActiveProfiles("itest")
@ActiveProfiles("test")
class StatusControllerITests(@Autowired val mockMvc: MockMvc) {

@Autowired lateinit var jdbcOperations: JdbcOperations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private const val BASE_URL = "/hakemukset"

@WebMvcTest(ApplicationController::class)
@Import(IntegrationTestConfiguration::class)
@ActiveProfiles("itest")
@ActiveProfiles("test")
class ApplicationControllerITest(@Autowired override val mockMvc: MockMvc) : ControllerTest {

@Autowired private lateinit var applicationService: ApplicationService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private val dataWithoutAreas = AlluDataFactory.createCableReportApplicationData(

@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("default", "emailtest")
@ActiveProfiles("test")
@WithMockUser(USERNAME)
class ApplicationServiceITest : DatabaseTest() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status

@WebMvcTest(ApplicationAttachmentController::class)
@Import(IntegrationTestConfiguration::class)
@ActiveProfiles("itest")
@ActiveProfiles("test")
@WithMockUser(USERNAME)
class ApplicationAttachmentControllerITest(@Autowired override val mockMvc: MockMvc) :
ControllerTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private const val ALLU_ID = 42

@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("default")
@ActiveProfiles("test")
@WithMockUser(USERNAME)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class ApplicationAttachmentServiceITest : DatabaseTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.testcontainers.junit.jupiter.Testcontainers

@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("default")
@ActiveProfiles("test")
@TestPropertySource(locations = ["classpath:application-test.properties"])
class FileScanClientITest : DatabaseTest() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status

@WebMvcTest(HankeAttachmentController::class)
@Import(IntegrationTestConfiguration::class)
@ActiveProfiles("itest")
@ActiveProfiles("test")
@WithMockUser(USERNAME)
class HankeAttachmentControllerITests(@Autowired override val mockMvc: MockMvc) : ControllerTest {

Expand Down Expand Up @@ -201,7 +201,7 @@ class HankeAttachmentControllerITests(@Autowired override val mockMvc: MockMvc)
properties = ["haitaton.features.hanke-editing=false"]
)
@Import(IntegrationTestConfiguration::class)
@ActiveProfiles("itest")
@ActiveProfiles("test")
@WithMockUser(USERNAME)
class HankeAttachmentControllerHankeEditingDisabledITests(
@Autowired override val mockMvc: MockMvc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import org.testcontainers.junit.jupiter.Testcontainers

@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("default")
@ActiveProfiles("test")
@WithMockUser(USERNAME)
@TestPropertySource(locations = ["classpath:application-test.properties"])
class HankeAttachmentServiceITests : DatabaseTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPat

@WebMvcTest(PublicHankeController::class)
@Import(IntegrationTestConfiguration::class)
@ActiveProfiles("itest")
@ActiveProfiles("test")
class PublicHankeControllerITests(@Autowired override val mockMvc: MockMvc) : ControllerTest {

@Autowired private lateinit var hankeService: HankeService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.testcontainers.junit.jupiter.Testcontainers
"[email protected];[email protected]"
]
)
@ActiveProfiles("default", "emailtest")
@ActiveProfiles("test")
class EmailSenderServiceFilterITest : DatabaseTest() {

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private const val APPLICATION_IDENTIFIER = "JS2300001"

@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("default", "emailtest")
@ActiveProfiles("test")
class EmailSenderServiceITest : DatabaseTest() {

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private const val USERID = "test-user"

@WebMvcTest(controllers = [GdprController::class], properties = ["haitaton.gdpr.disabled=false"])
@Import(IntegrationTestConfiguration::class)
@ActiveProfiles("itest")
@ActiveProfiles("test")
@WithMockUser(USERID)
class GdprControllerITests(@Autowired var mockMvc: MockMvc) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private const val USERID = "test-user"

@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("default")
@ActiveProfiles("test")
@WithMockUser(USERID)
class GdprServiceITest : DatabaseTest() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.testcontainers.junit.jupiter.Testcontainers

@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("default")
@ActiveProfiles("test")
internal class GeometriatDaoImplITest : DatabaseTest() {

private val expectedPolygonArea = 1707f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import org.testcontainers.junit.jupiter.Testcontainers

@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("default")
@ActiveProfiles("test")
@WithMockUser(username = "test")
internal class GeometriatServiceImplITest : DatabaseTest() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import org.testcontainers.junit.jupiter.Testcontainers
// Thus, have to use this test containers -way, which uses the proper PostgreSQL.
@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("default")
@ActiveProfiles("test")
class AuditLogServiceITests : DatabaseTest() {

@Autowired private lateinit var entityManager: EntityManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,9 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
private const val USERNAME = "testUser"
private const val HANKE_TUNNUS = HankeFactory.defaultHankeTunnus

@WebMvcTest(
HankeKayttajaController::class,
properties = ["haitaton.features.user-management=true"],
)
@WebMvcTest(HankeKayttajaController::class)
@Import(IntegrationTestConfiguration::class)
@ActiveProfiles("itest")
@ActiveProfiles("test")
@WithMockUser(USERNAME)
class HankeKayttajaControllerITest(@Autowired override val mockMvc: MockMvc) : ControllerTest {

Expand Down Expand Up @@ -454,7 +451,7 @@ class HankeKayttajaControllerITest(@Autowired override val mockMvc: MockMvc) : C
properties = ["haitaton.features.user-management=false"],
)
@Import(IntegrationTestConfiguration::class)
@ActiveProfiles("itest")
@ActiveProfiles("test")
@WithMockUser(USERNAME)
class HankeKayttajaControllerFeatureDisabledITest(@Autowired override val mockMvc: MockMvc) :
ControllerTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const val kayttajaTunnistePattern = "[a-zA-z0-9]{24}"

@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("default")
@ActiveProfiles("test")
@WithMockUser(USERNAME)
class HankeKayttajaServiceITest : DatabaseTest() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.testcontainers.junit.jupiter.Testcontainers

@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("default")
@ActiveProfiles("test")
@WithMockUser(username = "test7358")
class PermissionServiceITest : DatabaseTest() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private const val BASE_URL = "/testdata"
properties = ["haitaton.testdata.enabled=false"],
)
@Import(IntegrationTestConfiguration::class)
@ActiveProfiles("itest")
@ActiveProfiles("test")
@WithMockUser(USERNAME)
class TestDataControllerDisabledITest(@Autowired override val mockMvc: MockMvc) : ControllerTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private const val BASE_URL = "/testdata"
properties = ["haitaton.testdata.enabled=true"],
)
@Import(IntegrationTestConfiguration::class)
@ActiveProfiles("itest")
@ActiveProfiles("test")
@WithMockUser(USERNAME)
class TestDataControllerEnabledITest(@Autowired override val mockMvc: MockMvc) : ControllerTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private const val USERNAME = "testUser"
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = ["haitaton.testdata.enabled=true"],
)
@ActiveProfiles("default")
@ActiveProfiles("test")
@WithMockUser(USERNAME)
class TestDataServiceITest : DatabaseTest() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.testcontainers.junit.jupiter.Testcontainers

@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("default")
@ActiveProfiles("test")
internal class TormaystarkasteluTormaysServicePGITest : DatabaseTest() {

@Autowired private lateinit var geometriatDao: GeometriatDao
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Profile
import org.springframework.http.client.reactive.ReactorClientHttpConnector
import org.springframework.jdbc.core.JdbcOperations
import org.springframework.web.reactive.function.client.WebClient
import reactor.netty.http.client.HttpClient

@Configuration
@Profile("default")
@EnableConfigurationProperties(
GdprProperties::class,
FeatureFlags::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ haitaton.gdpr.delete-scope=${HAITATON_GDPR_DELETE_SCOPE:haitaton.gdprdelete}
#logging.level.org.springframework.security=DEBUG

# Disable endpoints that are e.g. in development and should not be in production.
haitaton.features.hanke-editing=${HAITATON_FEATURE_HANKE_EDITING:true}
haitaton.features.user-management=${HAITATON_FEATURE_USER_MANAGEMENT:true}
haitaton.features.hanke-editing=${HAITATON_FEATURE_HANKE_EDITING:false}
haitaton.features.user-management=${HAITATON_FEATURE_USER_MANAGEMENT:false}

# For dev and test environments, enable the testdata controller for resetting data
haitaton.testdata.enabled=${HAITATON_TESTDATA_ENABLED:false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ spring.mail.properties.mail.smtp.auth=false
spring.mail.properties.mail.smtp.starttls.enable=false
spring.mail.properties.mail.smtp.starttls.required=false
spring.mail.properties.mail.debug=false
haitaton.clamav.baseUrl=http://localhost:6789
haitaton.features.hanke-editing=true
haitaton.features.user-management=true
Loading