From 2973a942dc5557ef779e1ac68f903e1a87296687 Mon Sep 17 00:00:00 2001 From: jarno Date: Sat, 19 Oct 2024 17:23:06 +0200 Subject: [PATCH 1/2] FIX: config now has @Configuration annotation so public data should now be accessible --- pom.xml | 2 +- .../java/com/wiemanboy/wiemanapi/config/SecurityConfig.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 23720d5..f2afd53 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.wiemanboy WiemanApi - 1.1.1 + 1.1.3 WiemanApi WiemanApi diff --git a/src/main/java/com/wiemanboy/wiemanapi/config/SecurityConfig.java b/src/main/java/com/wiemanboy/wiemanapi/config/SecurityConfig.java index 6a0eac2..ad27bc5 100644 --- a/src/main/java/com/wiemanboy/wiemanapi/config/SecurityConfig.java +++ b/src/main/java/com/wiemanboy/wiemanapi/config/SecurityConfig.java @@ -2,6 +2,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; @@ -10,7 +11,7 @@ import org.springframework.security.oauth2.jwt.*; import org.springframework.security.web.SecurityFilterChain; - +@Configuration @EnableWebSecurity public class SecurityConfig { From 0eef2f4a20a828a16e22cf1087dfc9acfc783b54 Mon Sep 17 00:00:00 2001 From: jarno Date: Sat, 19 Oct 2024 17:30:43 +0200 Subject: [PATCH 2/2] FIX: test security config --- .../com/wiemanboy/wiemanapi/WiemanApiApplicationTests.java | 4 ++-- .../config/{TestSecurityConfig.java => SecurityConfig.java} | 6 +++--- .../wiemanapi/presentation/ProfileControllerTest.java | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename src/test/java/com/wiemanboy/wiemanapi/config/{TestSecurityConfig.java => SecurityConfig.java} (84%) diff --git a/src/test/java/com/wiemanboy/wiemanapi/WiemanApiApplicationTests.java b/src/test/java/com/wiemanboy/wiemanapi/WiemanApiApplicationTests.java index 39c1474..d08f554 100644 --- a/src/test/java/com/wiemanboy/wiemanapi/WiemanApiApplicationTests.java +++ b/src/test/java/com/wiemanboy/wiemanapi/WiemanApiApplicationTests.java @@ -1,10 +1,10 @@ package com.wiemanboy.wiemanapi; -import com.wiemanboy.wiemanapi.config.TestSecurityConfig; +import com.wiemanboy.wiemanapi.config.SecurityConfig; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -@SpringBootTest(classes = {TestSecurityConfig.class, WiemanApiApplication.class}) +@SpringBootTest(classes = {SecurityConfig.class, WiemanApiApplication.class}) class WiemanApiApplicationTests { @Test diff --git a/src/test/java/com/wiemanboy/wiemanapi/config/TestSecurityConfig.java b/src/test/java/com/wiemanboy/wiemanapi/config/SecurityConfig.java similarity index 84% rename from src/test/java/com/wiemanboy/wiemanapi/config/TestSecurityConfig.java rename to src/test/java/com/wiemanboy/wiemanapi/config/SecurityConfig.java index ae03b9f..11173ef 100644 --- a/src/test/java/com/wiemanboy/wiemanapi/config/TestSecurityConfig.java +++ b/src/test/java/com/wiemanboy/wiemanapi/config/SecurityConfig.java @@ -1,13 +1,13 @@ package com.wiemanboy.wiemanapi.config; -import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.web.SecurityFilterChain; -@TestConfiguration -public class TestSecurityConfig { +@Configuration +public class SecurityConfig { @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { return http.authorizeHttpRequests( diff --git a/src/test/java/com/wiemanboy/wiemanapi/presentation/ProfileControllerTest.java b/src/test/java/com/wiemanboy/wiemanapi/presentation/ProfileControllerTest.java index 6eccb4c..77e8477 100644 --- a/src/test/java/com/wiemanboy/wiemanapi/presentation/ProfileControllerTest.java +++ b/src/test/java/com/wiemanboy/wiemanapi/presentation/ProfileControllerTest.java @@ -2,7 +2,7 @@ import com.wiemanboy.wiemanapi.WiemanApiApplication; import com.wiemanboy.wiemanapi.builders.ProfileBuilder; -import com.wiemanboy.wiemanapi.config.TestSecurityConfig; +import com.wiemanboy.wiemanapi.config.SecurityConfig; import com.wiemanboy.wiemanapi.data.ProfileRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -19,7 +19,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@SpringBootTest(classes = {TestSecurityConfig.class, WiemanApiApplication.class}) +@SpringBootTest(classes = {SecurityConfig.class, WiemanApiApplication.class}) @AutoConfigureMockMvc public class ProfileControllerTest {