クラス SecurityMockServerConfigurers
java.lang.ObjectSE
org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers
Spring Security および
WebTestClient.Builder.apply(WebTestClientConfigurer) を使用するためのテストユーティリティ。- 導入:
- 5.0
ネストされたクラスの概要
ネストされたクラス修飾子と型クラス説明static final classstatic final class{@link SecurityMockServerConfigurers#mockAuthentication(Authentication)}を使用して WebServerExchange を更新します。static final classstatic final classstatic final classstatic final classstatic final class{@link SecurityMockServerConfigurers#mockUser(UserDetails)}を使用して WebServerExchange を更新します。方法の概要
修飾子と型メソッド説明csrf()static <T extends org.springframework.test.web.reactive.server.WebTestClientConfigurer & org.springframework.test.web.reactive.server.MockServerConfigurer>
TmockAuthentication(Authentication authentication) 提供された認証をプリンシパルとして使用するように ServerWebExchange を更新しますmockJwt()ServerWebExchange を更新して、AuthenticationのJwtAuthenticationTokenとAuthentication.getPrincipal()のJwtを持つSecurityContextを確立します。ServerWebExchange を更新して、セッションでOAuth2AuthorizedClientを確立します。mockOAuth2Client(StringSE registrationId) ServerWebExchange を更新して、セッションでOAuth2AuthorizedClientを確立します。ServerWebExchange を更新して、Authentication用のBearerTokenAuthenticationとAuthentication.getPrincipal()用のOAuth2AuthenticatedPrincipalを持つSecurityContextを確立します。mockUser()UserDetails を使用してプリンシパルとして UsernamePasswordAuthenticationToken を作成するように ServerWebExchange を更新します。UserDetails を使用してプリンシパルとして UsernamePasswordAuthenticationToken を作成するように ServerWebExchange を更新します。static <T extends org.springframework.test.web.reactive.server.WebTestClientConfigurer & org.springframework.test.web.reactive.server.MockServerConfigurer>
TmockUser(UserDetails userDetails) 提供された UserDetails を使用してプリンシパルとして UsernamePasswordAuthenticationToken を作成するように ServerWebExchange を更新しますstatic org.springframework.test.web.reactive.server.MockServerConfigurerSpring Security のWebTestClientテストサポートをセットアップする
方法の詳細
springSecurity
public static org.springframework.test.web.reactive.server.MockServerConfigurer springSecurity()Spring Security のWebTestClientテストサポートをセットアップする- 戻り値:
- 使用する MockServerConfigurer
mockAuthentication
public static <T extends org.springframework.test.web.reactive.server.WebTestClientConfigurer & org.springframework.test.web.reactive.server.MockServerConfigurer> T mockAuthentication(Authentication authentication) 提供された認証をプリンシパルとして使用するように ServerWebExchange を更新します- パラメーター:
authentication- 使用する認証。- 戻り値:
- 使用する設定プログラム
mockUser
public static <T extends org.springframework.test.web.reactive.server.WebTestClientConfigurer & org.springframework.test.web.reactive.server.MockServerConfigurer> T mockUser(UserDetails userDetails) 提供された UserDetails を使用してプリンシパルとして UsernamePasswordAuthenticationToken を作成するように ServerWebExchange を更新します- パラメーター:
userDetails- 使用する UserDetails。- 戻り値:
- 使用する設定プログラム
mockUser
UserDetails を使用してプリンシパルとして UsernamePasswordAuthenticationToken を作成するように ServerWebExchange を更新します。これは、"user" のデフォルトのユーザー名、"password" のパスワード、"ROLE_USER" の付与された権限を使用します。mockUser
UserDetails を使用してプリンシパルとして UsernamePasswordAuthenticationToken を作成するように ServerWebExchange を更新します。これは、"password" のデフォルトパスワードを使用し、"ROLE_USER" の権限を付与します。- 戻り値:
- 使用する
WebTestClientConfigurer
mockJwt
ServerWebExchange を更新して、AuthenticationのJwtAuthenticationTokenとAuthentication.getPrincipal()のJwtを持つSecurityContextを確立します。詳細はすべて宣言型であり、JWT が有効である必要はありません。- 戻り値:
SecurityMockServerConfigurers.JwtMutatorをさらに構成または使用する- 導入:
- 5.2
mockOpaqueToken
ServerWebExchange を更新して、Authentication用のBearerTokenAuthenticationとAuthentication.getPrincipal()用のOAuth2AuthenticatedPrincipalを持つSecurityContextを確立します。すべての詳細は宣言型であり、トークンが有効である必要はありません。- 戻り値:
SecurityMockServerConfigurers.OpaqueTokenMutatorをさらに構成または使用する- 導入:
- 5.3
mockOAuth2Login
ServerWebExchange を更新して、Authentication用のOAuth2AuthenticationTokenを持つSecurityContextを確立します。すべての詳細は宣言型であり、対応する OAuth 2.0 トークンが有効である必要はありません。- 戻り値:
SecurityMockServerConfigurers.OAuth2LoginMutatorをさらに構成または使用する- 導入:
- 5.3
mockOidcLogin
ServerWebExchange を更新して、Authentication用のOAuth2AuthenticationTokenを持つSecurityContextを確立します。すべての詳細は宣言型であり、対応する OAuth 2.0 トークンが有効である必要はありません。- 戻り値:
SecurityMockServerConfigurers.OidcLoginMutatorをさらに構成または使用する- 導入:
- 5.3
mockOAuth2Client
ServerWebExchange を更新して、セッションでOAuth2AuthorizedClientを確立します。すべての詳細は宣言型であり、対応する OAuth 2.0 トークンが有効である必要はありません。サポートは、
ServerOAuth2AuthorizedClientRepositoryを使用して承認されたクライアントを ServerWebExchange に関連付けることによって機能します。- 戻り値:
SecurityMockServerConfigurers.OAuth2ClientMutatorをさらに構成または使用する- 導入:
- 5.3
mockOAuth2Client
public static SecurityMockServerConfigurers.OAuth2ClientMutator mockOAuth2Client(StringSE registrationId) ServerWebExchange を更新して、セッションでOAuth2AuthorizedClientを確立します。すべての詳細は宣言型であり、対応する OAuth 2.0 トークンが有効である必要はありません。サポートは、
ServerOAuth2AuthorizedClientRepositoryを使用して承認されたクライアントを ServerWebExchange に関連付けることによって機能します。- パラメーター:
registrationId-OAuth2AuthorizedClientに関連付けられている登録 ID- 戻り値:
SecurityMockServerConfigurers.OAuth2ClientMutatorをさらに構成または使用する- 導入:
- 5.3
csrf