Class SecurityMockMvcConfigurers


  • public final class SecurityMockMvcConfigurers
    extends java.lang.Object
    Provides Security related MockMvcConfigurer implementations.
    Since:
    4.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.springframework.test.web.servlet.setup.MockMvcConfigurer springSecurity()
      Configures the MockMvcBuilder for use with Spring Security.
      static org.springframework.test.web.servlet.setup.MockMvcConfigurer springSecurity​(javax.servlet.Filter springSecurityFilterChain)
      Configures the MockMvcBuilder for use with Spring Security.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • 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 applying SecurityMockMvcRequestPostProcessors.testSecurityContext() .
        Returns:
        the MockMvcConfigurer to 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 applying SecurityMockMvcRequestPostProcessors.testSecurityContext() .
        Parameters:
        springSecurityFilterChain - the Filter to be added
        Returns:
        the MockMvcConfigurer to use