From c503d566625f69d1d5f0d0bdf23b663dc5e66521 Mon Sep 17 00:00:00 2001 From: Fabian Emilius Date: Wed, 30 Oct 2024 01:05:17 +0100 Subject: [PATCH] Add test application config --- .../ls1/mock/BaseIntegrationTest.java | 9 +-- .../ls1/mock/TestSecurityConfig.java | 4 +- .../src/test/resources/application-test.yml | 69 +++++++++++++++++++ 3 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 server/src/test/resources/application-test.yml diff --git a/server/src/test/java/thesistrack/ls1/mock/BaseIntegrationTest.java b/server/src/test/java/thesistrack/ls1/mock/BaseIntegrationTest.java index c4f52f93..5c5561e5 100644 --- a/server/src/test/java/thesistrack/ls1/mock/BaseIntegrationTest.java +++ b/server/src/test/java/thesistrack/ls1/mock/BaseIntegrationTest.java @@ -4,8 +4,6 @@ import com.auth0.jwt.algorithms.Algorithm; import com.fasterxml.jackson.databind.ObjectMapper; import com.jayway.jsonpath.JsonPath; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestInstance; import org.springframework.beans.factory.annotation.Autowired; @@ -13,13 +11,9 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Import; import org.springframework.http.MediaType; -import org.springframework.test.context.DynamicPropertyRegistry; -import org.springframework.test.context.DynamicPropertySource; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import org.testcontainers.containers.PostgreSQLContainer; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; import thesistrack.ls1.controller.payload.CreateApplicationPayload; import thesistrack.ls1.controller.payload.CreateThesisPayload; import thesistrack.ls1.controller.payload.ReplaceTopicPayload; @@ -32,6 +26,7 @@ @AutoConfigureMockMvc @TestInstance(TestInstance.Lifecycle.PER_CLASS) @Import(TestSecurityConfig.class) +@ActiveProfiles("test") public abstract class BaseIntegrationTest { @Autowired private ApplicationRepository applicationRepository; diff --git a/server/src/test/java/thesistrack/ls1/mock/TestSecurityConfig.java b/server/src/test/java/thesistrack/ls1/mock/TestSecurityConfig.java index 533a090b..8a5691ea 100644 --- a/server/src/test/java/thesistrack/ls1/mock/TestSecurityConfig.java +++ b/server/src/test/java/thesistrack/ls1/mock/TestSecurityConfig.java @@ -5,6 +5,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Primary; import org.springframework.security.config.Customizer; +import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; @@ -24,9 +25,9 @@ @TestConfiguration @EnableWebSecurity +@EnableMethodSecurity public class TestSecurityConfig { @Bean - @Primary public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { http .cors(Customizer.withDefaults()) @@ -41,7 +42,6 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti } @Bean - @Primary public JwtDecoder jwtDecoder() { return token -> { var decodedJWT = JWT.decode(token); diff --git a/server/src/test/resources/application-test.yml b/server/src/test/resources/application-test.yml new file mode 100644 index 00000000..c0bf74c9 --- /dev/null +++ b/server/src/test/resources/application-test.yml @@ -0,0 +1,69 @@ +logging: +level: + liquibase: INFO + net.fortuna.ical4j.util.Configurator: INFO + +spring: + datasource: + url: jdbc:postgresql://localhost:5432/thesis-track + username: thesis-track-postgres + password: thesis-track-postgres + driver-class-name: org.postgresql.Driver + liquibase: + enabled: true + change-log: db/changelog/db.changelog-master.xml + jpa: + open-in-view: true + hibernate: + ddl-auto: validate + show-sql: false + properties: + hibernate: + format_sql: false + thymeleaf: + prefix: classpath:/mail-templates/ + suffix: .html + servlet: + multipart: + max-file-size: 20MB + max-request-size: 20MB + mail: + host: localhost + port: 25 + properties: + mail: + transport: + protocol: smtp + smtp: + starttls: + enable: true + +server: + servlet: + context-path: /api + +thesis-track: + keycloak: + host: http://localhost:8081 + realm-name: thesis-track + client-id: thesis-track-app + service-client: + id: thesis-track-service-client + secret: "" + student-group-name: thesis-students + calendar: + enabled: false + url: "" + username: "" + password: "" + client: + host: http://localhost:3000 + mail: + enabled: false + sender: test@ios.ase.cit.tum.de + signature: "" + workspace-url: https://slack.com + bcc-recipients: "" + storage: + upload-location: uploads + scientific-writing-guide: ""