Class MockMvcOAuth2AuthenticationUtil

java.lang.Object
com.broadleafcommerce.oauth2.resource.security.test.MockMvcOAuth2AuthenticationUtil
Direct Known Subclasses:
VendorMockMvcOAuth2AuthenticationUtil

@Configuration public class MockMvcOAuth2AuthenticationUtil extends Object

A bean providing simple mocking of OAuth2 access tokens for security tests with MockMVC. Required for authentication to succeed from the BearerTokenAuthenticationFilter when stateless = true.

This originally comes from JHipster, see https://github.com/jhipster/generator-jhipster/pull/4066 for more details about the original context of this support.

This is required to be an @Configuration class because of the @MockBean usage. This is automatically done via the MockOauth2ResourceServerAutoConfiguration.

Author:
Phillip Verheyden (phillipuniverse)
  • Constructor Details

    • MockMvcOAuth2AuthenticationUtil

      public MockMvcOAuth2AuthenticationUtil()
  • Method Details

    • withAuthentication

      public org.springframework.test.web.servlet.request.RequestPostProcessor withAuthentication(Set<String> scopes, Set<String> authorities, Set<String> applications, String tenant, Boolean isGlobal, String username, String userId)
    • withAuthentication

      public org.springframework.test.web.servlet.request.RequestPostProcessor withAuthentication(Set<String> scopes, Set<String> authorities, Set<String> applications, String tenant, Boolean isGlobal, String username, String userId, Map<String,Object> authDetails)
    • withScopes

      public org.springframework.test.web.servlet.request.RequestPostProcessor withScopes(Set<String> scopes)
    • withAuthorities

      public org.springframework.test.web.servlet.request.RequestPostProcessor withAuthorities(Set<String> authorities)
    • withAuthoritiesAndTenant

      public org.springframework.test.web.servlet.request.RequestPostProcessor withAuthoritiesAndTenant(Set<String> authorities, String tenant)
    • withAuthoritiesAndTenant

      public org.springframework.test.web.servlet.request.RequestPostProcessor withAuthoritiesAndTenant(Set<String> authorities, Set<String> applications, Boolean isGlobal, String user)
    • withAuthoritiesAndDetails

      public org.springframework.test.web.servlet.request.RequestPostProcessor withAuthoritiesAndDetails(Set<String> authorities, Map<String,Object> details)
    • withAuthoritiesAndTenant

      public org.springframework.test.web.servlet.request.RequestPostProcessor withAuthoritiesAndTenant(Set<String> authorities, Set<String> applications, String tenant, Boolean isGlobal, String user)
    • withAuthoritiesAndTenant

      public org.springframework.test.web.servlet.request.RequestPostProcessor withAuthoritiesAndTenant(Set<String> authorities, Set<String> applications, Boolean isGlobal, String username, String userId)
    • withAuthoritiesAndTenant

      public org.springframework.test.web.servlet.request.RequestPostProcessor withAuthoritiesAndTenant(Set<String> authorities, Set<String> applications, String tenant, Boolean isGlobal, String username, String userId)