@Test
public void shouldSaveAccessToken() {
//Given
final OAuth2ProtectedResourceDetails oAuth2ProtectedResourceDetails = oAuth2ProtectedResourceDetailsBuilder().build();
final TestingAuthenticationToken authentication = new TestingAuthenticationToken(userBuilder().build(), string().next());
final OAuth2AccessToken oAuth2AccessToken = oAuth2AccessTokenBuilder().build();
//And
final String authenticationId = string().next();
given(keyGenerator.extractKey(oAuth2ProtectedResourceDetails, authentication)).willReturn(authenticationId);
//When
mongoClientTokenServices.saveAccessToken(oAuth2ProtectedResourceDetails, authentication, oAuth2AccessToken);
//Then
verify(keyGenerator, atLeastOnce()).extractKey(oAuth2ProtectedResourceDetails, authentication);
verify(mongoOAuth2ClientTokenRepository).save(any(MongoOAuth2ClientToken.class));
verify(mongoOAuth2ClientTokenRepository).deleteByAuthenticationId(authenticationId);
}
MongoClientTokenServicesTest.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:spring-security-mongo
作者:
评论列表
文章目录