use of eu.bcvsolutions.idm.core.security.api.domain.GuardedString in project CzechIdMng by bcvsolutions.
the class CodeableEvaluatorIntegrationTest method testPermissionByWrongUuid.
@Test
public void testPermissionByWrongUuid() {
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
// prepare role
IdmRoleDto role = helper.createRole();
//
IdmAuthorizationPolicyDto dto = new IdmAuthorizationPolicyDto();
dto.setRole(role.getId());
dto.setEvaluator(CodeableEvaluator.class);
dto.setGroupPermission(CoreGroupPermission.ROLE.getName());
dto.setAuthorizableType(IdmRole.class.getCanonicalName());
dto.getEvaluatorProperties().put(CodeableEvaluator.PARAMETER_IDENTIFIER, "wrong");
dto.setPermissions(IdmBasePermission.READ);
authorizationPolicyService.save(dto);
// prepare identity
IdmIdentityDto identity = helper.createIdentity();
identity.setPassword(new GuardedString("heslo"));
identityService.save(identity);
// assign role
helper.createIdentityRole(identity, role);
logout();
//
try {
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
//
// evaluate access
assertEquals(0, roleService.find(null, IdmBasePermission.READ).getTotalElements());
;
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.security.api.domain.GuardedString in project CzechIdMng by bcvsolutions.
the class ConfigurationEvaluatorIntegrationTest method testUpdateWithoutPermissions.
@Test(expected = ForbiddenEntityException.class)
public void testUpdateWithoutPermissions() {
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
// prepare role
IdmRoleDto role = helper.createRole();
//
IdmAuthorizationPolicyDto dto = new IdmAuthorizationPolicyDto();
dto.setRole(role.getId());
dto.setEvaluator(ConfigurationEvaluator.class);
dto.setGroupPermission(CoreGroupPermission.CONFIGURATION.getName());
dto.setAuthorizableType(IdmConfiguration.class.getCanonicalName());
dto.setPermissions(IdmBasePermission.READ);
authorizationPolicyService.save(dto);
// prepare identity
IdmIdentityDto identity = helper.createIdentity();
identity.setPassword(new GuardedString("heslo"));
identityService.save(identity);
// assign role
helper.createIdentityRole(identity, role);
logout();
//
try {
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
//
publicConfig.setValue("update");
configurationService.save(publicConfig, IdmBasePermission.UPDATE);
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.security.api.domain.GuardedString in project CzechIdMng by bcvsolutions.
the class IdentityTransitiveEvaluatorsIntegrationTest method testChangePassword.
@Test
public void testChangePassword() {
IdmIdentityDto identity = prepareIdentityProfile();
//
try {
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
//
PasswordChangeDto passwordChangeDto = new PasswordChangeDto();
passwordChangeDto.setIdm(true);
passwordChangeDto.setAll(true);
passwordChangeDto.setOldPassword(identity.getPassword());
passwordChangeDto.setNewPassword(new GuardedString("heslo2"));
passwordChangeController.passwordChange(identity.getId().toString(), passwordChangeDto);
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.security.api.domain.GuardedString in project CzechIdMng by bcvsolutions.
the class IdentityTransitiveEvaluatorsIntegrationTest method testChangeForeignPassword.
@Test(expected = ForbiddenEntityException.class)
public void testChangeForeignPassword() {
IdmIdentityDto identity = prepareIdentityProfile();
//
try {
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
//
PasswordChangeDto passwordChangeDto = new PasswordChangeDto();
passwordChangeDto.setIdm(true);
passwordChangeDto.setOldPassword(identity.getPassword());
passwordChangeDto.setNewPassword(new GuardedString("heslo2"));
passwordChangeController.passwordChange(InitTestData.TEST_ADMIN_USERNAME, passwordChangeDto);
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.security.api.domain.GuardedString in project CzechIdMng by bcvsolutions.
the class RoleForRequestEvaluatorIntegrationTest method deleteRoleAsUser.
private Exception deleteRoleAsUser(IdmIdentityDto user, IdmRoleDto role) {
try {
loginService.login(new LoginDto(user.getUsername(), new GuardedString(TEST_PWD)));
roleService.delete(role, IdmBasePermission.DELETE);
} catch (Exception ex) {
return ex;
} finally {
logout();
}
return null;
}
Aggregations