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());
}
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();
}
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());
}
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());
}
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());
}
Aggregations