Search in sources :

Example 6 with TestResource

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

the class DefaultSysProvisioningServiceTest method testPasswordChangeWithAdditionalAttributesInOneOperation.

@Test
public void testPasswordChangeWithAdditionalAttributesInOneOperation() {
    Assert.assertTrue(provisioningConfiguration.isSendPasswordAttributesTogether());
    // 
    // prepare account on target system
    SysSystemDto system = helper.createTestResourceSystem(true);
    SysSystemMappingDto systemMapping = helper.getDefaultMapping(system);
    SysSystemAttributeMappingDto firtstNameAttribute = systemAttributeMappingService.findBySystemMappingAndName(systemMapping.getId(), TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME);
    firtstNameAttribute.setSendOnPasswordChange(Boolean.TRUE);
    systemAttributeMappingService.save(firtstNameAttribute);
    IdmRoleDto role = helper.createRole();
    helper.createRoleSystem(role, system);
    IdmIdentityDto identity = helper.createIdentity();
    helper.createIdentityRole(identity, role);
    // 
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccoutnService.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
    String firstNameChange = "firstname-change";
    identity.setFirstName(firstNameChange);
    idmIdentityService.passwordChange(identity, passwordChange);
    // 
    // Check correct password One
    TestResource resource = helper.findResource(account.getRealUid());
    Assert.assertNotNull(resource);
    Assert.assertEquals(IDENTITY_PASSWORD_ONE, resource.getPassword());
    Assert.assertEquals(firstNameChange, resource.getFirstname());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) 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 7 with TestResource

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

the class DefaultSysProvisioningServiceTest method doIdentityProvisioningChangeAccountTransformFromResource.

@Test
public void doIdentityProvisioningChangeAccountTransformFromResource() {
    IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
    TestResource createdAccount = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    identity.setFirstName(IDENTITY_CHANGED_FIRST_NAME.substring(1));
    identity = idmIdentityService.save(identity);
    Assert.assertNotEquals(identity.getFirstName(), createdAccount.getFirstname());
    provisioningService.doProvisioning(identity);
    TestResource changedAccount = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertNotNull(changedAccount);
    // Must be with "c" on target system, because we have set transformation
    // from system!
    Assert.assertEquals(identity.getFirstName(), changedAccount.getFirstname().substring(1));
}
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 8 with TestResource

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

the class DefaultSysProvisioningServiceTest method doIdentityProvisioningAndPasswordCheck.

@Test
public void doIdentityProvisioningAndPasswordCheck() {
    IdmIdentityDto existIdentity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(existIdentity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
    TestResource createdAccount = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertNotNull(createdAccount);
    // password must be exactly two 'a' characters, see setting for password
    // policy
    Assert.assertEquals("aa", createdAccount.getPassword());
}
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 9 with TestResource

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

the class DefaultSysProvisioningServiceTest method doIdentityProvisioningStrategySendOnlyIfNotNull.

@Test
public void doIdentityProvisioningStrategySendOnlyIfNotNull() {
    IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
    // Init value check
    TestResource resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertEquals(EMAIL_TWO, 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.SET);
    attributeHandling.setSendOnlyIfNotNull(true);
    attributeHandling.setTransformToResourceScript("return null");
    systemAttributeMappingService.save(attributeHandling);
    // Do provisioning
    provisioningService.doProvisioning(identity);
    // Email strategy is SendOnlyIfNotNull ... email in account must have old value
    resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertEquals(EMAIL_TWO, resourceAccoutn.getEmail());
    attributeHandling.setStrategyType(AttributeMappingStrategyType.SET);
    attributeHandling.setTransformToResourceScript("return \"\";");
    systemAttributeMappingService.save(attributeHandling);
    // Do provisioning
    provisioningService.doProvisioning(identity);
    // Email strategy is SendOnlyIfNotNull (value is empty string) ... email in account must have old value
    resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertEquals(EMAIL_TWO, resourceAccoutn.getEmail());
    attributeHandling.setStrategyType(AttributeMappingStrategyType.SET);
    attributeHandling.setTransformToResourceScript("return \"" + EMAIL_ONE + "\";");
    systemAttributeMappingService.save(attributeHandling);
    // Do provisioning
    provisioningService.doProvisioning(identity);
    // Email strategy is SendOnlyIfNotNull  (value is not null and not empty)... email in account must have new value
    resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    Assert.assertEquals(EMAIL_ONE, 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 10 with TestResource

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

the class DefaultSysProvisioningServiceTest method doIdentityProvisioningChangeAccount.

@Test
public void doIdentityProvisioningChangeAccount() {
    IdmIdentityDto identity = idmIdentityService.getByUsername(IDENTITY_USERNAME);
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    AccIdentityAccountDto accountIdentityOne = identityAccoutnService.find(filter, null).getContent().get(0);
    TestResource createdAccount = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
    identity.setFirstName(IDENTITY_CHANGED_FIRST_NAME);
    identity = idmIdentityService.save(identity);
    Assert.assertNotEquals(identity.getFirstName(), createdAccount.getFirstname());
    provisioningService.doProvisioning(identity);
    TestResource 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) 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