use of org.gluu.oxauth.model.registration.Client in project oxAuth by GluuFederation.
the class CleanerTimerTest method client_whichIsExpiredAndDeletable_MustBeRemoved.
// disabled temporarily. It works perfectly locally but fails on jenkins. Reason is unclear.
@Test(enabled = false)
public void client_whichIsExpiredAndDeletable_MustBeRemoved() throws StringEncrypter.EncryptionException {
// 1. create client
final Client client = createClient(true);
final Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
client.setClientIdIssuedAt(calendar.getTime());
calendar.add(Calendar.MONTH, -1);
client.setExpirationDate(calendar.getTime());
clientService.persist(client);
// 2. client is in persistence
assertNotNull(clientService.getClient(client.getClientId()));
// 3. clean up
cleanerTimer.processImpl();
cacheService.clear();
// 4. no client in persistence
assertNull(clientService.getClient(client.getClientId()));
}
use of org.gluu.oxauth.model.registration.Client in project oxAuth by GluuFederation.
the class CleanerTimerTest method u2fDevice_whichIsExpiredAndDeletable_MustBeRemoved.
@Test
public void u2fDevice_whichIsExpiredAndDeletable_MustBeRemoved() throws StringEncrypter.EncryptionException {
final Client client = createClient();
clientService.persist(client);
// 1. create device
String userInum = "";
String appId = "https://testapp.com";
final DeviceRegistration device = new DeviceRegistration();
device.setStatus(DeviceRegistrationStatus.ACTIVE);
device.setApplication(appId);
device.setId(String.valueOf(System.currentTimeMillis()));
device.setDn(deviceRegistrationService.getDnForU2fDevice(userInum, device.getId()));
deviceRegistrationService.addOneStepDeviceRegistration(device);
// 2. device exists
assertNotNull(deviceRegistrationService.findUserDeviceRegistration(userInum, device.getId()));
// 3. clean up
cleanerTimer.processImpl();
cacheService.clear();
// 4. device exists
assertNotNull(deviceRegistrationService.findUserDeviceRegistration(userInum, device.getId()));
final Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, -10);
device.setExpirationDate(calendar.getTime());
deviceRegistrationService.merge(device);
// 5. clean up
cleanerTimer.processImpl();
cacheService.clear();
// 6. no device in persistence
try {
deviceRegistrationService.findUserDeviceRegistration(userInum, device.getId());
throw new AssertionError("No exception, expected EntryPersistenceException on find.");
} catch (EntryPersistenceException e) {
// ignore
}
}
use of org.gluu.oxauth.model.registration.Client in project oxAuth by GluuFederation.
the class CleanerTimerTest method u2fRequest_whichIsExpiredAndDeletable_MustBeRemoved.
@Test
public void u2fRequest_whichIsExpiredAndDeletable_MustBeRemoved() throws StringEncrypter.EncryptionException {
final Client client = createClient();
clientService.persist(client);
// 1. create token
String userInum = "";
String appId = "https://testapp.com";
final RequestMessageLdap request = u2fRegistrationService.storeRegisterRequestMessage(u2fRegistrationService.builRegisterRequestMessage(appId, userInum), userInum, userInum);
// 2. request exists
assertNotNull(u2fRegistrationService.getRegisterRequestMessage(request.getId()));
// 3. clean up
cleanerTimer.processImpl();
cacheService.clear();
// 4. request exists
assertNotNull(u2fRegistrationService.getRegisterRequestMessage(request.getId()));
final Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, -10);
request.setExpirationDate(calendar.getTime());
u2fRegistrationService.merge(request);
// 5. clean up
cleanerTimer.processImpl();
cacheService.clear();
// 6. no request in persistence
try {
u2fRegistrationService.getRegisterRequestMessage(request.getId());
throw new AssertionError("No exception, expected EntryPersistenceException on find request.");
} catch (EntryPersistenceException e) {
// ignore
}
}
use of org.gluu.oxauth.model.registration.Client in project oxAuth by GluuFederation.
the class CleanerTimerTest method umaPermission_whichIsExpiredAndDeletable_MustBeRemoved.
@Test
public void umaPermission_whichIsExpiredAndDeletable_MustBeRemoved() throws StringEncrypter.EncryptionException {
final Client client = createClient();
clientService.persist(client);
final String ticket = UUID.randomUUID().toString();
// 1. create permission
UmaPermission permission = new UmaPermission();
permission.setTicket(ticket);
permission.setConfigurationCode(UUID.randomUUID().toString());
permission.setResourceId(UUID.randomUUID().toString());
umaPermissionService.addPermission(permission, client.getDn());
// 2. permission exists
assertNotNull(umaPermissionService.getPermissionsByTicket(ticket).get(0));
// 3. clean up
cleanerTimer.processImpl();
cacheService.clear();
// 4. permission exists
assertNotNull(umaPermissionService.getPermissionsByTicket(ticket).get(0));
final Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, -10);
permission.setExpirationDate(calendar.getTime());
umaPermissionService.merge(permission);
// 5. clean up
cleanerTimer.processImpl();
cacheService.clear();
// 6. no permission in persistence
final List<UmaPermission> permissionsByTicket = umaPermissionService.getPermissionsByTicket(ticket);
assertTrue(permissionsByTicket.isEmpty());
}
use of org.gluu.oxauth.model.registration.Client in project oxAuth by GluuFederation.
the class CleanerTimerTest method client_whichIsExpiredAndNotDeletable_MustNotBeRemoved.
@Test
public void client_whichIsExpiredAndNotDeletable_MustNotBeRemoved() throws StringEncrypter.EncryptionException {
// 1. create client
final Client client = createClient(false);
try {
final Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
client.setClientIdIssuedAt(calendar.getTime());
calendar.add(Calendar.HOUR, -1);
client.setExpirationDate(calendar.getTime());
clientService.persist(client);
// 2. client is in persistence
assertNotNull(clientService.getClient(client.getClientId()));
// 3. clean up
cleanerTimer.processImpl();
cacheService.clear();
// 4. client is in persistence (not removed)
assertNotNull(clientService.getClient(client.getClientId()));
} finally {
// make it available for cleaner
client.setDeletable(true);
clientService.merge(client);
}
}
Aggregations