Search in sources :

Example 11 with TestResource

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

the class DefaultSysProvisioningServiceTest method doIdentityProvisioningAddAccount.

@Test
public void doIdentityProvisioningAddAccount() {
    initData();
    IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
    provisioningService.doProvisioning(DtoUtils.getEmbedded(accountIdentityOne, AccIdentityAccount_.identity, IdmIdentityDto.class));
    TestResource createdAccount = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertNotNull(createdAccount);
    Assert.assertEquals(identity.getFirstName(), createdAccount.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) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 12 with TestResource

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

the class IdentitySyncTest method setTestData.

/**
 * Method set and persist data to test resource
 */
@Transactional
public void setTestData(String name, String firstName, String lastName) {
    TestResource resourceUser = new TestResource();
    resourceUser.setName(name);
    resourceUser.setFirstname(firstName);
    resourceUser.setLastname(lastName);
    entityManager.persist(resourceUser);
}
Also used : TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) Transactional(javax.transaction.Transactional)

Example 13 with TestResource

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

the class IdentitySetPasswordProcessorIntegrationTest method testGeneratePassword.

@Test
public void testGeneratePassword() {
    SysSystemDto system = helper.createTestResourceSystem(true);
    // 
    IdmRoleDto role = helper.createRole();
    helper.createRoleSystem(role, system);
    IdmIdentityDto identity = helper.createIdentity();
    IdmIdentityContractDto contract = helper.getPrimeContract(identity.getId());
    contract.setValidFrom(new LocalDate().plusDays(1));
    identityContractService.save(contract);
    identity = identityService.get(identity.getId());
    Assert.assertEquals(IdentityState.FUTURE_CONTRACT, identity.getState());
    helper.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());
    // Create new password one
    PasswordChangeDto passwordChange = new PasswordChangeDto();
    passwordChange.setAccounts(ImmutableList.of(account.getId().toString()));
    passwordChange.setNewPassword(new GuardedString(IDENTITY_PASSWORD_ONE));
    passwordChange.setIdm(true);
    // 
    // Do change of password for selected accounts
    identityService.passwordChange(identity, passwordChange);
    // 
    // Check correct password One
    TestResource resource = helper.findResource(account.getRealUid());
    Assert.assertNotNull(resource);
    Assert.assertEquals(IDENTITY_PASSWORD_ONE, resource.getPassword());
    // 
    // set contract to valid
    contract.setValidFrom(new LocalDate());
    identityContractService.save(contract);
    identity = identityService.get(identity.getId());
    Assert.assertEquals(IdentityState.VALID, identity.getState());
    // 
    // check password on target system was changed
    resource = helper.findResource(account.getRealUid());
    Assert.assertNotNull(resource);
    Assert.assertNotEquals(IDENTITY_PASSWORD_ONE, resource.getPassword());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) LocalDate(org.joda.time.LocalDate) 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 14 with TestResource

use of eu.bcvsolutions.idm.acc.entity.TestResource 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 15 with TestResource

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

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