Search in sources :

Example 86 with AccIdentityAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningServiceTest method prepareAccount.

private AccIdentityAccountDto prepareAccount(IdmIdentityDto identity) {
    AccAccountDto accountOne = new AccAccountDto();
    accountOne.setSystem(getSystem().getId());
    accountOne.setUid("x" + identity.getUsername());
    accountOne.setAccountType(AccountType.PERSONAL);
    accountOne.setEntityType(SystemEntityType.IDENTITY);
    accountOne = accountService.save(accountOne);
    // 
    AccIdentityAccountDto accountIdentityOne = new AccIdentityAccountDto();
    accountIdentityOne.setIdentity(identity.getId());
    accountIdentityOne.setOwnership(true);
    accountIdentityOne.setAccount(accountOne.getId());
    // 
    return identityAccountService.save(accountIdentityOne);
}
Also used : AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)

Example 87 with AccIdentityAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto 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 88 with AccIdentityAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningServiceTest method doIdentityProvisioningStrategyIfNull.

@Test
public void doIdentityProvisioningStrategyIfNull() {
    IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccountService.find(filter, null).getContent().get(0);
    // Default email strategy is CREATE, we check value
    TestResource resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertEquals(EMAIL_ONE, resourceAccoutn.getEmail());
    SysSystemAttributeMappingFilter filterSchemaAttr = new SysSystemAttributeMappingFilter();
    filterSchemaAttr.setIdmPropertyName("email");
    filterSchemaAttr.setSystemId(accountService.get(accountIdentityOne.getAccount()).getSystem());
    SysSystemAttributeMappingDto attributeHandling = systemAttributeMappingService.find(filterSchemaAttr, null).getContent().get(0);
    attributeHandling.setEntityAttribute(true);
    attributeHandling.setStrategyType(AttributeMappingStrategyType.WRITE_IF_NULL);
    attributeHandling.setTransformToResourceScript("return \"" + EMAIL_TWO + "\";");
    systemAttributeMappingService.save(attributeHandling);
    // Do provisioning
    provisioningService.doProvisioning(identity);
    // Email strategy is WRITE_IF_NULL ... email in account must not have new value
    resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertNotEquals(EMAIL_TWO, resourceAccoutn.getEmail());
    attributeHandling.setEntityAttribute(true);
    attributeHandling.setStrategyType(AttributeMappingStrategyType.SET);
    attributeHandling.setTransformToResourceScript("return \"" + EMAIL_TWO + "\";");
    systemAttributeMappingService.save(attributeHandling);
    // Do provisioning
    provisioningService.doProvisioning(identity);
    // Email strategy is SET ... email in account must have new value
    resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertEquals(EMAIL_TWO, resourceAccoutn.getEmail());
}
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) 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 89 with AccIdentityAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningServiceTest method doIdentityProvisioningChangeIdentityContract.

@Test
public void doIdentityProvisioningChangeIdentityContract() {
    // change identity internally
    IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
    identity.setFirstName("first-name-change");
    identity = identityService.saveInternal(identity);
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    IdmIdentityContractDto contract = identityContractService.getPrimeContract(identity.getId());
    contract.setDescription("update");
    identityContractService.save(contract);
    AccIdentityAccountDto accountIdentityOne = identityAccountService.find(filter, null).getContent().get(0);
    TestResource changedAccount = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertNotNull(changedAccount);
    Assert.assertEquals(identity.getFirstName(), changedAccount.getFirstname());
    identity.setFirstName(IDENTITY_CHANGED_FIRST_NAME);
    identity = identityService.save(identity);
    changedAccount = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertNotNull(changedAccount);
    Assert.assertEquals(identity.getFirstName(), changedAccount.getFirstname());
}
Also used : AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) 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 90 with AccIdentityAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto 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)

Aggregations

AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)115 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)92 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)90 Test (org.junit.Test)79 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)76 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)59 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)59 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)48 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)38 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)34 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)31 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)29 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)22 ArrayList (java.util.ArrayList)22 UUID (java.util.UUID)21 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)19 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)17 Transactional (org.springframework.transaction.annotation.Transactional)17 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)16 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)16