Search in sources :

Example 91 with TestResource

use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningServiceTest method doIdentityProvisioningChangeAccountIdentifier.

/**
 * Test for change account ID.
 */
@Test
public void doIdentityProvisioningChangeAccountIdentifier() {
    IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME_TWO);
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccountService.find(filter, null).getContent().get(0);
    AccAccountDto account = accountService.get(accountIdentityOne.getAccount());
    identity.setUsername(IDENTITY_USERNAME_CHANGED);
    identity = identityService.save(identity);
    Assert.assertEquals("x" + IDENTITY_USERNAME_TWO, account.getUid());
    TestResource changedAccount = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertNotNull(changedAccount);
    Assert.assertEquals(identity.getUsername(), changedAccount.getName().substring(1));
    account = accountService.get(account.getId());
    Assert.assertEquals("x" + IDENTITY_USERNAME_CHANGED, account.getUid());
    Assert.assertEquals("x" + IDENTITY_USERNAME_CHANGED, account.getRealUid());
    // Change username back
    identity.setUsername(IDENTITY_USERNAME_TWO);
    identity = identityService.save(identity);
    account = accountService.get(account.getId());
    Assert.assertEquals("x" + IDENTITY_USERNAME_TWO, account.getUid());
    Assert.assertEquals("x" + IDENTITY_USERNAME_TWO, account.getRealUid());
}
Also used : AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 92 with TestResource

use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningServiceTest method testUpdateWishIfSystemEntityExists.

