use of io.jans.as.server.model.common.ExecutionContext in project jans by JanssenProject.
the class CleanerTimerTest method token_whichIsExpiredAndDeletable_MustBeRemoved.
@Test
public void token_whichIsExpiredAndDeletable_MustBeRemoved() throws StringEncrypter.EncryptionException {
final Client client = createClient();
clientService.persist(client);
// 1. create token
final ClientCredentialsGrant grant = authorizationGrantList.createClientCredentialsGrant(new User(), client);
final AccessToken accessToken = grant.createAccessToken(new ExecutionContext(null, null));
// 2. token exists
assertNotNull(grantService.getGrantByCode(accessToken.getCode()));
// 3. clean up
cleanerTimer.processImpl();
cacheService.clear();
// 4. token exists
final TokenEntity grantLdap = grantService.getGrantByCode(accessToken.getCode());
assertNotNull(grantLdap);
final Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, -10);
grantLdap.setExpirationDate(calendar.getTime());
grantService.merge(grantLdap);
// 5. clean up
cleanerTimer.processImpl();
cacheService.clear();
// 6. no token in persistence
assertNull(grantService.getGrantByCode(accessToken.getCode()));
}
Aggregations