From 9c3a446252f30b65ab8d4e1ff9c39322141c6f63 Mon Sep 17 00:00:00 2001
From: KronosDP <darrel.danadyaksa19@gmail.com>
Date: Fri, 7 Mar 2025 10:00:30 +0700
Subject: [PATCH] [REFACTOR] Remove unused TestSecurityConfig from
 AuthenticationControllerTest and configure SecurityFilterChain

---
 .../controller/AuthenticationControllerTest.java     | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/test/java/com/safetypin/authentication/controller/AuthenticationControllerTest.java b/src/test/java/com/safetypin/authentication/controller/AuthenticationControllerTest.java
index a3ac6da..db80b8a 100644
--- a/src/test/java/com/safetypin/authentication/controller/AuthenticationControllerTest.java
+++ b/src/test/java/com/safetypin/authentication/controller/AuthenticationControllerTest.java
@@ -29,7 +29,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
 
 @WebMvcTest(AuthenticationController.class)
-@Import({AuthenticationControllerTest.TestConfig.class, AuthenticationControllerTest.TestSecurityConfig.class})
+@Import({AuthenticationControllerTest.TestConfig.class})
 class AuthenticationControllerTest {
 
     @Autowired
@@ -211,5 +211,15 @@ class AuthenticationControllerTest {
         public AuthenticationService authenticationService() {
             return Mockito.mock(AuthenticationService.class);
         }
+        
+        @Bean
+        public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
+            http
+                .csrf(AbstractHttpConfigurer::disable)  // Appropriate for JWT authentication
+                .authorizeHttpRequests(auth -> auth
+                    .anyRequest().permitAll()
+                );
+            return http.build();
+        }
     }
 }
-- 
GitLab