Search in sources :

Example 76 with AccIdentityAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.

the class ForwardAccountManagementTest method forwardAcmEnabledTest.

@Test
public void forwardAcmEnabledTest() {
    SysSystemDto system = initIdentityData();
    Assert.assertNotNull(system);
    SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
    Assert.assertNotNull(mapping);
    IdmIdentityDto identity = helper.createIdentity();
    AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
    roleAccountFilter.setEntityId(identity.getId());
    roleAccountFilter.setOwnership(Boolean.TRUE);
    roleAccountFilter.setSystemId(system.getId());
    List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    // None role assigned
    Assert.assertEquals(0, identityAccounts.size());
    IdmRoleDto roleDefault = helper.createRole();
    SysRoleSystemDto roleSystemDefault = new SysRoleSystemDto();
    roleSystemDefault.setRole(roleDefault.getId());
    roleSystemDefault.setSystem(system.getId());
    roleSystemDefault.setSystemMapping(mapping.getId());
    // Forward ACM is enabled
    roleSystemDefault.setForwardAccountManagemen(true);
    // 
    roleSystemDefault = roleSystemService.save(roleSystemDefault);
    IdmIdentityRoleDto identityRole = new IdmIdentityRoleDto();
    identityRole.setIdentityContract(identityContractService.getPrimeContract(identity.getId()).getId());
    identityRole.setRole(roleDefault.getId());
    identityRole.setValidFrom(LocalDate.now().plusDays(10));
    identityRole = identityRoleService.save(identityRole);
    identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    // Role assigned - is valid in the future and forward ACM is enabled
    Assert.assertEquals(1, identityAccounts.size());
    // Delete
    identityService.delete(identity);
    roleService.delete(roleDefault);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) 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 77 with AccIdentityAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.

the class ForwardAccountManagementTest method forwardAcmDisabledTest.

@Test
public void forwardAcmDisabledTest() {
    SysSystemDto system = initIdentityData();
    Assert.assertNotNull(system);
    SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
    Assert.assertNotNull(mapping);
    IdmIdentityDto identity = helper.createIdentity();
    AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
    roleAccountFilter.setEntityId(identity.getId());
    roleAccountFilter.setOwnership(Boolean.TRUE);
    roleAccountFilter.setSystemId(system.getId());
    List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    // None role assigned
    Assert.assertEquals(0, identityAccounts.size());
    IdmRoleDto roleDefault = helper.createRole();
    SysRoleSystemDto roleSystemDefault = new SysRoleSystemDto();
    roleSystemDefault.setRole(roleDefault.getId());
    roleSystemDefault.setSystem(system.getId());
    roleSystemDefault.setSystemMapping(mapping.getId());
    // Forward ACM is disabled
    roleSystemDefault.setForwardAccountManagemen(false);
    // 
    roleSystemDefault = roleSystemService.save(roleSystemDefault);
    IdmIdentityRoleDto identityRole = new IdmIdentityRoleDto();
    identityRole.setIdentityContract(identityContractService.getPrimeContract(identity.getId()).getId());
    identityRole.setRole(roleDefault.getId());
    identityRole.setValidFrom(LocalDate.now().plusDays(10));
    identityRole = identityRoleService.save(identityRole);
    identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    // Role assigned, but is valid in the future and forward ACM is disabled
    Assert.assertEquals(0, identityAccounts.size());
    // Delete
    identityService.delete(identity);
    roleService.delete(roleDefault);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) 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 78 with AccIdentityAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.

the class ForwardAccountManagementTest method identityRoleIsValidInPastTest.

