Search in sources :

Example 56 with TestResource

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

the class IdentityPasswordProvisioningTest method testCheckMappingReturnStringCreate.

@Test
public void testCheckMappingReturnStringCreate() {
    String postfixForPassword = "-" + System.currentTimeMillis();
    SysSystemDto system = initSystem();
    IdmRoleDto role = initRole(system);
    SysSystemAttributeMappingDto descriptionAttribute = initDescriptionAttribute(system);
    descriptionAttribute = changeAttributeToPasswordMapping(descriptionAttribute, "" + "import eu.bcvsolutions.idm.core.security.api.domain.GuardedString;" + System.lineSeparator() + "" + System.lineSeparator() + "String newPassword = attributeValue.asString();" + System.lineSeparator() + "newPassword = newPassword + " + postfixForPassword + ";" + System.lineSeparator() + "" + System.lineSeparator() + "return newPassword;" + System.lineSeparator());
    String identityUsername = "test-" + System.currentTimeMillis();
    IdmIdentityDto identity = helper.createIdentity(identityUsername);
    IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
    checkIdentityAccount(identity, identityRole, 1);
    TestResource findResource = helper.findResource(identityUsername);
    assertNull(findResource);
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setEntityType(SystemEntityType.IDENTITY);
    filter.setEntityIdentifier(identity.getId());
    List<SysProvisioningOperationDto> operations = provisioningOperationService.find(filter, null).getContent();
    assertEquals(1, operations.size());
    SysProvisioningOperationDto operationDto = operations.get(0);
    assertEquals(OperationState.EXCEPTION, operationDto.getResultState());
    OperationResult result = operationDto.getResult();
    assertEquals(AccResultCode.PROVISIONING_PASSWORD_TRANSFORMATION_FAILED.getCode(), result.getCode());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) 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 57 with TestResource

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

the class IdentityPasswordProvisioningTest method testCheckMappingReturnNull.

