Search in sources :

Example 76 with IdmIdentityDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto in project CzechIdMng by bcvsolutions.

the class ProvisioningBreakProcessorTest method testWarningDeleteOperation.

@Test
public void testWarningDeleteOperation() {
    SysSystemDto system = testHelper.createTestResourceSystem(true);
    IdmIdentityDto identity = testHelper.createIdentity();
    IdmIdentityDto identity2 = testHelper.createIdentity();
    IdmIdentityDto identity3 = testHelper.createIdentity();
    SysProvisioningBreakConfigDto breakConfig = createProvisioningBreak(20l, null, 2, ProvisioningEventType.DELETE, system.getId());
    IdmIdentityDto recipient = testHelper.createIdentity();
    createRecipient(breakConfig.getId(), recipient.getId(), null);
    // 
    this.createAccount(system, identity);
    this.createAccount(system, identity2);
    this.createAccount(system, identity3);
    // 
    provisioningService.doProvisioning(identity);
    provisioningService.doProvisioning(identity2);
    provisioningService.doProvisioning(identity3);
    // 
    identityService.delete(identity);
    identityService.delete(identity2);
    identityService.delete(identity3);
    // 
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setRecipient(recipient.getUsername());
    List<IdmNotificationLogDto> content = notificationLogService.find(filter, null).getContent();
    // two notification (notification +
    assertEquals(2, content.size());
    // parent)
    // 
    system = systemService.get(system.getId());
    assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getUpdateOperation());
    assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getCreateOperation());
    assertNotEquals(Boolean.TRUE, system.getBlockedOperation().getDeleteOperation());
}
Also used : SysProvisioningBreakConfigDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 77 with IdmIdentityDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto in project CzechIdMng by bcvsolutions.

the class ProvisioningBreakProcessorTest method testBlockSystemCreate.

@Test
public void testBlockSystemCreate() {
    SysSystemDto system = testHelper.createTestResourceSystem(true);
    SysBlockedOperationDto blockedOperationDto = new SysBlockedOperationDto();
    blockedOperationDto.blockCreate();
    system.setBlockedOperation(blockedOperationDto);
    system = systemService.save(system);
    // 
    IdmIdentityDto identity = testHelper.createIdentity();
    createProvisioningBreak(20l, 3, 2, ProvisioningEventType.CREATE, system.getId());
    // 
    this.createAccount(system, identity);
    // 
    // create block
    provisioningService.doProvisioning(identity);
    SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
    // 
    SysProvisioningBatchDto batch = batchService.findBatch(system.getId(), identity.getId(), systemEntity.getId());
    // 
    List<SysProvisioningOperationDto> content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
    assertEquals(1, content.size());
    SysProvisioningOperationDto sysProvisioningOperationDto = content.get(0);
    // 
    assertEquals(ProvisioningEventType.CREATE, sysProvisioningOperationDto.getOperationType());
    assertEquals(OperationState.BLOCKED, sysProvisioningOperationDto.getResult().getState());
}
Also used : SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) SysBlockedOperationDto(eu.bcvsolutions.idm.acc.dto.SysBlockedOperationDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) 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 78 with IdmIdentityDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto in project CzechIdMng by bcvsolutions.

the class IdentityAccountManagementTest method overloadedAttributeAdd_C_AccountYrole.

@Test
public void overloadedAttributeAdd_C_AccountYrole() {
    IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
    IdmRoleDto role = roleService.getByCode(ROLE_OVERLOADING_Y_ACCOUNT);
    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(role.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 role_overloading_y_account) and
    // identity accounts
    Assert.assertEquals("Idenitity accounts have to exists (three items) after account management was started!", 3, identityAccountService.find(iaccFilter, null).getContent().size());
    TestResource createdAccount = helper.findResource("y" + 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());
    Assert.assertEquals("Last name on target system must be equals with first name on identity", identity.getLastName(), createdAccount.getLastname());
}
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 79 with IdmIdentityDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto in project CzechIdMng by bcvsolutions.

the class IdentityAccountManagementTest method defaultAccountAddInvalid.

@Test
public /**
 * Add invalid identity role. Account cannot be created.
 */
