クラス SecurityMockMvcResultMatchers.AuthenticatedMatcher
java.lang.ObjectSE
org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.AuthenticatedMatcher
- 実装されているすべてのインターフェース:
org.springframework.test.web.servlet.ResultMatcher
- 含まれているクラス:
- SecurityMockMvcResultMatchers
特定のユーザーを検証する
MockMvc ResultMatcher は、MvcResult に関連付けられています。- 導入:
- 4.0
メソッドのサマリー
修飾子と型メソッド説明protected SecurityContextload(org.springframework.test.web.servlet.MvcResult result) voidmatch(org.springframework.test.web.servlet.MvcResult result) withAuthentication(ConsumerSE<Authentication> assertAuthentication) 任意のアサーションで認証を検証できますwithAuthentication(Authentication expected) 予想されるAuthenticationを指定しますwithAuthenticationName(StringSE expected) 予想されるPrincipal.getName()を指定しますwithAuthenticationPrincipal(ObjectSE expected) 期待されるプリンシパルを指定しますwithAuthorities(StringSE... authorities) withAuthorities(CollectionSE<? extends GrantedAuthority> expected) 期待されるロールを指定します。期待されるロールを指定します。withSecurityContext(SecurityContext expected) 予想されるSecurityContextを指定しますwithUsername(StringSE expected) 予想されるユーザー名を指定します
メソッドの詳細
match
@NullUnmarked public void match(org.springframework.test.web.servlet.MvcResult result) withAuthentication
public SecurityMockMvcResultMatchers.AuthenticatedMatcher withAuthentication(ConsumerSE<Authentication> assertAuthentication) 任意のアサーションで認証を検証できます- パラメーター:
assertAuthentication- 認証を検証するコンシューマー- 戻り値:
- 追加のアサーションを実行するための AuthenticatedMatcher
withUsername
予想されるユーザー名を指定します- パラメーター:
expected- 予想されるユーザー名- 戻り値:
- さらにカスタマイズするための
SecurityMockMvcResultMatchers.AuthenticatedMatcher
withSecurityContext
public SecurityMockMvcResultMatchers.AuthenticatedMatcher withSecurityContext(SecurityContext expected) 予想されるSecurityContextを指定します- パラメーター:
expected- 予想されるSecurityContext- 戻り値:
- さらにカスタマイズするための
SecurityMockMvcResultMatchers.AuthenticatedMatcher
withAuthentication
public SecurityMockMvcResultMatchers.AuthenticatedMatcher withAuthentication(Authentication expected) 予想されるAuthenticationを指定します- パラメーター:
expected- 予想されるAuthentication- 戻り値:
- さらにカスタマイズするための
SecurityMockMvcResultMatchers.AuthenticatedMatcher
withAuthenticationPrincipal
public SecurityMockMvcResultMatchers.AuthenticatedMatcher withAuthenticationPrincipal(ObjectSE expected) 期待されるプリンシパルを指定します- パラメーター:
expected- 期待される元本- 戻り値:
- さらにカスタマイズするための
SecurityMockMvcResultMatchers.AuthenticatedMatcher
withAuthenticationName
予想されるPrincipal.getName()を指定します- パラメーター:
expected- 予想されるPrincipal.getName()- 戻り値:
- さらにカスタマイズするための
SecurityMockMvcResultMatchers.AuthenticatedMatcher
withAuthorities
- パラメーター:
authorities- authorityNames- 戻り値:
- さらにカスタマイズするための
SecurityMockMvcResultMatchers.AuthenticatedMatcher
withAuthorities
public SecurityMockMvcResultMatchers.AuthenticatedMatcher withAuthorities(CollectionSE<? extends GrantedAuthority> expected) - パラメーター:
expected-Authentication.getAuthorities()- 戻り値:
- さらにカスタマイズするための
SecurityMockMvcResultMatchers.AuthenticatedMatcher
withRoles
期待されるロールを指定します。権限セットにはロール以外にも複数の権限が含まれる可能性があるため、この方法は
withAuthorities(java.lang.String...)とは異なり、ROLE_で始まる権限のみを検証します。その他の権限は無視されます。ロール以外のものを検証したい場合は、
withAuthorities(java.lang.String...)を使用してください。- パラメーター:
roles- ロール。各値には自動的に "ROLE_" というプレフィックスが付きます- 戻り値:
- さらにカスタマイズするための
SecurityMockMvcResultMatchers.AuthenticatedMatcher
withRoles
public SecurityMockMvcResultMatchers.AuthenticatedMatcher withRoles(StringSE rolePrefix, StringSE[] roles) 期待されるロールを指定します。権限セットにはロール以外にも複数の権限が含まれる可能性があるため、この方法は
withAuthorities(java.lang.String...)とは異なり、ROLE_で始まる権限のみを検証します。その他の権限は無視されます。ロール以外のものを検証したい場合は、
withAuthorities(java.lang.String...)を使用してください。- パラメーター:
rolePrefix- ロールのプレフィックスroles- ロール。各値には自動的にrolePrefixという接頭辞が付けられます- 戻り値:
- さらにカスタマイズするための
SecurityMockMvcResultMatchers.AuthenticatedMatcher - 導入:
- 7.0
load