배경

커스텀 SecurityConfigJwtAuthenticationFilter를 추가한 뒤 기존 CI 테스트가 실패했다.

주요 실패 대상:

테스트 실패의 핵심은 운영 보안 설정이 테스트 컨텍스트에도 영향을 주기 시작했다는 점이다.

컨트롤러 slice 테스트 실패

증상

@WebMvcTest 기반 컨트롤러 테스트에서 ApplicationContext 로딩이 실패했다.

대표 원인:

No qualifying bean of type 'com.team6.moduply.auth.JwtTokenProvider'
Error creating bean with name 'jwtAuthenticationFilter'

왜 발생했는가

@WebMvcTest는 전체 애플리케이션을 띄우지 않고 MVC 계층 중심으로 테스트한다.

하지만 JwtAuthenticationFilterOncePerRequestFilter이므로 웹 계층 Bean으로 잡힐 수 있다.

이 필터는 다음 의존성을 가진다.

JwtAuthenticationFilter
→ JwtTokenProvider
→ JwtAuthenticationService
→ ModuPlyAuthenticationEntryPoint

반면 @WebMvcTest slice 컨텍스트에는 서비스/인증 관련 Bean이 전부 올라오지 않는다.

그래서 필터 Bean을 만들다가 의존성 누락으로 실패한다.

addFilters = false의 한계