@Test
public void identityRoleIsValidInPastTest() {
    SysSystemDto system = initIdentityData();
    Assert.assertNotNull(system);
    SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
    Assert.assertNotNull(mapping);
    IdmIdentityDto identity = helper.createIdentity();
    AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
    roleAccountFilter.setEntityId(identity.getId());
    roleAccountFilter.setOwnership(Boolean.TRUE);
    roleAccountFilter.setSystemId(system.getId());
    List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    // None role assigned
    Assert.assertEquals(0, identityAccounts.size());
    IdmRoleDto roleDefault = helper.createRole();
    SysRoleSystemDto roleSystemDefault = new SysRoleSystemDto();
    roleSystemDefault.setRole(roleDefault.getId());
    roleSystemDefault.setSystem(system.getId());
    roleSystemDefault.setSystemMapping(mapping.getId());
    // Forward ACM is enabled
    roleSystemDefault.setForwardAccountManagemen(true);
    // 
    roleSystemDefault = roleSystemService.save(roleSystemDefault);
    IdmIdentityRoleDto identityRole = new IdmIdentityRoleDto();
    identityRole.setIdentityContract(identityContractService.getPrimeContract(identity.getId()).getId());
    identityRole.setRole(roleDefault.getId());
    identityRole.setValidFrom(LocalDate.now().minusDays(10));
    // Assignment is expired
    identityRole.setValidTill(LocalDate.now().minusDays(1));
    identityRole = identityRoleService.save(identityRole);
    identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
    // Role assigned - but is expired (forward ACM is enabled)
    Assert.assertEquals(0, identityAccounts.size());
    // Delete
    identityService.delete(identity);
    roleService.delete(roleDefault);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) 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 79 with AccIdentityAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.

the class PasswordPreValidationIntegrationTest method testLenght.

@Test
public void testLenght() {
    IdmIdentityDto identity = new IdmIdentityDto();
    identity.setUsername("test" + System.currentTimeMillis());
    identity.setFirstName("testFirst");
    identity.setLastName("testSecond");
    identity = idmIdentityService.save(identity);
    // 
    SysSystemDto system = testHelper.createTestResourceSystem(true);
    // 
    AccAccountDto acc = new AccAccountDto();
    acc.setId(UUID.randomUUID());
    acc.setUid(System.currentTimeMillis() + "");
    acc.setAccountType(AccountType.PERSONAL);
    acc.setSystem(system.getId());
    // 
    acc = accountService.save(acc);
    // 
    AccIdentityAccountDto account = testHelper.createIdentityAccount(system, identity);
    account.setAccount(acc.getId());
    account.setOwnership(true);
    account = accountIdentityService.save(account);
    List<String> accounts = new ArrayList<String>();
    accounts.add(acc.getId() + "");
    // password policy default
    IdmPasswordPolicyDto policyDefault = new IdmPasswordPolicyDto();
    policyDefault.setName(System.currentTimeMillis() + "test1");
    policyDefault.setDefaultPolicy(true);
    policyDefault.setMinPasswordLength(5);
    policyDefault.setMaxPasswordLength(10);
    // password policy
    IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
    policy.setName(System.currentTimeMillis() + "test2");
    policy.setDefaultPolicy(false);
    policy.setMinPasswordLength(6);
    policy.setMaxPasswordLength(11);
    policyDefault = passwordPolicyService.save(policyDefault);
    policy = passwordPolicyService.save(policy);
    system.setPasswordPolicyValidate(policy.getId());
    systemService.save(system);
    PasswordChangeDto passwordChange = new PasswordChangeDto();
    passwordChange.setIdm(true);
    passwordChange.setAccounts(accounts);
    passwordChange.setAll(true);
    try {
        idmIdentityService.validatePassword(passwordChange);
    } catch (ResultCodeException ex) {
        assertEquals(6, ex.getError().getError().getParameters().get("minLength"));
        assertEquals(10, ex.getError().getError().getParameters().get("maxLength"));
        assertEquals(2, ex.getError().getError().getParameters().size());
        policyDefault.setDefaultPolicy(false);
        passwordPolicyService.save(policyDefault);
    }
}
Also used : IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) ArrayList(java.util.ArrayList) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) 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 80 with AccIdentityAccountDto

use of eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto in project CzechIdMng by bcvsolutions.

the class PasswordPreValidationIntegrationTest method testAdvancedEnabledSimilarAttributes.

