use of eu.bcvsolutions.idm.core.api.dto.IdmTokenDto in project CzechIdMng by bcvsolutions.
the class PermissionsAuthorityChangeProcessorTest method testChangePersmissions.
/**
* Change permissions type for given policy.
* @throws Exception
*/
@Test
public void testChangePersmissions() throws Exception {
IdmRoleDto role = getTestRole();
IdmIdentityDto i = getHelper().createIdentity();
IdmIdentityContractDto c = getTestContract(i);
getTestIdentityRole(role, c);
//
IdmTokenFilter filter = new IdmTokenFilter();
filter.setOwnerType(tokenManager.getOwnerType(i.getClass()));
filter.setOwnerId(i.getId());
List<IdmTokenDto> tokens = tokenManager.getTokens(i);
//
Assert.assertTrue(tokens.isEmpty());
//
// login - one token
getHelper().login(i.getUsername(), i.getPassword());
try {
tokens = tokenManager.getTokens(i);
Assert.assertEquals(1, tokens.size());
Assert.assertFalse(tokens.get(0).isDisabled());
//
changeAuthorizationPolicyPermissions(role);
//
tokens = tokenManager.getTokens(i);
Assert.assertEquals(1, tokens.size());
Assert.assertTrue(tokens.get(0).isDisabled());
} finally {
getHelper().logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTokenDto in project CzechIdMng by bcvsolutions.
the class IdmTokenControllerRestTest method testFindByExpirationTill.
@Test
public void testFindByExpirationTill() {
UUID mockOwnerId = UUID.randomUUID();
ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
//
IdmTokenDto tokenOne = prepareDto();
tokenOne.setOwnerId(mockOwnerId);
tokenOne.setExpiration(now);
tokenOne = createDto(tokenOne);
IdmTokenDto tokenTwo = prepareDto();
tokenTwo.setOwnerId(mockOwnerId);
tokenTwo.setExpiration(now.plusDays(2));
tokenTwo = createDto(tokenTwo);
//
IdmTokenFilter filter = new IdmTokenFilter();
filter.setOwnerId(mockOwnerId);
filter.setExpirationTill(now);
List<IdmTokenDto> results = find(filter);
//
Assert.assertEquals(1, results.size());
Assert.assertEquals(tokenOne, results.get(0));
//
filter.setExpirationTill(now.plusDays(1));
results = find(filter);
//
Assert.assertEquals(1, results.size());
Assert.assertEquals(tokenOne, results.get(0));
//
filter.setExpirationTill(now.plusDays(2));
results = find(filter);
//
Assert.assertEquals(2, results.size());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTokenDto in project CzechIdMng by bcvsolutions.
the class IdmTokenControllerRestTest method testFindByOwner.
@Test
public void testFindByOwner() {
IdmIdentityDto owner = getHelper().createIdentity();
IdmTokenDto tokenOne = prepareDto();
tokenOne.setOwnerId(owner.getId());
String ownerType = tokenManager.getOwnerType(owner);
tokenOne.setOwnerType(ownerType);
tokenOne = createDto(tokenOne);
// other
createDto();
// other
createDto();
IdmTokenFilter filter = new IdmTokenFilter();
filter.setOwnerType(ownerType);
filter.setOwnerId(owner.getId());
List<IdmTokenDto> results = find(filter);
//
Assert.assertEquals(1, results.size());
Assert.assertEquals(tokenOne, results.get(0));
}
Aggregations