use of eu.bcvsolutions.idm.acc.dto.SysSystemDto in project CzechIdMng by bcvsolutions.
the class AccountProtectionSystemTest method accountWithProtectionAndIntervalTest.
@Test
public void accountWithProtectionAndIntervalTest() {
IdmIdentityDto identity = helper.createIdentity();
SysSystemDto system = initSystem();
IdmRoleDto roleOne = roleService.getByCode(ROLE_ONE);
int intervalInDays = 10;
// Set system to protected mode
SysSystemMappingDto mapping = systemMappingService.findBySystem(system, SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
mapping.setProtectionEnabled(Boolean.TRUE);
mapping.setProtectionInterval(intervalInDays);
mapping = systemMappingService.save(mapping);
IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, roleOne);
AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNotNull(account);
Assert.assertFalse(account.isInProtection());
TestResource createdAccount = helper.findResource(account.getUid());
Assert.assertNotNull(createdAccount);
Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
// Remove role from identity
identityRoleService.deleteById(identityRole.getId());
account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNotNull(account);
Assert.assertTrue(account.isInProtection());
Assert.assertNotNull(account.getEndOfProtection());
Assert.assertTrue(account.getEndOfProtection().toLocalDate().isEqual(LocalDate.now().plusDays(intervalInDays)));
createdAccount = helper.findResource(account.getUid());
Assert.assertNotNull(createdAccount);
Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemDto in project CzechIdMng by bcvsolutions.
the class AccountProtectionSystemTest method accountWithProtectionTest.
@Test
public void accountWithProtectionTest() {
IdmIdentityDto identity = helper.createIdentity();
SysSystemDto system = initSystem();
IdmRoleDto roleOne = roleService.getByCode(ROLE_ONE);
// Set system to protected mode
SysSystemMappingDto mapping = systemMappingService.findBySystem(system, SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
mapping.setProtectionEnabled(Boolean.TRUE);
mapping.setProtectionInterval(null);
systemMappingService.save(mapping);
IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, roleOne);
AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNotNull(account);
Assert.assertFalse(account.isInProtection());
TestResource createdAccount = helper.findResource(account.getUid());
Assert.assertNotNull(createdAccount);
Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
// Remove role from identity
identityRoleService.deleteById(identityRole.getId());
account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNotNull(account);
Assert.assertTrue(account.isInProtection());
Assert.assertNull(account.getEndOfProtection());
createdAccount = helper.findResource(account.getUid());
Assert.assertNotNull(createdAccount);
Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemDto in project CzechIdMng by bcvsolutions.
the class AccountProtectionSystemTest method deleteAccountOnProtectionSystemTest.
@Test
public void deleteAccountOnProtectionSystemTest() {
IdmIdentityDto identity = helper.createIdentity();
SysSystemDto system = initSystem();
IdmRoleDto roleOne = roleService.getByCode(ROLE_ONE);
// Set system to protected mode
SysSystemMappingDto mapping = systemMappingService.findBySystem(system, SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
mapping.setProtectionEnabled(Boolean.TRUE);
mapping.setProtectionInterval(null);
systemMappingService.save(mapping);
// Assign the role
helper.createIdentityRole(identity, roleOne);
AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
AccIdentityAccountFilter identityAccountFilter = new AccIdentityAccountFilter();
identityAccountFilter.setAccountId(account.getId());
List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(identityAccountFilter, null).getContent();
// Identity account have relation on the role
Assert.assertEquals(1, identityAccounts.size());
Assert.assertNotNull(identityAccounts.get(0).getIdentityRole());
Assert.assertNotNull(account);
Assert.assertFalse(account.isInProtection());
TestResource createdAccount = helper.findResource(account.getUid());
Assert.assertNotNull(createdAccount);
Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
// Remove account directly. Account must be transformed to the protection state.
accountService.delete(account);
account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNotNull(account);
Assert.assertTrue(account.isInProtection());
Assert.assertNull(account.getEndOfProtection());
createdAccount = helper.findResource(account.getUid());
Assert.assertNotNull(createdAccount);
Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
// Identity account have not relation on the role now.
identityAccounts = identityAccountService.find(identityAccountFilter, null).getContent();
Assert.assertEquals(1, identityAccounts.size());
Assert.assertNull(identityAccounts.get(0).getIdentityRole());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemDto in project CzechIdMng by bcvsolutions.
the class AccountProtectionSystemTest method initSystem.
private SysSystemDto initSystem() {
// create test system
SysSystemDto system = helper.createTestResourceSystem(true);
// Create role with link on system (default)
IdmRoleDto role = helper.createRole();
ROLE_ONE = role.getCode();
// assign role to system
helper.createRoleSystem(role, system);
//
return system;
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemDto in project CzechIdMng by bcvsolutions.
the class CoreReferentialIntegrityIntegrationTest method testRoleReferentialIntegrity.
@Test
public void testRoleReferentialIntegrity() {
IdmRoleDto role = helper.createRole();
// role systems
SysSystemDto system = new SysSystemDto();
system.setName("system_" + System.currentTimeMillis());
system = systemService.save(system);
// schema
SysSchemaObjectClassDto objectClass = new SysSchemaObjectClassDto();
objectClass.setSystem(system.getId());
objectClass.setObjectClassName("__ACCOUNT__");
objectClass = schemaObjectClassService.save(objectClass);
SysSystemMappingDto systemMapping = new SysSystemMappingDto();
systemMapping.setName("default_" + System.currentTimeMillis());
systemMapping.setObjectClass(objectClass.getId());
systemMapping.setOperationType(SystemOperationType.PROVISIONING);
systemMapping.setEntityType(SystemEntityType.IDENTITY);
systemMapping = systemEntityHandlingService.save(systemMapping);
SysRoleSystemDto roleSystem = new SysRoleSystemDto();
roleSystem.setSystem(system.getId());
roleSystem.setRole(role.getId());
roleSystem.setSystemMapping(systemMapping.getId());
roleSystemService.save(roleSystem);
SysRoleSystemFilter filter = new SysRoleSystemFilter();
filter.setRoleId(role.getId());
assertNotNull(roleService.getByCode(role.getName()));
assertEquals(1, roleSystemService.find(filter, null).getTotalElements());
roleService.delete(role);
assertNull(roleService.getByCode(role.getName()));
assertEquals(0, roleSystemService.find(filter, null).getTotalElements());
}
Aggregations