더북(TheBook)

4.2.2 웹 보안 테스트하기

스프링 시큐리티는 간단한 보안 웹 애플리케이션 테스트를 지원한다. 이 기능을 이용하려면 빌드에 스프링 시큐리티 테스트 모듈을 추가해야 한다. 그레이들을 사용할 때는 testCompile을 추가하면 된다.2


testCompile('org.springframework.security:spring-security-test')

메이븐을 사용한다면 다음과 같이 <dependency>를 빌드에 추가하자.


<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-test</artifactId>
    <scope>test</scope>
</dependency>

애플리케이션의 클래스패스에 스프링 시큐리티 테스트 모듈이 있으면 MockMvc 인스턴스를 생성할 때 스프링 시큐리티 구성자(Spring Security  configurer)를 적용하면 된다.

 

2 역주 

보안 테스트는 3장 예제 코드를 기준으로 작성한다.

신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.