From 404f60a4499cf15899c039db8099ba867ad46406 Mon Sep 17 00:00:00 2001 From: Stephan Krusche Date: Sun, 24 Nov 2024 23:39:25 +0100 Subject: [PATCH] Update server dependencies Update Spring to 3.4.0 --- client/package-lock.json | 4 +- package-lock.json | 6 +++ server/build.gradle | 5 +- server/gradle.properties | 2 +- .../ls1/security/WebSecurityConfig.java | 5 +- .../controller/ApplicationControllerTest.java | 27 ++--------- .../ls1/controller/ThesisControllerTest.java | 28 ++--------- .../ls1/controller/TopicControllerTest.java | 29 ++---------- .../ls1/controller/UserControllerTest.java | 25 +--------- .../ls1/mock/BaseIntegrationTest.java | 46 ++++++++++++++++++- .../ls1/mock/TestSecurityConfig.java | 4 +- 11 files changed, 72 insertions(+), 109 deletions(-) create mode 100644 package-lock.json diff --git a/client/package-lock.json b/client/package-lock.json index 15752a17..06c7dab7 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -1,12 +1,12 @@ { "name": "thesis-track", - "version": "3.0.0", + "version": "3.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "thesis-track", - "version": "3.0.0", + "version": "3.0.2", "license": "MIT", "dependencies": { "@mantine/core": "7.14.1", diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..0bfe50a2 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "thesis-track", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/server/build.gradle b/server/build.gradle index 6ee7327b..a456e96c 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -45,7 +45,7 @@ dependencies { implementation "commons-io:commons-io:2.18.0" implementation "com.github.vladimir-bukhtoyarov:bucket4j-core:8.0.1" - implementation "org.mnode.ical4j:ical4j:4.0.5" + implementation "org.mnode.ical4j:ical4j:4.0.6" implementation "com.itextpdf:itext-core:9.0.0" implementation "com.itextpdf:html2pdf:6.0.0" implementation "com.auth0:java-jwt:4.4.0" @@ -68,8 +68,7 @@ dependencies { testImplementation "org.testcontainers:database-commons:${test_container_version}" testImplementation "org.testcontainers:postgresql:${test_container_version}" - // TODO: for some reason an update of org.junit.jupiter:junit-jupiter-engine to 5.11.x breaks the tests - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.5" + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.11.3" testRuntimeOnly "org.junit.platform:junit-platform-launcher:1.11.3" compileOnly "org.projectlombok:lombok:1.18.36" annotationProcessor "org.projectlombok:lombok:1.18.36" diff --git a/server/gradle.properties b/server/gradle.properties index ba745119..323049d8 100644 --- a/server/gradle.properties +++ b/server/gradle.properties @@ -1,4 +1,4 @@ rootProject.name=Thesis Track -spring_boot_version=3.3.6 +spring_boot_version=3.4.0 netty_version=4.1.115.Final test_container_version=1.20.4 diff --git a/server/src/main/java/thesistrack/ls1/security/WebSecurityConfig.java b/server/src/main/java/thesistrack/ls1/security/WebSecurityConfig.java index faf3a87d..29dc9c80 100644 --- a/server/src/main/java/thesistrack/ls1/security/WebSecurityConfig.java +++ b/server/src/main/java/thesistrack/ls1/security/WebSecurityConfig.java @@ -1,18 +1,16 @@ package thesistrack.ls1.security; -import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import org.springframework.http.HttpMethod; -import org.springframework.lang.NonNullApi; 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; -import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.core.session.SessionRegistryImpl; import org.springframework.security.web.SecurityFilterChain; @@ -25,6 +23,7 @@ @EnableWebSecurity @RequiredArgsConstructor @EnableMethodSecurity +@Profile("!test") // NOTE: this is a workaround to avoid overlapping definitions during test execution public class WebSecurityConfig { private final JwtAuthConverter jwtAuthConverter; diff --git a/server/src/test/java/thesistrack/ls1/controller/ApplicationControllerTest.java b/server/src/test/java/thesistrack/ls1/controller/ApplicationControllerTest.java index e1892436..ea045017 100644 --- a/server/src/test/java/thesistrack/ls1/controller/ApplicationControllerTest.java +++ b/server/src/test/java/thesistrack/ls1/controller/ApplicationControllerTest.java @@ -4,13 +4,10 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; -import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; -import org.testcontainers.containers.PostgreSQLContainer; -import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import thesistrack.ls1.constants.ApplicationState; import thesistrack.ls1.controller.payload.AcceptApplicationPayload; @@ -26,28 +23,10 @@ @Testcontainers class ApplicationControllerTest extends BaseIntegrationTest { - @Container - static PostgreSQLContainer dbContainer = new PostgreSQLContainer<>( - "postgres:16-alpine" - ); - - @BeforeAll - static void startDatabase() { - dbContainer.start(); - } - - @AfterAll - static void stopDatabase() { - dbContainer.stop(); - } @DynamicPropertySource - static void configureProperties(DynamicPropertyRegistry registry) { - dbContainer.start(); - - registry.add("spring.datasource.url", dbContainer::getJdbcUrl); - registry.add("spring.datasource.username", dbContainer::getUsername); - registry.add("spring.datasource.password", dbContainer::getPassword); + static void configureDynamicProperties(DynamicPropertyRegistry registry) { + configureProperties(registry); } @Test @@ -133,4 +112,4 @@ void acceptApplication_Success() throws Exception { .andExpect(status().isOk()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].state").value(ApplicationState.ACCEPTED.getValue())); } -} \ No newline at end of file +} diff --git a/server/src/test/java/thesistrack/ls1/controller/ThesisControllerTest.java b/server/src/test/java/thesistrack/ls1/controller/ThesisControllerTest.java index 7c825633..edfa30e4 100644 --- a/server/src/test/java/thesistrack/ls1/controller/ThesisControllerTest.java +++ b/server/src/test/java/thesistrack/ls1/controller/ThesisControllerTest.java @@ -3,12 +3,9 @@ import org.junit.jupiter.api.*; import org.springframework.http.MediaType; import org.springframework.mock.web.MockMultipartFile; -import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; 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.constants.*; import thesistrack.ls1.controller.payload.*; @@ -21,30 +18,11 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @Testcontainers -@ActiveProfiles("test") class ThesisControllerTest extends BaseIntegrationTest { - @Container - static PostgreSQLContainer dbContainer = new PostgreSQLContainer<>( - "postgres:16-alpine" - ); - - @BeforeAll - static void startDatabase() { - dbContainer.start(); - } - - @AfterAll - static void stopDatabase() { - dbContainer.stop(); - } @DynamicPropertySource - static void configureProperties(DynamicPropertyRegistry registry) { - dbContainer.start(); - - registry.add("spring.datasource.url", dbContainer::getJdbcUrl); - registry.add("spring.datasource.username", dbContainer::getUsername); - registry.add("spring.datasource.password", dbContainer::getPassword); + static void configureDynamicProperties(DynamicPropertyRegistry registry) { + configureProperties(registry); } @Nested @@ -256,4 +234,4 @@ void createPresentation_Success() throws Exception { .andExpect(status().isOk()); } } -} \ No newline at end of file +} diff --git a/server/src/test/java/thesistrack/ls1/controller/TopicControllerTest.java b/server/src/test/java/thesistrack/ls1/controller/TopicControllerTest.java index 1f3e392d..bc13fbba 100644 --- a/server/src/test/java/thesistrack/ls1/controller/TopicControllerTest.java +++ b/server/src/test/java/thesistrack/ls1/controller/TopicControllerTest.java @@ -1,17 +1,12 @@ package thesistrack.ls1.controller; -import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; -import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; 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.constants.ApplicationRejectReason; import thesistrack.ls1.controller.payload.CloseTopicPayload; @@ -27,28 +22,10 @@ @Testcontainers class TopicControllerTest extends BaseIntegrationTest { - @Container - static PostgreSQLContainer dbContainer = new PostgreSQLContainer<>( - "postgres:16-alpine" - ); - - @BeforeAll - static void startDatabase() { - dbContainer.start(); - } - - @AfterAll - static void stopDatabase() { - dbContainer.stop(); - } @DynamicPropertySource - static void configureProperties(DynamicPropertyRegistry registry) { - dbContainer.start(); - - registry.add("spring.datasource.url", dbContainer::getJdbcUrl); - registry.add("spring.datasource.username", dbContainer::getUsername); - registry.add("spring.datasource.password", dbContainer::getPassword); + static void configureDynamicProperties(DynamicPropertyRegistry registry) { + configureProperties(registry); } @Test @@ -195,4 +172,4 @@ void getTopics_WithSearch_Success() throws Exception { .andExpect(jsonPath("$.content", hasSize(equalTo(1)))) .andExpect(jsonPath("$.content[0].title", containsString("Specific"))); } -} \ No newline at end of file +} diff --git a/server/src/test/java/thesistrack/ls1/controller/UserControllerTest.java b/server/src/test/java/thesistrack/ls1/controller/UserControllerTest.java index 4897a820..9a6f6f20 100644 --- a/server/src/test/java/thesistrack/ls1/controller/UserControllerTest.java +++ b/server/src/test/java/thesistrack/ls1/controller/UserControllerTest.java @@ -3,12 +3,9 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; 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.mock.BaseIntegrationTest; @@ -19,28 +16,10 @@ @Testcontainers public class UserControllerTest extends BaseIntegrationTest { - @Container - static PostgreSQLContainer dbContainer = new PostgreSQLContainer<>( - "postgres:16-alpine" - ); - - @BeforeAll - static void startDatabase() { - dbContainer.start(); - } - - @AfterAll - static void stopDatabase() { - dbContainer.stop(); - } @DynamicPropertySource - static void configureProperties(DynamicPropertyRegistry registry) { - dbContainer.start(); - - registry.add("spring.datasource.url", dbContainer::getJdbcUrl); - registry.add("spring.datasource.username", dbContainer::getUsername); - registry.add("spring.datasource.password", dbContainer::getPassword); + static void configureDynamicProperties(DynamicPropertyRegistry registry) { + configureProperties(registry); } @Test diff --git a/server/src/test/java/thesistrack/ls1/mock/BaseIntegrationTest.java b/server/src/test/java/thesistrack/ls1/mock/BaseIntegrationTest.java index 74132363..59c0e661 100644 --- a/server/src/test/java/thesistrack/ls1/mock/BaseIntegrationTest.java +++ b/server/src/test/java/thesistrack/ls1/mock/BaseIntegrationTest.java @@ -4,6 +4,8 @@ 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; @@ -12,9 +14,13 @@ import org.springframework.context.annotation.Import; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; import org.springframework.test.context.TestPropertySource; 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 thesistrack.ls1.controller.payload.CreateApplicationPayload; import thesistrack.ls1.controller.payload.CreateThesisPayload; import thesistrack.ls1.controller.payload.ReplaceTopicPayload; @@ -29,38 +35,55 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) @Import(TestSecurityConfig.class) public abstract class BaseIntegrationTest { + @Autowired private ApplicationRepository applicationRepository; + @Autowired private ApplicationReviewerRepository applicationReviewerRepository; + @Autowired private NotificationSettingRepository notificationSettingRepository; + @Autowired private ThesisAssessmentRepository thesisAssessmentRepository; + @Autowired private ThesisCommentRepository thesisCommentRepository; + @Autowired private ThesisFeedbackRepository thesisFeedbackRepository; + @Autowired private ThesisFileRepository thesisFileRepository; + @Autowired private ThesisPresentationInviteRepository thesisPresentationInviteRepository; + @Autowired private ThesisPresentationRepository thesisPresentationRepository; + @Autowired private ThesisProposalRepository thesisProposalRepository; + @Autowired private ThesisRepository thesisRepository; + @Autowired private ThesisRoleRepository thesisRoleRepository; + @Autowired private ThesisStateChangeRepository thesisStateChangeRepository; + @Autowired private TopicRepository topicRepository; + @Autowired private TopicRoleRepository topicRoleRepository; + @Autowired private UserGroupRepository userGroupRepository; + @Autowired private UserRepository userRepository; @@ -70,6 +93,27 @@ public abstract class BaseIntegrationTest { @Autowired protected ObjectMapper objectMapper; + @Container + protected static PostgreSQLContainer dbContainer = new PostgreSQLContainer<>("postgres:17.1-alpine"); + + protected static void configureProperties(DynamicPropertyRegistry registry) { + dbContainer.start(); + + registry.add("spring.datasource.url", dbContainer::getJdbcUrl); + registry.add("spring.datasource.username", dbContainer::getUsername); + registry.add("spring.datasource.password", dbContainer::getPassword); + } + + @BeforeAll + protected static void startDatabase() { + dbContainer.start(); + } + + @AfterAll + protected static void stopDatabase() { + dbContainer.stop(); + } + @BeforeEach void deleteDatabase() { thesisCommentRepository.deleteAll(); @@ -195,4 +239,4 @@ protected UUID createTestThesis(String title) throws Exception { return objectMapper.readTree(response).get("thesisId").asText().transform(UUID::fromString); } -} \ No newline at end of file +} diff --git a/server/src/test/java/thesistrack/ls1/mock/TestSecurityConfig.java b/server/src/test/java/thesistrack/ls1/mock/TestSecurityConfig.java index 8a5691ea..301ffdf5 100644 --- a/server/src/test/java/thesistrack/ls1/mock/TestSecurityConfig.java +++ b/server/src/test/java/thesistrack/ls1/mock/TestSecurityConfig.java @@ -4,6 +4,7 @@ import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; @@ -26,6 +27,7 @@ @TestConfiguration @EnableWebSecurity @EnableMethodSecurity +@Profile("test") // should only be used during tests public class TestSecurityConfig { @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { @@ -81,4 +83,4 @@ private JwtAuthenticationConverter jwtAuthenticationConverter() { return converter; } -} \ No newline at end of file +}