クラス 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 SecurityContext
load
(org.springframework.test.web.servlet.MvcResult result) void
match
(org.springframework.test.web.servlet.MvcResult result) withAuthentication
(ConsumerSE<Authentication> assertAuthentication) 任意のアサーションで認証を検証できますwithAuthentication
(Authentication expected) 予想されるAuthentication
を指定しますwithAuthenticationName
(StringSE expected) 予想されるPrincipal.getName()
を指定しますwithAuthenticationPrincipal
(ObjectSE expected) 期待されるプリンシパルを指定しますwithAuthorities
(CollectionSE<? extends GrantedAuthority> expected) withSecurityContext
(SecurityContext expected) 予想されるSecurityContext
を指定しますwithUsername
(StringSE expected) 予想されるユーザー名を指定します
メソッドの詳細
match
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
public SecurityMockMvcResultMatchers.AuthenticatedMatcher withAuthorities(CollectionSE<? extends GrantedAuthority> expected) - パラメーター:
expected
-Authentication.getAuthorities()
- 戻り値:
- さらにカスタマイズするための
SecurityMockMvcResultMatchers.AuthenticatedMatcher
withRoles
- パラメーター:
roles
- ロール。各値には自動的に "ROLE_" というプレフィックスが付きます- 戻り値:
- さらにカスタマイズするための
SecurityMockMvcResultMatchers.AuthenticatedMatcher
load