Search in sources :

Example 36 with TestResource

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

the class DefaultSynchronizationServiceTest method changeResourceDataWrongEmail.

@Transactional
public void changeResourceDataWrongEmail() {
    // Set wrong email to resource
    TestResource one = entityManager.find(TestResource.class, "x" + IDENTITY_USERNAME_ONE);
    one.setEmail(IDENTITY_EMAIL_WRONG);
    TestResource two = entityManager.find(TestResource.class, "x" + IDENTITY_USERNAME_TWO);
    two.setEmail(IDENTITY_EMAIL_WRONG);
    // Change data on resource
    entityManager.persist(one);
    entityManager.persist(two);
}
Also used : TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) Transactional(org.springframework.transaction.annotation.Transactional)

Example 37 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)

Example 38 with TestResource

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

the class DefaultSynchronizationServiceTest method initResourceData.

@Transactional
public void initResourceData() {
    // Delete all
    Query q = entityManager.createNativeQuery("DELETE FROM test_resource");
    q.executeUpdate();
    // Insert data to testResource table
    LocalDateTime paste = LocalDateTime.now().minusYears(1);
    LocalDateTime future = paste.plusYears(2);
    TestResource resourceUserOne = new TestResource();
    resourceUserOne.setName("x" + IDENTITY_USERNAME_ONE);
    resourceUserOne.setFirstname(IDENTITY_USERNAME_ONE);
    resourceUserOne.setLastname(IDENTITY_USERNAME_ONE);
    resourceUserOne.setEmail(IDENTITY_EMAIL_CORRECT);
    resourceUserOne.setModified(paste);
    resourceUserOne.setEavAttribute("1");
    entityManager.persist(resourceUserOne);
    TestResource resourceUserTwo = new TestResource();
    resourceUserTwo.setName("x" + IDENTITY_USERNAME_TWO);
    resourceUserTwo.setFirstname(IDENTITY_USERNAME_TWO);
    resourceUserTwo.setLastname(IDENTITY_USERNAME_TWO);
    resourceUserTwo.setEmail(IDENTITY_EMAIL_CORRECT);
    resourceUserTwo.setModified(future);
    resourceUserTwo.setEavAttribute("2");
    entityManager.persist(resourceUserTwo);
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Query(javax.persistence.Query) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) Transactional(org.springframework.transaction.annotation.Transactional)

Example 39 with TestResource

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

the class DefaultSysProvisioningServiceTest method doIdentityProvisioningChangeSingleAttribute.

@Test
public void doIdentityProvisioningChangeSingleAttribute() {
    IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
    identity.setFirstName(IDENTITY_CHANGED_FIRST_NAME);
    identity = idmIdentityService.save(identity);
    Assert.assertEquals("Identity must have this first name!", IDENTITY_CHANGED_FIRST_NAME, identity.getFirstName());
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    filter.setSystemId(systemService.getByCode(SYSTEM_NAME).getId());
    AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
    AccAccountDto account = accountService.get(accountIdentityOne.getAccount());
    SysSystemDto system = DtoUtils.getEmbedded(account, AccAccount_.system, SysSystemDto.class);
    SysSystemEntityDto systemEntity = DtoUtils.getEmbedded(account, AccAccount_.systemEntity, SysSystemEntityDto.class);
    SysSystemAttributeMappingFilter attributeFilter = new SysSystemAttributeMappingFilter();
    attributeFilter.setSystemId(system.getId());
    attributeFilter.setIdmPropertyName("firstName");
    TestResource resourceAccount = entityManager.find(TestResource.class, "x" + IDENTITY_USERNAME);
    Assert.assertNotNull("Idenitity have to exists on target system (after account management)", resourceAccount);
    Assert.assertEquals("Account on target system, must have same first name as Identity", IDENTITY_CHANGED_FIRST_NAME, resourceAccount.getFirstname());
    provisioningService.doProvisioningForAttribute(systemEntity, systemAttributeMappingService.find(attributeFilter, null).getContent().get(0), IDENTITY_USERNAME, ProvisioningOperationType.UPDATE, identity);
    resourceAccount = entityManager.find(TestResource.class, "x" + IDENTITY_USERNAME);
    Assert.assertNotNull("Idenitity have to exists on target system (after account management)", resourceAccount);
    Assert.assertEquals("Account on target system, must have changed first name!", IDENTITY_USERNAME, resourceAccount.getFirstname());
}
Also used : SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) 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) 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 40 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 = idmIdentityService.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 = idmIdentityService.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 = idmIdentityService.find(filter, null).getContent();
    Assert.assertEquals(0, subordinates.size());
    // 
    // change subordinate again
    subordinateOne.setFirstName("first-name-change-two");
    subordinateOne = idmIdentityService.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 = idmIdentityService.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)

Aggregations

TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)45 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)37 Test (org.junit.Test)37 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)36 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)25 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)23 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)19 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)17 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)17 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)16 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)11 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)7 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)7 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)6 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)6 Transactional (org.springframework.transaction.annotation.Transactional)5 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)3 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)3 AccAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter)2 Transactional (javax.transaction.Transactional)2