Search in sources :

Example 51 with TestResource

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

the class IdentityPasswordProvisioningTest method testPasswordChangeGreenLine.

@Test
public void testPasswordChangeGreenLine() {
    String newPassword = "newPassword" + System.currentTimeMillis();
    String newPassword2 = "newPassword2" + System.currentTimeMillis();
    SysSystemDto system = initSystem();
    IdmRoleDto role = initRole(system);
    IdmIdentityDto identity = helper.createIdentity();
    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());
    assertNotNull(entityOnSystem);
    assertEquals(DEFAULT_PASSWORD, entityOnSystem.getPassword());
    PasswordChangeDto passwordChange = new PasswordChangeDto();
    passwordChange.setAll(true);
    passwordChange.setOldPassword(new GuardedString(DEFAULT_PASSWORD));
    passwordChange.setNewPassword(new GuardedString(newPassword));
    List<OperationResult> results = identityProvisioningExecutor.changePassword(identity, passwordChange);
    assertEquals(1, results.size());
    entityOnSystem = helper.findResource(account.getUid());
    assertNotNull(entityOnSystem);
    assertEquals(newPassword, entityOnSystem.getPassword());
    passwordChange = new PasswordChangeDto();
    passwordChange.setAccounts(Lists.newArrayList(account.getId().toString()));
    passwordChange.setOldPassword(new GuardedString(DEFAULT_PASSWORD));
    passwordChange.setNewPassword(new GuardedString(newPassword2));
    results = identityProvisioningExecutor.changePassword(identity, passwordChange);
    assertEquals(1, results.size());
    entityOnSystem = helper.findResource(account.getUid());
    assertNotNull(entityOnSystem);
    assertEquals(newPassword2, entityOnSystem.getPassword());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) PasswordChangeDto(eu.bcvsolutions.idm.core.api.dto.PasswordChangeDto) 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) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) 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) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 52 with TestResource

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

the class IdentityPasswordProvisioningTest method testCheckMappingReturnStringPasswordChange.

@Test(expected = ResultCodeException.class)
public void testCheckMappingReturnStringPasswordChange() {
    String postfixForPassword = "-" + System.currentTimeMillis();
    SysSystemDto system = initSystem();
    IdmRoleDto role = initRole(system);
    SysSystemAttributeMappingDto descriptionAttribute = initDescriptionAttribute(system);
    descriptionAttribute = changeAttributeToPasswordMapping(descriptionAttribute, null);
    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());
    assertEquals(DEFAULT_PASSWORD, findResource.getDescrip());
    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());
    findResource = helper.findResource(identityUsername);
    assertNotNull(findResource);
    String newPassword = "newPass" + System.currentTimeMillis();
    // this throw exception
    changePassword(identity, null, newPassword);
    fail();
}
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 53 with TestResource

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

the class IdentityPasswordProvisioningTest method testCheckMapping.

@Test
public void testCheckMapping() {
    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 new GuardedString(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);
    assertNotNull(findResource);
    assertEquals(DEFAULT_PASSWORD, findResource.getPassword());
    assertEquals(DEFAULT_PASSWORD + postfixForPassword, 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 54 with TestResource

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

the class IdentityPasswordProvisioningTest method disabledPasswordAttribute.

@Test
public void disabledPasswordAttribute() {
    SysSystemDto system = initSystem();
    IdmRoleDto role = initRole(system);
    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());
    // disable password attribute
    SysSystemAttributeMappingDto passwordAttribute = getMainPasswordAttribute(system);
    passwordAttribute.setDisabledAttribute(true);
    passwordAttribute = systemAttributeMappingService.save(passwordAttribute);
    // change password, but only for idm
    List<OperationResult> results = changePassword(identity, null, "password");
    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())) {
            assertNull(account.getSystemId());
            assertNull(account.getSystemName());
            continue;
        } else if (statusEnum.equals(CoreResultCode.PASSWORD_CHANGE_ACCOUNT_FAILED.name())) {
            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(DEFAULT_PASSWORD, findResource.getPassword());
    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)

Example 55 with TestResource

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

the class IdentityPasswordProvisioningTest method testIdentityPasswordChangeWithAnotherAtt.

@Test
public void testIdentityPasswordChangeWithAnotherAtt() {
    SysSystemDto system = initSystem();
    IdmRoleDto role = initRole(system);
    SysSystemAttributeMappingDto descriptionAttribute = initDescriptionAttribute(system);
    descriptionAttribute = changeAttributeToPasswordMapping(descriptionAttribute, null);
    String identityUsername = "test-" + System.currentTimeMillis();
    IdmIdentityDto identity = helper.createIdentity(identityUsername);
    IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
    checkIdentityAccount(identity, identityRole, 1);
    String newPassword = "newPass" + System.currentTimeMillis();
    changePassword(identity, null, newPassword);
    TestResource findResource = helper.findResource(identityUsername);
    assertNotNull(findResource);
    assertEquals(newPassword, findResource.getPassword());
    assertEquals(newPassword, 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)

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