use of eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange in project CzechIdMng by bcvsolutions.
the class IdentityRoleAddAuthoritiesProcessorTest method testAddRoleWithoutAuthorities.
@Test
public void testAddRoleWithoutAuthorities() throws Exception {
IdmRoleDto role = getTestRole();
IdmIdentityDto i = getTestUser();
IdmIdentityContractDto c = getTestContract(i);
IdmAuthorityChange ac = getAuthorityChange(i);
// user has no authorities - change flag is null
Assert.assertNull(ac);
// authority added
getTestIdentityRole(role, c);
i = identityService.get(i.getId());
ac = getAuthorityChange(i);
//
DateTime firstChangeTs = ac.getAuthChangeTimestamp();
Assert.assertNotNull(firstChangeTs);
// prepare role without authorities
IdmRoleDto r = new IdmRoleDto();
r.setName(UUID.randomUUID().toString());
r = saveInTransaction(r, roleService);
Thread.sleep(10);
getTestIdentityRole(r, c);
i = identityService.get(i.getId());
ac = getAuthorityChange(i);
Assert.assertEquals(firstChangeTs, ac.getAuthChangeTimestamp());
}
use of eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange in project CzechIdMng by bcvsolutions.
the class IdentityRoleAddAuthoritiesProcessorTest method testAddRoleWithSuperAuthorities.
@Test
public void testAddRoleWithSuperAuthorities() throws Exception {
// prepare role with full authorities (APP_ADMIN)
IdmRoleDto r = new IdmRoleDto();
r.setName(UUID.randomUUID().toString());
r = saveInTransaction(r, roleService);
getTestPolicy(r, IdmBasePermission.ADMIN, IdmGroupPermission.APP);
//
IdmIdentityDto i = getTestUser();
IdmIdentityContractDto c = getTestContract(i);
IdmAuthorityChange ac = getAuthorityChange(i);
Assert.assertNull(ac);
// authority added
getTestIdentityRole(r, c);
i = identityService.get(i.getId());
ac = getAuthorityChange(i);
//
DateTime firstChangeTs = ac.getAuthChangeTimestamp();
Assert.assertNotNull(firstChangeTs);
// role adds IDENTITY_DELETE - must pass without auth change
IdmRoleDto role = getTestRole();
Thread.sleep(10);
getTestIdentityRole(role, c);
i = identityService.get(i.getId());
ac = getAuthorityChange(i);
Assert.assertEquals(firstChangeTs, ac.getAuthChangeTimestamp());
}
use of eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange in project CzechIdMng by bcvsolutions.
the class IdentityRoleDeleteAuthoritiesProcessorTest method removeModifiedTimestamp.
private void removeModifiedTimestamp(IdmIdentityDto i) {
// addition of roles also modifies authorities -> set to null for the sake of testing
IdmAuthorityChange ac = getAuthorityChange(i);
Assert.assertNotNull(ac);
acRepository.delete(ac);
}
use of eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange in project CzechIdMng by bcvsolutions.
the class PermissionsAuthorityChangeProcessorTest method testCreateAuthorityChangeEntity.
/**
* In case the identity in role does not have IdmAuthorityChange entity
* relation, changing role's authorities must create one.
* @throws Exception
*/
@Test
public void testCreateAuthorityChangeEntity() throws Exception {
IdmRoleDto role = getTestRole();
IdmIdentityDto i = getTestUser();
IdmIdentityContractDto c = getTestContract(i);
getTestIdentityRole(role, c);
deleteAuthorityChangedEntity(i);
IdmAuthorityChange ac = acRepository.findOneByIdentity_Id(i.getId());
Assert.assertNull(ac);
sleep();
clearAuthPolicies(role);
ac = acRepository.findOneByIdentity_Id(i.getId());
Assert.assertNotNull(ac);
Assert.assertNotNull(ac.getAuthChangeTimestamp());
}
use of eu.bcvsolutions.idm.core.model.entity.IdmAuthorityChange in project CzechIdMng by bcvsolutions.
the class IdentityRoleAddAuthoritiesProcessorTest method testAddRoleDoNotModifyAuthorities.
@Test
public void testAddRoleDoNotModifyAuthorities() throws Exception {
IdmRoleDto role = getTestRole();
IdmRoleDto role2 = getTestRole();
IdmIdentityDto i = getTestUser();
IdmIdentityContractDto c = getTestContract(i);
IdmAuthorityChange ac = getAuthorityChange(i);
// user has no authorities - change flag is null
Assert.assertNull(ac);
// authority added
getTestIdentityRole(role, c);
i = identityService.get(i.getId());
ac = getAuthorityChange(i);
DateTime firstChangeTs = ac.getAuthChangeTimestamp();
Assert.assertNotNull(firstChangeTs);
Thread.sleep(10);
getTestIdentityRole(role2, c);
i = identityService.get(i.getId());
ac = getAuthorityChange(i);
Assert.assertEquals(firstChangeTs, ac.getAuthChangeTimestamp());
}
Aggregations