use of org.springframework.security.oauth2.provider.ClientRegistrationException in project spring-security-oauth by spring-projects.
the class AbstractDefaultTokenServicesTests method testClientInvalidated.
@Test(expected = InvalidTokenException.class)
public void testClientInvalidated() throws Exception {
final AtomicBoolean deleted = new AtomicBoolean();
getTokenServices().setClientDetailsService(new ClientDetailsService() {
public ClientDetails loadClientByClientId(String clientId) throws OAuth2Exception {
if (deleted.get()) {
throw new ClientRegistrationException("No such client: " + clientId);
}
BaseClientDetails client = new BaseClientDetails();
client.setRefreshTokenValiditySeconds(100);
client.setAuthorizedGrantTypes(Arrays.asList("authorization_code", "refresh_token"));
return client;
}
});
OAuth2AccessToken token = getTokenServices().createAccessToken(createAuthentication());
deleted.set(true);
OAuth2Authentication authentication = getTokenServices().loadAuthentication(token.getValue());
assertNotNull(authentication.getOAuth2Request());
}
Aggregations