@Test
public void testCheckMappingReturnNull() {
    SysSystemDto system = initSystem();
    IdmRoleDto role = initRole(system);
    SysSystemAttributeMappingDto descriptionAttribute = initDescriptionAttribute(system);
    descriptionAttribute = changeAttributeToPasswordMapping(descriptionAttribute, "return null;" + System.lineSeparator());
    String identityUsername = "test-" + System.currentTimeMillis();
    IdmIdentityDto identity = helper.createIdentity(identityUsername);
    IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
    checkIdentityAccount(identity, identityRole, 1);
    TestResource findResource = helper.findResource(identityUsername);
    assertNotNull(findResource);
    assertEquals(DEFAULT_PASSWORD, findResource.getPassword());
    assertNull(findResource.getDescrip());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 58 with TestResource

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

the class IdentityPasswordProvisioningTest method twoAttributesBothEnabled.

@Test
public void twoAttributesBothEnabled() {
    SysSystemDto system = initSystem();
    IdmRoleDto role = initRole(system);
    SysSystemAttributeMappingDto descriptionAttribute = initDescriptionAttribute(system);
    changeAttributeToPasswordMapping(descriptionAttribute, null);
    IdmIdentityDto identity = helper.createIdentity();
    IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
    checkIdentityAccount(identity, identityRole, 1);
    TestResource findResource = helper.findResource(identity.getUsername());
    assertNotNull(findResource);
    assertEquals(DEFAULT_PASSWORD, findResource.getPassword());
    assertEquals(DEFAULT_PASSWORD, findResource.getDescrip());
    String newPassword = "password" + System.currentTimeMillis();
    // change password, but only for idm
    List<OperationResult> results = changePassword(identity, null, newPassword);
    assertEquals(2, results.size());
    // check for results
    for (OperationResult result : results) {
        IdmAccountDto account = (IdmAccountDto) result.getModel().getParameters().get(IdmAccountDto.PARAMETER_NAME);
        String statusEnum = result.getModel().getStatusEnum();
        assertNotNull(statusEnum);
        assertNotNull(account);
        if (statusEnum.equals(CoreResultCode.PASSWORD_CHANGE_ACCOUNT_SUCCESS.name())) {
            if (account.getSystemId() == null) {
                // idm
                assertNull(account.getSystemId());
                assertNull(account.getSystemName());
            } else {
                assertEquals(system.getId(), account.getSystemId());
                assertEquals(system.getName(), account.getSystemName());
            }
            continue;
        }
        fail("Different result!");
    }
    // password must be same as before
    findResource = helper.findResource(identity.getUsername());
    assertNotNull(findResource);
    assertEquals(newPassword, findResource.getPassword());
    assertEquals(newPassword, findResource.getDescrip());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmAccountDto(eu.bcvsolutions.idm.core.api.dto.IdmAccountDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) 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) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 59 with TestResource

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

the class IdentityPasswordProvisioningTest method testSendPasswordNotificationProvisioningFailed.

@Test
public void testSendPasswordNotificationProvisioningFailed() {
    SysSystemDto system = initSystem();
    IdmRoleDto role = initRole(system);
    IdmIdentityDto identity = helper.createIdentity();
    // => new password is sent for valid identity only
    identity.setState(IdentityState.VALID);
    identityService.save(identity);
    // Break the system (change the password column to not exists) - we need make a exception.
    IdmFormDefinitionDto savedFormDefinition = systemService.getConnectorFormDefinition(system);
    IdmFormAttributeDto formAttribute = savedFormDefinition.getMappedAttributeByCode("passwordColumn");
    formService.saveValues(system, formAttribute, Lists.newArrayList("not-exist-column-password"));
    IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
    checkIdentityAccount(identity, identityRole, 1);
    AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
    Assert.assertNotNull(account);
    Assert.assertFalse(account.isInProtection());
    TestResource entityOnSystem = helper.findResource(account.getUid());
    assertNull(entityOnSystem);
    // Check for send password notification
    IdmNotificationFilter notificationFilter = new IdmNotificationFilter();
    notificationFilter.setTopic(AccModuleDescriptor.TOPIC_NEW_PASSWORD);
    notificationFilter.setRecipient(identity.getUsername());
    List<IdmNotificationLogDto> notifications = // 
    notificationLogService.find(notificationFilter, null).getContent().stream().filter(// 
    notification -> IdmEmailLog.NOTIFICATION_TYPE.equals(notification.getType())).collect(Collectors.toList());
    assertEquals(0, notifications.size());
}
Also used : ProvisioningExecutor(eu.bcvsolutions.idm.acc.service.api.ProvisioningExecutor) IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) StringUtils(org.apache.commons.lang3.StringUtils) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) SysRoleSystemService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemService) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysProvisioningArchiveDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) After(org.junit.After) Assert.fail(org.junit.Assert.fail) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysProvisioningOperationService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningOperationService) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) Collectors(java.util.stream.Collectors) IdentityState(eu.bcvsolutions.idm.core.api.domain.IdentityState) Serializable(java.io.Serializable) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) List(java.util.List) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) Assert.assertFalse(org.junit.Assert.assertFalse) IdentityProvisioningExecutor(eu.bcvsolutions.idm.acc.service.impl.IdentityProvisioningExecutor) Entry(java.util.Map.Entry) AccIdentityAccountService(eu.bcvsolutions.idm.acc.service.api.AccIdentityAccountService) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) AttributeMappingStrategyType(eu.bcvsolutions.idm.acc.domain.AttributeMappingStrategyType) ProvisioningEventType(eu.bcvsolutions.idm.acc.domain.ProvisioningEventType) IdmAccountDto(eu.bcvsolutions.idm.core.api.dto.IdmAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ConfidentialStorage(eu.bcvsolutions.idm.core.api.service.ConfidentialStorage) Lists(com.google.common.collect.Lists) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) Before(org.junit.Before) AccModuleDescriptor(eu.bcvsolutions.idm.acc.AccModuleDescriptor) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) SysProvisioningArchiveService(eu.bcvsolutions.idm.acc.service.api.SysProvisioningArchiveService) IdmPasswordPolicyType(eu.bcvsolutions.idm.core.api.domain.IdmPasswordPolicyType) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) Assert.assertNotNull(org.junit.Assert.assertNotNull) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Assert.assertTrue(org.junit.Assert.assertTrue) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) Test(org.junit.Test) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IdmNotificationLogService(eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationLogService) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) Assert.assertNull(org.junit.Assert.assertNull) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) IdmEmailLog(eu.bcvsolutions.idm.core.notification.entity.IdmEmailLog) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) ProvisioningService(eu.bcvsolutions.idm.acc.service.api.ProvisioningService) IdmIdentity_(eu.bcvsolutions.idm.core.model.entity.IdmIdentity_) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) TestHelper(eu.bcvsolutions.idm.acc.TestHelper) Assert(org.junit.Assert) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) Assert.assertEquals(org.junit.Assert.assertEquals) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) IdmPasswordPolicyService(eu.bcvsolutions.idm.core.api.service.IdmPasswordPolicyService) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 60 with TestResource

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

