Skip to content

Commit 4a8126f

Browse files
committed
Fix: Resolve ApplicationContext failure in integration tests
- Added @MockBean for UserDetailsService to SecurityConfigIntegrationTest. - This prevents the initial ApplicationContext load failure by providing a mock dependency for Spring Security, allowing all subsequent integration tests to run.
1 parent 3610fb2 commit 4a8126f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

backend/src/test/java/com/example/phoebe/integration/config/SecurityConfigIntegrationTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import org.junit.jupiter.api.Test;
1212
import org.springframework.beans.factory.annotation.Autowired;
1313
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
14+
import org.springframework.boot.test.mock.mockito.MockBean;
15+
import org.springframework.security.core.userdetails.UserDetailsService;
1416
import org.springframework.security.crypto.password.PasswordEncoder;
1517
import org.springframework.test.annotation.DirtiesContext;
1618
import org.springframework.test.web.servlet.MockMvc;
@@ -49,6 +51,9 @@ class SecurityConfigIntegrationTest extends BaseIntegrationTest {
4951
@Autowired
5052
private NewsRepository newsRepository;
5153

54+
@MockBean
55+
private UserDetailsService userDetailsService;
56+
5257
private String adminAuthHeader;
5358
private String editorAuthHeader;
5459

0 commit comments

Comments
 (0)