@Test
public void testUpdateWishIfSystemEntityExists() {
    String username = getHelper().createName();
    SysSystemDto system = getHelper().createTestResourceSystem(true);
    // 
    // prepare resource
    IdmIdentityDto identity = getHelper().createIdentity(username, (GuardedString) null);
    TestResource resource = new TestResource();
    resource.setName(username);
    resource.setFirstname(identity.getFirstName());
    resource.setLastname(identity.getLastName());
    // TODO: test constant
    resource.setStatus("enabled");
    resource = getHelper().saveResource(resource);
    // 
    // prepare identity with account on target system with the same system entity as prepared
    IdmRoleDto role = getHelper().createRole();
    getHelper().createRoleSystem(role, system);
    getHelper().createIdentityRole(identity, role);
    // 
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccountService.find(filter, null).getContent().get(0);
    AccAccountDto account = accountService.get(accountIdentityOne.getAccount());
    // 
    SysSystemEntityDto systemEntity = DtoUtils.getEmbedded(account, AccAccount_.systemEntity);
    // 
    resource = helper.findResource(account.getRealUid());
    // 
    Assert.assertFalse(systemEntity.isWish());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 93 with TestResource

use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningServiceTest method doIdentityProvisioningChangeManagersContract.

/**
 * Call provisioning for subordinates, after managers's contract changes - filled managers could be provisioned
 */
@Test
public void doIdentityProvisioningChangeManagersContract() {
    IdmIdentityDto managerOne = createIdentity();
    IdmIdentityDto subordinateOne = createIdentity();
    IdmTreeNodeDto managerOnePosition = createTreeNode(null);
    IdmIdentityContractDto managersContract = createIdentityContact(managerOne, managerOnePosition);
    IdmTreeNodeDto subordinateOnePositionOne = createTreeNode(managerOnePosition);
    createIdentityContact(subordinateOne, subordinateOnePositionOne);
    AccIdentityAccountDto subordinateAccount = prepareAccount(subordinateOne);
    // 
    provisioningService.doProvisioning(DtoUtils.getEmbedded(subordinateAccount, AccIdentityAccount_.identity, IdmIdentityDto.class));
    // 
    TestResource account = entityManager.find(TestResource.class, accountService.get(subordinateAccount.getAccount()).getUid());
    Assert.assertNotNull(account);
    Assert.assertEquals(subordinateOne.getFirstName(), account.getFirstname());
    // 
    IdmIdentityFilter filter = new IdmIdentityFilter();
    filter.setSubordinatesFor(managerOne.getId());
    List<IdmIdentityDto> subordinates = identityService.find(filter, null).getContent();
    Assert.assertEquals(1, subordinates.size());
    Assert.assertEquals(subordinateOne.getId(), subordinates.get(0).getId());
    // 
    // change subordinate
    subordinateOne.setFirstName("first-name-change-one");
    subordinateOne = identityService.saveInternal(subordinateOne);
    // 
    // change managers contract
    managersContract.setWorkPosition(null);
    managersContract = identityContractService.save(managersContract);
    // 
    account = entityManager.find(TestResource.class, accountService.get(subordinateAccount.getAccount()).getUid());
    Assert.assertNotNull(account);
    Assert.assertEquals(subordinateOne.getFirstName(), account.getFirstname());
    subordinates = identityService.find(filter, null).getContent();
    Assert.assertEquals(0, subordinates.size());
    // 
    // change subordinate again
    subordinateOne.setFirstName("first-name-change-two");
    subordinateOne = identityService.saveInternal(subordinateOne);
    // 
    managersContract.setWorkPosition(managerOnePosition.getId());
    managersContract = identityContractService.save(managersContract);
    // 
    account = entityManager.find(TestResource.class, accountService.get(subordinateAccount.getAccount()).getUid());
    Assert.assertNotNull(account);
    Assert.assertEquals(subordinateOne.getFirstName(), account.getFirstname());
    subordinates = identityService.find(filter, null).getContent();
    Assert.assertEquals(1, subordinates.size());
    Assert.assertEquals(subordinateOne.getId(), subordinates.get(0).getId());
}
Also used : IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 94 with TestResource

use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningServiceTest method doIdentityProvisioningExtendedAttribute.

@Test
public void doIdentityProvisioningExtendedAttribute() {
    IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccountService.find(filter, null).getContent().get(0);
    // We will use firstName attribute (password attribute is not returned
    // by default)
    SysSystemAttributeMappingFilter filterSchemaAttr = new SysSystemAttributeMappingFilter();
    filterSchemaAttr.setIdmPropertyName("firstName");
    filterSchemaAttr.setSystemId(accountService.get(accountIdentityOne.getAccount()).getSystem());
    SysSystemAttributeMappingDto attributeHandling = systemAttributeMappingService.find(filterSchemaAttr, null).getContent().get(0);
    // Set attribute to extended attribute and modify idmPropety to
    // extPassword
    attributeHandling.setIdmPropertyName(IDENTITY_EXT_PASSWORD);
    attributeHandling.setExtendedAttribute(true);
    attributeHandling.setConfidentialAttribute(true);
    attributeHandling.setEntityAttribute(false);
    attributeHandling.setTransformToResourceScript("return attributeValue");
    // Form attribute definition will be created during save attribute
    // handling
    attributeHandling = systemAttributeMappingService.save(attributeHandling);
    // Create extended attribute value for password
    IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentity.class);
    List<IdmFormValueDto> values = new ArrayList<>();
    IdmFormValueDto phoneValue = new IdmFormValueDto();
    phoneValue.setFormAttribute(formDefinition.getMappedAttributeByCode(IDENTITY_EXT_PASSWORD).getId());
    phoneValue.setPersistentType(PersistentType.SHORTTEXT);
    phoneValue.setValue(IDENTITY_PASSWORD_THREE);
    values.add(phoneValue);
    formService.saveValues(identity, formDefinition, values);
    // save account
    provisioningService.doProvisioning(identity);
    TestResource resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertEquals(IDENTITY_PASSWORD_THREE, resourceAccoutn.getFirstname());
}
Also used : SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) ArrayList(java.util.ArrayList) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 95 with TestResource

use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.

the class DefaultSynchronizationServiceTest method addIdentityThreeToResourceData.

@Transactional
public void addIdentityThreeToResourceData() {
    // Change data on resource
    // Insert data to testResource table
    TestResource resourceUser = new TestResource();
    resourceUser.setName("x" + IDENTITY_USERNAME_THREE);
    resourceUser.setFirstname(IDENTITY_USERNAME_THREE);
    resourceUser.setLastname(IDENTITY_USERNAME_THREE);
    resourceUser.setEmail(IDENTITY_EMAIL_CORRECT);
    resourceUser.setEavAttribute("3");
    entityManager.persist(resourceUser);
}
Also used : TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)97 Test (org.junit.Test)83 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)81 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)69 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)51 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)50 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)36 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)32 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)32 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)30 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)27 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)26 ConfidentialString (eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString)19 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)17 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)12 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)12 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)12 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)11 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)10 Transactional (org.springframework.transaction.annotation.Transactional)10