the class IdentityPasswordProvisioningTest method twoAttributeDescriptionDisabled.

@Test
public void twoAttributeDescriptionDisabled() {
    SysSystemDto system = initSystem();
    IdmRoleDto role = initRole(system);
    SysSystemAttributeMappingDto descriptionAttribute = initDescriptionAttribute(system);
    changeAttributeToPasswordMapping(descriptionAttribute, null);
    descriptionAttribute.setDisabledAttribute(true);
    descriptionAttribute = systemAttributeMappingService.save(descriptionAttribute);
    IdmIdentityDto identity = helper.createIdentity();
    IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
    checkIdentityAccount(identity, identityRole, 1);
    TestResource findResource = helper.findResource(identity.getUsername());
    assertNotNull(findResource);
    assertEquals(DEFAULT_PASSWORD, findResource.getPassword());
    assertNull(findResource.getDescrip());
    String newPassword = "password" + System.currentTimeMillis();
    // change password, but only for idm
    List<OperationResult> results = changePassword(identity, null, newPassword);
    assertEquals(2, results.size());
    // check for results
    for (OperationResult result : results) {
        IdmAccountDto account = (IdmAccountDto) result.getModel().getParameters().get(IdmAccountDto.PARAMETER_NAME);
        String statusEnum = result.getModel().getStatusEnum();
        assertNotNull(statusEnum);
        assertNotNull(account);
        if (statusEnum.equals(CoreResultCode.PASSWORD_CHANGE_ACCOUNT_SUCCESS.name())) {
            if (account.getSystemId() == null) {
                // idm
                assertNull(account.getSystemId());
                assertNull(account.getSystemName());
            } else {
                assertEquals(system.getId(), account.getSystemId());
                assertEquals(system.getName(), account.getSystemName());
            }
            continue;
        }
        fail("Different result!");
    }
    // password must be same as before
    findResource = helper.findResource(identity.getUsername());
    assertNotNull(findResource);
    assertEquals(newPassword, findResource.getPassword());
    // description is disabled
    assertNull(findResource.getDescrip());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmAccountDto(eu.bcvsolutions.idm.core.api.dto.IdmAccountDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) ConfidentialString(eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString) 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) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)97 Test (org.junit.Test)83 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)81 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)69 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)51 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)50 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)36 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)32 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)32 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)30 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)27 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)26 ConfidentialString (eu.bcvsolutions.idm.core.security.api.domain.ConfidentialString)19 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)17 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)12 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)12 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)12 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)11 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)10 Transactional (org.springframework.transaction.annotation.Transactional)10