Class SecurityMockMvcConfigurers
java.lang.Object
org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers
Provides Security related
MockMvcConfigurer implementations.- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.springframework.test.web.servlet.setup.MockMvcConfigurerConfigures the MockMvcBuilder for use with Spring Security.static org.springframework.test.web.servlet.setup.MockMvcConfigurerspringSecurity(javax.servlet.Filter springSecurityFilterChain) Configures the MockMvcBuilder for use with Spring Security.
-
Method Details
-
springSecurity
public static org.springframework.test.web.servlet.setup.MockMvcConfigurer springSecurity()Configures the MockMvcBuilder for use with Spring Security. Specifically the configurer adds the Spring Bean named "springSecurityFilterChain" as a Filter. It will also ensure that the TestSecurityContextHolder is leveraged for each request by applyingSecurityMockMvcRequestPostProcessors.testSecurityContext().- Returns:
- the
MockMvcConfigurerto use
-
springSecurity
public static org.springframework.test.web.servlet.setup.MockMvcConfigurer springSecurity(javax.servlet.Filter springSecurityFilterChain) Configures the MockMvcBuilder for use with Spring Security. Specifically the configurer adds the provided Filter. It will also ensure that the TestSecurityContextHolder is leveraged for each request by applyingSecurityMockMvcRequestPostProcessors.testSecurityContext().- Parameters:
springSecurityFilterChain- the Filter to be added- Returns:
- the
MockMvcConfigurerto use
-