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