public final class SecurityMockServerConfigurers
extends java.lang.Object
WebTestClient.Builder.apply(WebTestClientConfigurer)
.Modifier and Type | Class and Description |
---|---|
static class |
SecurityMockServerConfigurers.CsrfMutator |
static class |
SecurityMockServerConfigurers.JwtMutator
Updates the WebServerExchange using
{@link
SecurityMockServerConfigurers#mockAuthentication(Authentication)} . |
static class |
SecurityMockServerConfigurers.OAuth2ClientMutator |
static class |
SecurityMockServerConfigurers.OAuth2LoginMutator |
static class |
SecurityMockServerConfigurers.OidcLoginMutator |
static class |
SecurityMockServerConfigurers.OpaqueTokenMutator |
static class |
SecurityMockServerConfigurers.UserExchangeMutator
Updates the WebServerExchange using
{@link
SecurityMockServerConfigurers#mockUser(UserDetails)} . |
Modifier and Type | Method and Description |
---|---|
static SecurityMockServerConfigurers.CsrfMutator |
csrf() |
static <T extends org.springframework.test.web.reactive.server.WebTestClientConfigurer & org.springframework.test.web.reactive.server.MockServerConfigurer> |
mockAuthentication(Authentication authentication)
Updates the ServerWebExchange to use the provided Authentication as the Principal
|
static SecurityMockServerConfigurers.JwtMutator |
mockJwt()
Updates the ServerWebExchange to establish a
SecurityContext that has a
JwtAuthenticationToken for the Authentication and a Jwt for
the Authentication.getPrincipal() . |
static SecurityMockServerConfigurers.OAuth2ClientMutator |
mockOAuth2Client()
Updates the ServerWebExchange to establish a
OAuth2AuthorizedClient in the
session. |
static SecurityMockServerConfigurers.OAuth2ClientMutator |
mockOAuth2Client(java.lang.String registrationId)
Updates the ServerWebExchange to establish a
OAuth2AuthorizedClient in the
session. |
static SecurityMockServerConfigurers.OAuth2LoginMutator |
mockOAuth2Login()
Updates the ServerWebExchange to establish a
SecurityContext that has a
OAuth2AuthenticationToken for the Authentication . |
static SecurityMockServerConfigurers.OidcLoginMutator |
mockOidcLogin()
Updates the ServerWebExchange to establish a
SecurityContext that has a
OAuth2AuthenticationToken for the Authentication . |
static SecurityMockServerConfigurers.OpaqueTokenMutator |
mockOpaqueToken()
Updates the ServerWebExchange to establish a
SecurityContext that has a
BearerTokenAuthentication for the Authentication and an
OAuth2AuthenticatedPrincipal for the Authentication.getPrincipal() . |
static SecurityMockServerConfigurers.UserExchangeMutator |
mockUser()
Updates the ServerWebExchange to use a UserDetails to create a
UsernamePasswordAuthenticationToken as the Principal.
|
static SecurityMockServerConfigurers.UserExchangeMutator |
mockUser(java.lang.String username)
Updates the ServerWebExchange to use a UserDetails to create a
UsernamePasswordAuthenticationToken as the Principal.
|
static <T extends org.springframework.test.web.reactive.server.WebTestClientConfigurer & org.springframework.test.web.reactive.server.MockServerConfigurer> |
mockUser(UserDetails userDetails)
Updates the ServerWebExchange to use the provided UserDetails to create a
UsernamePasswordAuthenticationToken as the Principal
|
static org.springframework.test.web.reactive.server.MockServerConfigurer |
springSecurity()
Sets up Spring Security's
WebTestClient test support |
public static org.springframework.test.web.reactive.server.MockServerConfigurer springSecurity()
WebTestClient
test supportpublic static <T extends org.springframework.test.web.reactive.server.WebTestClientConfigurer & org.springframework.test.web.reactive.server.MockServerConfigurer> T mockAuthentication(Authentication authentication)
authentication
- the Authentication to use.public static <T extends org.springframework.test.web.reactive.server.WebTestClientConfigurer & org.springframework.test.web.reactive.server.MockServerConfigurer> T mockUser(UserDetails userDetails)
userDetails
- the UserDetails to use.public static SecurityMockServerConfigurers.UserExchangeMutator mockUser()
SecurityMockServerConfigurers.UserExchangeMutator
to usepublic static SecurityMockServerConfigurers.UserExchangeMutator mockUser(java.lang.String username)
WebTestClientConfigurer
to usepublic static SecurityMockServerConfigurers.JwtMutator mockJwt()
SecurityContext
that has a
JwtAuthenticationToken
for the Authentication
and a Jwt
for
the Authentication.getPrincipal()
. All details are declarative and do not
require the JWT to be valid.SecurityMockServerConfigurers.JwtMutator
to further configure or usepublic static SecurityMockServerConfigurers.OpaqueTokenMutator mockOpaqueToken()
SecurityContext
that has a
BearerTokenAuthentication
for the Authentication
and an
OAuth2AuthenticatedPrincipal
for the Authentication.getPrincipal()
.
All details are declarative and do not require the token to be valid.SecurityMockServerConfigurers.OpaqueTokenMutator
to further configure or usepublic static SecurityMockServerConfigurers.OAuth2LoginMutator mockOAuth2Login()
SecurityContext
that has a
OAuth2AuthenticationToken
for the Authentication
. All details are
declarative and do not require the corresponding OAuth 2.0 tokens to be valid.SecurityMockServerConfigurers.OAuth2LoginMutator
to further configure or usepublic static SecurityMockServerConfigurers.OidcLoginMutator mockOidcLogin()
SecurityContext
that has a
OAuth2AuthenticationToken
for the Authentication
. All details are
declarative and do not require the corresponding OAuth 2.0 tokens to be valid.SecurityMockServerConfigurers.OidcLoginMutator
to further configure or usepublic static SecurityMockServerConfigurers.OAuth2ClientMutator mockOAuth2Client()
OAuth2AuthorizedClient
in the
session. All details are declarative and do not require the corresponding OAuth 2.0
tokens to be valid.
The support works by associating the authorized client to the ServerWebExchange via
the WebSessionServerOAuth2AuthorizedClientRepository
SecurityMockServerConfigurers.OAuth2ClientMutator
to further configure or usepublic static SecurityMockServerConfigurers.OAuth2ClientMutator mockOAuth2Client(java.lang.String registrationId)
OAuth2AuthorizedClient
in the
session. All details are declarative and do not require the corresponding OAuth 2.0
tokens to be valid.
The support works by associating the authorized client to the ServerWebExchange via
the WebSessionServerOAuth2AuthorizedClientRepository
registrationId
- The registration id associated with the
OAuth2AuthorizedClient
SecurityMockServerConfigurers.OAuth2ClientMutator
to further configure or usepublic static SecurityMockServerConfigurers.CsrfMutator csrf()