void defaultAccountAddInvalid() {
    initData();
    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());
    // Set valid from to future
    irdto.setValidFrom(LocalDate.now().plusDays(1));
    // This evokes IdentityRole SAVE event. On this event will be start
    // account management and provisioning
    irdto = identityRoleService.save(irdto);
    AccIdentityAccountFilter iaccFilter = new AccIdentityAccountFilter();
    iaccFilter.setIdentityId(identity.getId());
    iaccFilter.setIdentityRoleId(irdto.getId());
    List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(iaccFilter, null).getContent();
    // Identity-account have to not exists after account management was started (INVALID identityRole was added)!
    Assert.assertEquals(0, identityAccounts.size());
    // Set valid from to null - Account must be created
    irdto.setValidFrom(null);
    // This evokes IdentityRole SAVE event. On this event will be start
    // account management and provisioning
    irdto = identityRoleService.save(irdto);
    identityAccounts = identityAccountService.find(iaccFilter, null).getContent();
    Assert.assertEquals(1, identityAccounts.size());
    AccIdentityAccountDto identityAccount = identityAccounts.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());
    // Set valid from to null - Account must be created
    irdto.setValidTill(LocalDate.now().minusDays(1));
    // This evokes IdentityRole SAVE event. On this event will be start
    // account management and provisioning
    irdto = identityRoleService.save(irdto);
    identityAccounts = identityAccountService.find(iaccFilter, null).getContent();
    // Identity-account have to not exists after account management was started (INVALID identityRole was added)!
    Assert.assertEquals(0, identityAccounts.size());
    // Clean identity role
    identityRoleService.delete(irdto);
}
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 80 with IdmIdentityDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto in project CzechIdMng by bcvsolutions.

the class IdentityAccountManagementTest method overloadedAttributeChangePassword.

@Test
public void overloadedAttributeChangePassword() {
    IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    filter.setSystemId(systemService.getByCode(SYSTEM_NAME).getId());
    List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(filter, new PageRequest(0, 1, new Sort(Sort.Direction.ASC, AccIdentityAccount_.created.getName()))).getContent();
    TestResource resourceAccount = helper.findResource("x" + IDENTITY_USERNAME);
    // Create new password two
    PasswordChangeDto passwordChange = new PasswordChangeDto();
    passwordChange.setAccounts(ImmutableList.of(identityAccounts.get(0).getAccount().toString()));
    passwordChange.setNewPassword(new GuardedString(IDENTITY_PASSWORD_TWO));
    passwordChange.setIdm(true);
    // Do change of password for selected accounts
    identityService.passwordChange(identity, passwordChange);
    // Check correct password two
    resourceAccount = helper.findResource("x" + IDENTITY_USERNAME);
    Assert.assertEquals("Check same password on target system", IDENTITY_PASSWORD_TWO, resourceAccount.getPassword());
    // Add overloaded password attribute
    IdmRoleDto rolePassword = roleService.getByCode(ROLE_OVERLOADING_PASSWORD);
    IdmIdentityRoleDto irdto = new IdmIdentityRoleDto();
    irdto.setIdentityContract(identityContractService.findAllByIdentity(identity.getId()).get(0).getId());
    irdto.setRole(rolePassword.getId());
    // This evokes IdentityRole SAVE event. On this event will be start
    // account management and provisioning
    identityRoleService.save(irdto);
    // Do change of password for selected accounts
    passwordChange.setNewPassword(new GuardedString(IDENTITY_PASSWORD_THREE));
    identityService.passwordChange(identity, passwordChange);
    // Check correct overloaded password two
    resourceAccount = helper.findResource("x" + IDENTITY_USERNAME);
    Assert.assertEquals("Check overloaded password (added x) on target system", "x" + IDENTITY_PASSWORD_THREE, resourceAccount.getPassword());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) PageRequest(org.springframework.data.domain.PageRequest) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) Sort(org.springframework.data.domain.Sort) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) 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)

Aggregations

IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)568 Test (org.junit.Test)433 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)328 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)206 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)157 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)99 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)95 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)69 ArrayList (java.util.ArrayList)63 LoginDto (eu.bcvsolutions.idm.core.security.api.dto.LoginDto)61 UUID (java.util.UUID)59 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)58 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)55 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)54 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)54 Transactional (org.springframework.transaction.annotation.Transactional)53 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)51 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)50 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)49 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)48