Search in sources :

Example 26 with TestResource

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

the class DefaultProvisioningExecutorIntegrationTest method testClearProvisioningBatchOnReadonlySystem.

@Test
public void testClearProvisioningBatchOnReadonlySystem() {
    SysSystemDto system = helper.createTestResourceSystem(true);
    system.setReadonly(true);
    system = systemService.save(system);
    String firstname = "firstname";
    SysProvisioningOperationDto provisioningOperation = createProvisioningOperation(system, firstname);
    Map<ProvisioningAttributeDto, Object> accoutObject = provisioningOperation.getProvisioningContext().getAccountObject();
    String uid = (String) accoutObject.get(getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_NAME));
    // 
    // publish event
    // 1 - create
    provisioningExecutor.execute(provisioningOperation);
    // is necessary to get again operation from service
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setSystemEntity(provisioningOperation.getSystemEntity());
    filter.setSystemId(system.getId());
    SysProvisioningOperationDto readOnlyOperation = provisioningOperationService.find(filter, null).getContent().get(0);
    assertEquals(OperationState.NOT_EXECUTED, readOnlyOperation.getResultState());
    assertEquals(AccResultCode.PROVISIONING_SYSTEM_READONLY.name(), readOnlyOperation.getResult().getModel().getStatusEnum());
    SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
    // 2 - update
    provisioningExecutor.execute(updateProvisioningOperation(systemEntity, firstname + 2));
    // 3 - update
    provisioningExecutor.execute(updateProvisioningOperation(systemEntity, firstname + 3));
    // 
    systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
    assertTrue(systemEntity.isWish());
    assertNull(helper.findResource(uid));
    // 
    // check batch
    SysProvisioningBatchDto batch = provisioningBatchService.findBatch(system.getId(), readOnlyOperation.getEntityIdentifier(), systemEntity.getId());
    Assert.assertNotNull(batch);
    // 
    // check provisioning operation requests
    List<SysProvisioningOperationDto> requests = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
    Assert.assertEquals(3, requests.size());
    // 
    // execute first operation - create
    system.setReadonly(false);
    system = systemService.save(system);
    provisioningExecutor.execute(readOnlyOperation);
    Assert.assertNull(provisioningOperationService.get(readOnlyOperation.getId()));
    // 
    systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
    assertFalse(systemEntity.isWish());
    TestResource resource = helper.findResource(uid);
    assertNotNull(resource);
    Assert.assertEquals(firstname, resource.getFirstname());
    Assert.assertEquals(2, provisioningOperationService.findByBatchId(batch.getId(), null).getContent().size());
    // 
    // execute whole batch
    provisioningExecutor.execute(batch);
    // 
    resource = helper.findResource(uid);
    Assert.assertEquals(firstname + 3, resource.getFirstname());
    Assert.assertEquals(0, provisioningOperationService.findByBatchId(batch.getId(), null).getTotalElements());
    Assert.assertNull(provisioningOperationService.get(readOnlyOperation.getId()));
    Assert.assertNull(provisioningBatchService.get(batch.getId()));
}
Also used : SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 27 with TestResource

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

the class IdentitySyncTest method initIdentityData.

@Transactional
public void initIdentityData() {
    deleteAllResourceData();
    TestResource resourceUserOne = new TestResource();
    resourceUserOne.setName(IDENTITY_ONE);
    resourceUserOne.setFirstname(IDENTITY_ONE);
    resourceUserOne.setLastname(IDENTITY_ONE);
    resourceUserOne.setEavAttribute("1");
    entityManager.persist(resourceUserOne);
}
Also used : TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) Transactional(javax.transaction.Transactional)

Example 28 with TestResource

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

the class IdentityAccountManagementTest method defaultAccountAddValid.