@Test
public void testAdvancedEnabledSimilarAttributes() {
    IdmIdentityDto identity = new IdmIdentityDto();
    identity.setUsername("test" + System.currentTimeMillis());
    identity.setFirstName("testFirst");
    identity.setLastName("testSecond");
    identity = idmIdentityService.save(identity);
    // 
    SysSystemDto system = testHelper.createTestResourceSystem(true);
    // 
    AccAccountDto acc = new AccAccountDto();
    acc.setId(UUID.randomUUID());
    acc.setUid(System.currentTimeMillis() + "");
    acc.setAccountType(AccountType.PERSONAL);
    acc.setSystem(system.getId());
    // 
    acc = accountService.save(acc);
    // 
    AccIdentityAccountDto account = testHelper.createIdentityAccount(system, identity);
    account.setAccount(acc.getId());
    account = accountIdentityService.save(account);
    account.setOwnership(true);
    List<String> accounts = new ArrayList<String>();
    accounts.add(acc.getId() + "");
    // password policy default
    IdmPasswordPolicyDto policyDefault = new IdmPasswordPolicyDto();
    policyDefault.setName(System.currentTimeMillis() + "test1");
    policyDefault.setDefaultPolicy(true);
    policyDefault.setMinPasswordLength(10);
    policyDefault.setMaxPasswordLength(20);
    policyDefault.setPasswordLengthRequired(true);
    policyDefault.setMinUpperChar(5);
    policyDefault.setUpperCharRequired(true);
    policyDefault.setMinLowerChar(4);
    policyDefault.setLowerCharRequired(true);
    policyDefault.setEnchancedControl(true);
    policyDefault.setMinRulesToFulfill(1);
    policyDefault.setMinNumber(3);
    policyDefault.setNumberRequired(false);
    policyDefault.setMinSpecialChar(4);
    policyDefault.setSpecialCharRequired(false);
    policyDefault.setIdentityAttributeCheck("EMAIL, FIRSTNAME");
    // password policy
    IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
    policy.setName(System.currentTimeMillis() + "test2");
    policy.setDefaultPolicy(false);
    policy.setMinPasswordLength(9);
    policy.setMaxPasswordLength(21);
    policy.setPasswordLengthRequired(true);
    policy.setMinUpperChar(4);
    policy.setUpperCharRequired(true);
    policy.setMinLowerChar(3);
    policy.setLowerCharRequired(true);
    policy.setEnchancedControl(true);
    policy.setMinRulesToFulfill(1);
    policy.setMinNumber(5);
    policy.setNumberRequired(false);
    policy.setMinSpecialChar(2);
    policy.setSpecialCharRequired(false);
    policy.setIdentityAttributeCheck("USERNAME");
    policyDefault = passwordPolicyService.save(policyDefault);
    policy = passwordPolicyService.save(policy);
    system.setPasswordPolicyValidate(policy.getId());
    systemService.save(system);
    PasswordChangeDto passwordChange = new PasswordChangeDto();
    passwordChange.setIdm(true);
    passwordChange.setAccounts(accounts);
    passwordChange.setAll(true);
    try {
        idmIdentityService.validatePassword(passwordChange);
    } catch (ResultCodeException ex) {
        Map<String, Object> parametrs = new HashMap<String, Object>();
        parametrs.put("minNumber", 3);
        parametrs.put("minSpecialChar", 4);
        assertEquals(10, ex.getError().getError().getParameters().get("minLength"));
        assertEquals(20, ex.getError().getError().getParameters().get("maxLength"));
        assertEquals(5, ex.getError().getError().getParameters().get("minUpperChar"));
        assertEquals(4, ex.getError().getError().getParameters().get("minLowerChar"));
        assertEquals(parametrs.toString(), ex.getError().getError().getParameters().get("minRulesToFulfill").toString());
        // special char base, passwordSimilarUsername, passwordSimilarLastName,
        // passwordSimilarEmail -> 11, policy's name erased -> 10
        assertEquals(10, ex.getError().getError().getParameters().size());
        policyDefault.setDefaultPolicy(false);
        passwordPolicyService.save(policyDefault);
    }
}
Also used : PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) ArrayList(java.util.ArrayList) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) HashMap(java.util.HashMap) Map(java.util.Map) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)115 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)92 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)90 Test (org.junit.Test)79 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)76 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)59 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)59 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)48 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)38 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)34 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)31 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)29 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)22 ArrayList (java.util.ArrayList)22 UUID (java.util.UUID)21 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)19 PasswordChangeDto (eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto)17 Transactional (org.springframework.transaction.annotation.Transactional)17 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)16 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)16