Class SecurityMockMvcConfigurers

java.lang.Object
org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers

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

    Modifier and Type
    Method
    Description
    static org.springframework.test.web.servlet.setup.MockMvcConfigurer
    Configures the MockMvcBuilder for use with Spring Security.
    static org.springframework.test.web.servlet.setup.MockMvcConfigurer
    springSecurity(jakarta.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 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 applying SecurityMockMvcRequestPostProcessors.testSecurityContext() .
      Returns:
      the MockMvcConfigurer to use
    • springSecurity

      public static org.springframework.test.web.servlet.setup.MockMvcConfigurer springSecurity(jakarta.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