use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class AdGroupConnectorTypeTest method testReuseNewCatalog.
@Test
public void testReuseNewCatalog() {
ConnectorType connectorType = connectorManager.getConnectorType(MockAdGroupConnectorType.NAME);
ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
SysSystemDto systemDto = createSystem(this.getHelper().createName(), connectorTypeDto);
connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
// Create system with members.
SysSystemDto memberSystemDto = createMemberSystem();
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setSystemId(memberSystemDto.getId());
mappingFilter.setOperationType(SystemOperationType.PROVISIONING);
mappingFilter.setEntityType(SystemEntityType.IDENTITY);
SysSystemMappingDto mappingDto = mappingService.find(mappingFilter, null).getContent().stream().findFirst().orElse(null);
assertNotNull(mappingDto);
StringBuilder sb = new StringBuilder();
sb.append(this.getHelper().createName());
sb.append(AdGroupConnectorType.LINE_SEPARATOR);
sb.append(this.getHelper().createName());
String groupContainersMock = sb.toString();
connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.GROUP_CONTAINER_KEY, groupContainersMock);
connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.MEMBER_SYSTEM_MAPPING, mappingDto.getId().toString());
connectorTypeDto.setWizardStepName(MockAdGroupConnectorType.STEP_FOUR);
// Generate mock schema.
generateMockSchema(systemDto);
IdmRoleCatalogueDto mainCatalog = getHelper().createRoleCatalogue(getHelper().createName());
// Enable wizard switches.
connectorTypeDto.getMetadata().put(SysSyncRoleConfig_.membershipSwitch.getName(), Boolean.TRUE.toString());
connectorTypeDto.getMetadata().put(SysSyncRoleConfig_.assignCatalogueSwitch.getName(), Boolean.TRUE.toString());
connectorTypeDto.getMetadata().put(SysSyncRoleConfig_.assignRoleSwitch.getName(), Boolean.TRUE.toString());
connectorTypeDto.getMetadata().put(SysSyncRoleConfig_.assignRoleRemoveSwitch.getName(), Boolean.TRUE.toString());
connectorTypeDto.getMetadata().put(SysSyncRoleConfig_.removeCatalogueRoleSwitch.getName(), Boolean.TRUE.toString());
connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.NEW_ROLE_CATALOG, mainCatalog.getCode());
// Execute step four.
connectorManager.execute(connectorTypeDto);
SysSyncConfigFilter syncConfigFilter = new SysSyncConfigFilter();
syncConfigFilter.setSystemId(systemDto.getId());
AbstractSysSyncConfigDto syncConfigDto = syncConfigService.find(syncConfigFilter, null).getContent().stream().findFirst().orElse(null);
assertTrue(syncConfigDto instanceof SysSyncRoleConfigDto);
SysSyncRoleConfigDto syncRoleConfigDto = (SysSyncRoleConfigDto) syncConfigDto;
assertTrue(syncRoleConfigDto.isRemoveCatalogueRoleSwitch());
assertTrue(syncRoleConfigDto.isAssignCatalogueSwitch());
UUID mainCatalogueRoleNode = syncRoleConfigDto.getMainCatalogueRoleNode();
assertEquals(mainCatalog.getId(), mainCatalogueRoleNode);
UUID removeCatalogueRoleParentNode = syncRoleConfigDto.getRemoveCatalogueRoleParentNode();
assertEquals(mainCatalog.getId(), removeCatalogueRoleParentNode);
// Clean
systemService.delete(systemDto);
systemService.delete(memberSystemDto);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class AdGroupConnectorTypeTest method testStepOneBySystemWithWrongConnector.
@Test(expected = ResultCodeException.class)
public void testStepOneBySystemWithWrongConnector() {
// Create system with table connector -> should cause an exception!
SysSystemDto tableSystem = helper.createTestResourceSystem(true);
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setSystemId(tableSystem.getId());
mappingFilter.setOperationType(SystemOperationType.PROVISIONING);
mappingFilter.setEntityType(SystemEntityType.IDENTITY);
SysSystemMappingDto mappingDto = mappingService.find(mappingFilter, null).getContent().stream().findFirst().orElse(null);
assertNotNull(mappingDto);
ConnectorType connectorType = connectorManager.getConnectorType(MockAdGroupConnectorType.NAME);
ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
connectorTypeDto.setReopened(false);
connectorManager.load(connectorTypeDto);
assertNotNull(connectorTypeDto);
connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.SYSTEM_NAME, this.getHelper().createName());
connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.MEMBER_SYSTEM_MAPPING, mappingDto.getId().toString());
connectorTypeDto.setWizardStepName(MockAdGroupConnectorType.STEP_ONE);
// Execute the first step.
try {
connectorManager.execute(connectorTypeDto);
} finally {
// Clean
systemService.delete(tableSystem);
}
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class AdGroupConnectorTypeTest method testCreateNewCatalog.
@Test
public void testCreateNewCatalog() {
ConnectorType connectorType = connectorManager.getConnectorType(MockAdGroupConnectorType.NAME);
ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
SysSystemDto systemDto = createSystem(this.getHelper().createName(), connectorTypeDto);
connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
// Create system with members.
SysSystemDto memberSystemDto = createMemberSystem();
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setSystemId(memberSystemDto.getId());
mappingFilter.setOperationType(SystemOperationType.PROVISIONING);
mappingFilter.setEntityType(SystemEntityType.IDENTITY);
SysSystemMappingDto mappingDto = mappingService.find(mappingFilter, null).getContent().stream().findFirst().orElse(null);
assertNotNull(mappingDto);
StringBuilder sb = new StringBuilder();
sb.append(this.getHelper().createName());
sb.append(AdGroupConnectorType.LINE_SEPARATOR);
sb.append(this.getHelper().createName());
String groupContainersMock = sb.toString();
connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.GROUP_CONTAINER_KEY, groupContainersMock);
connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.MEMBER_SYSTEM_MAPPING, mappingDto.getId().toString());
connectorTypeDto.setWizardStepName(MockAdGroupConnectorType.STEP_FOUR);
// Generate mock schema.
generateMockSchema(systemDto);
String mainCatalog = getHelper().createName();
// Enable wizard switches.
connectorTypeDto.getMetadata().put(SysSyncRoleConfig_.membershipSwitch.getName(), Boolean.TRUE.toString());
connectorTypeDto.getMetadata().put(SysSyncRoleConfig_.assignCatalogueSwitch.getName(), Boolean.TRUE.toString());
connectorTypeDto.getMetadata().put(SysSyncRoleConfig_.assignRoleSwitch.getName(), Boolean.TRUE.toString());
connectorTypeDto.getMetadata().put(SysSyncRoleConfig_.assignRoleRemoveSwitch.getName(), Boolean.TRUE.toString());
connectorTypeDto.getMetadata().put(SysSyncRoleConfig_.removeCatalogueRoleSwitch.getName(), Boolean.TRUE.toString());
connectorTypeDto.getMetadata().put(MockAdGroupConnectorType.NEW_ROLE_CATALOG, mainCatalog);
// Execute step four.
connectorManager.execute(connectorTypeDto);
SysSyncConfigFilter syncConfigFilter = new SysSyncConfigFilter();
syncConfigFilter.setSystemId(systemDto.getId());
AbstractSysSyncConfigDto syncConfigDto = syncConfigService.find(syncConfigFilter, null).getContent().stream().findFirst().orElse(null);
assertTrue(syncConfigDto instanceof SysSyncRoleConfigDto);
SysSyncRoleConfigDto syncRoleConfigDto = (SysSyncRoleConfigDto) syncConfigDto;
assertTrue(syncRoleConfigDto.isRemoveCatalogueRoleSwitch());
assertTrue(syncRoleConfigDto.isAssignCatalogueSwitch());
IdmRoleCatalogueDto roleCatalogueDto = roleCatalogueService.getByCode(mainCatalog);
assertNotNull(roleCatalogueDto);
UUID mainCatalogueRoleNode = syncRoleConfigDto.getMainCatalogueRoleNode();
assertEquals(roleCatalogueDto.getId(), mainCatalogueRoleNode);
UUID removeCatalogueRoleParentNode = syncRoleConfigDto.getRemoveCatalogueRoleParentNode();
assertEquals(roleCatalogueDto.getId(), removeCatalogueRoleParentNode);
// Clean
systemService.delete(systemDto);
systemService.delete(memberSystemDto);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto 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.getCode()));
assertEquals(1, roleSystemService.find(filter, null).getTotalElements());
roleService.delete(role);
assertNull(roleService.getByCode(role.getCode()));
assertEquals(0, roleSystemService.find(filter, null).getTotalElements());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto 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());
}
Aggregations