@Test
public void defaultAccountAddValid() {
    IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
    IdmRoleDto roleDefault = roleService.getByCode(ROLE_DEFAULT);
    Assert.assertNull("No account for this identity can be found, before account management start!", helper.findResource("x" + IDENTITY_USERNAME));
    IdmIdentityRoleDto irdto = new IdmIdentityRoleDto();
    irdto.setIdentityContract(identityContractService.findAllByIdentity(identity.getId()).get(0).getId());
    irdto.setRole(roleDefault.getId());
    // This evokes IdentityRole SAVE event. On this event will be start
    // account management and provisioning
    IdmIdentityRoleDto irCreated = identityRoleService.save(irdto);
    AccIdentityAccountFilter iaccFilter = new AccIdentityAccountFilter();
    iaccFilter.setIdentityId(identity.getId());
    iaccFilter.setIdentityRoleId(irCreated.getId());
    AccIdentityAccountDto identityAccount = identityAccountService.find(iaccFilter, null).getContent().get(0);
    Assert.assertNotNull("Idenitity account have to exists after account management was started!", identityAccount);
    Assert.assertNotNull("Account have to exists after account management was started!", identityAccount.getAccount());
    Assert.assertEquals(accountService.get(identityAccount.getAccount()).getUid(), "x" + IDENTITY_USERNAME);
    TestResource createdAccount = helper.findResource("x" + IDENTITY_USERNAME);
    Assert.assertNotNull("Idenitity have to exists on target system (after account management)", createdAccount);
    Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 29 with TestResource

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

the class IdentityAccountManagementTest method overloadedAttributeAdd_B_DisableFirstNameRole.

@Test
public void overloadedAttributeAdd_B_DisableFirstNameRole() {
    IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
    IdmRoleDto roleLastName = roleService.getByCode(ROLE_OVERLOADING_FIRST_NAME);
    Assert.assertNotNull("Account for this identity have to be found!", helper.findResource("x" + IDENTITY_USERNAME));
    IdmIdentityRoleDto irdto = new IdmIdentityRoleDto();
    irdto.setIdentityContract(identityContractService.findAllByIdentity(identity.getId()).get(0).getId());
    irdto.setRole(roleLastName.getId());
    // This evokes IdentityRole SAVE event. On this event will be start
    // account management and provisioning
    identityRoleService.save(irdto);
    AccIdentityAccountFilter iaccFilter = new AccIdentityAccountFilter();
    iaccFilter.setIdentityId(identity.getId());
    // Now we have to identity roles (role_overloading_first_name and
    // role_overloading_last_name) and identity accounts
    Assert.assertEquals("Idenitity accounts have to exists (two items) after account management was started!", 2, identityAccountService.find(iaccFilter, null).getContent().size());
    TestResource createdAccount = helper.findResource("x" + IDENTITY_USERNAME);
    Assert.assertNotNull("Idenitity have to exists on target system (after account management)", createdAccount);
    Assert.assertEquals("First name on target system must be equals with first name on identity", identity.getFirstName(), createdAccount.getFirstname());
    identity.setFirstName(IDENTITY_CHANGED_FIRST_NAME);
    identity.setEmail(IDENTITY_EMAIL_CHANGED);
    // This evokes Identity SAVE event. On this event will be start
    // account management and provisioning
    identityService.save(identity);
    createdAccount = helper.findResource("x" + IDENTITY_USERNAME);
    // Because first name attribute was disabled, we now expect change only
    // on email attribute
    Assert.assertEquals("Last name on target system must be equals with email on identity (we use overloded attribute)", IDENTITY_EMAIL_CHANGED, createdAccount.getLastname());
    Assert.assertNotEquals("First name on target system must be not equals with first name on identity (we use overloded disabled attribute)", identity.getFirstName(), createdAccount.getFirstname());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 30 with TestResource

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

the class IdentityAccountManagementTest method defaultAccountDisable.

@Test
public void defaultAccountDisable() {
    IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
    Assert.assertEquals("Identity must be enabled!", Boolean.FALSE, identity.isDisabled());
    TestResource resourceAccount = helper.findResource("x" + IDENTITY_USERNAME);
    Assert.assertNotNull("Idenitity have to exists on target system (after account management)", resourceAccount);
    Assert.assertEquals("Account on target system, must be enabled", "enabled", resourceAccount.getStatus());
    identity.setState(IdentityState.DISABLED);
    // This evokes Identity SAVE event. On this event will be start account
    // management and provisioning
    identityService.save(identity);
    resourceAccount = helper.findResource("x" + IDENTITY_USERNAME);
    Assert.assertNotNull("Idenitity have to exists on target system (after account management)", resourceAccount);
    Assert.assertEquals("Account on target system, must be disabled!", "disabled", resourceAccount.getStatus());
}
Also used : TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) 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