-
[Spring Security} Spring 3.x에서 mockMvc 테스트 하는 법백엔드/Spring 2021. 1. 15. 09:04
🚀 들어가며...
- MockMVC를 사용하면 테스트 케이스를 보다 다양하게 구성할 수 있는데, 사내의 자바와 서블릿은 spring 3.x에 가능했다.
- 하지만 Spring security Test는 spring 4.x에서 동작하기 때문에 생기는 문제점...
📑 내용
stack over flow의 일부 내용
Update:
4.0.0.RC2 works for spring-security 3.x. For spring-security 4 spring-security-test become part of spring-security (http://docs.spring.io/spring-security/site/docs/4.0.x/reference/htmlsingle/#test, version is the same).- Spring Security Test 4.0.0 RC2를 사용하거나, 그 외의 버전을 확인하면 됩니다.
- 저의 경우는 Spring Security Test 4.0.0 RC2 를 사용했습니다.
- 아래의 래퍼런스와 stack over flow의 글을 참고하세요.
- Maven : Spring Security Test 4.0.0.RC2
<dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-test</artifactId> <version>4.0.0.RC2</version> </dependency>
🔗 레퍼런스
docs.spring.io/spring-security/site/docs/4.0.0.RC2/reference/htmlsingle/
Spring Security Reference
The authenticator is also responsible for retrieving any required user attributes. This is because the permissions on the attributes may depend on the type of authentication being used. For example, if binding as the user, it may be necessary to read them
docs.spring.io
🙋🏻♂️ 후기
API와 레퍼런스를 하나씩 읽어보는 게 중요하구나라며 느끼고 있다.
🔗 참고한 글
stackoverflow.com/questions/15203485/spring-test-security-how-to-mock-authentication
Spring Test & Security: How to mock authentication?
I was trying to figure out how to unit test if my the URLs of my controllers are properly secured. Just in case someone changes things around and accidentally removes security settings. My contro...
stackoverflow.com
반응형'백엔드 > Spring' 카테고리의 다른 글
[Spring] Servlet 응답, 요청 객체를 얻는 방법 (HttpServletRequest, HttpServletResponse) (0) 2021.11.04 Spring Security에서 Ajax 권한 검사하는 법 (0) 2021.10.30 [Spring JPA] 객체의 상태에 대해서 알아보자 (Transient, Persistent, Detached) (0) 2021.01.12 [Spring JPA] 검색 쿼리 개발 (5) 2021.01.02