クラス SecurityMockServerConfigurers
java.lang.ObjectSE
org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers
Spring Security および
WebTestClient.Builder.apply(WebTestClientConfigurer)
を使用するためのテストユーティリティ。- 導入:
- 5.0
ネストされたクラスのサマリー
ネストされたクラス修飾子と型クラス説明static final class
static final class
{@link SecurityMockServerConfigurers#mockAuthentication(Authentication)}
を使用して WebServerExchange を更新します。static final class
static final class
static final class
static final class
static 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.MockServerConfigurer
Spring 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