use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class ConfigurationEvaluatorIntegrationTest method testReadWithPermissions.
@Test
public void testReadWithPermissions() {
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()));
//
// evaluate access
List<IdmConfigurationDto> configs = configurationService.find(null, IdmBasePermission.READ).getContent();
assertTrue(configs.contains(publicConfig));
assertFalse(configs.contains(privateConfig));
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class ConfigurationEvaluatorIntegrationTest method testUpdateSecuredWithoutPermissions.
@Test(expected = ForbiddenEntityException.class)
public void testUpdateSecuredWithoutPermissions() {
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, IdmBasePermission.UPDATE);
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()));
//
privateConfig.setValue("update");
configurationService.save(privateConfig, IdmBasePermission.UPDATE);
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class IdentityTransitiveEvaluatorsIntegrationTest method prepareIdentityProfile.
private IdmIdentityDto prepareIdentityProfile() {
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
// get default role
IdmRoleDto role = roleService.getByCode(InitDemoData.DEFAULT_ROLE_NAME);
// prepare identity
IdmIdentityDto identity = helper.createIdentity();
identity.setPassword(new GuardedString("heslo"));
identity = identityService.save(identity);
// assign role
helper.createIdentityRole(identity, role);
logout();
//
return identity;
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class RoleRequestByIdentityEvaluatorIntegrationTest method testCannotReadRoleRequestByIdentity.
@Test(expected = ForbiddenEntityException.class)
public void testCannotReadRoleRequestByIdentity() {
IdmIdentityDto identityOne = helper.createIdentity();
IdmIdentityDto identityTwo = helper.createIdentity();
//
IdmRoleDto role = helper.createRole();
helper.createIdentityRole(identityTwo, role);
IdmRoleRequestDto roleRequest = helper.assignRoles(helper.getPrimeContract(identityOne.getId()), role);
//
try {
loginService.login(new LoginDto(identityTwo.getUsername(), identityTwo.getPassword()));
//
roleRequestService.get(roleRequest.getId(), IdmBasePermission.READ);
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class RoleRequestByIdentityEvaluatorIntegrationTest method testCreateRoleRequestForOtherIdentity.
@Test
public void testCreateRoleRequestForOtherIdentity() {
IdmIdentityDto identityOne = helper.createIdentity();
IdmIdentityDto identityTwo = helper.createIdentity();
// create policy
IdmRoleDto role = helper.createRole();
helper.createUuidPolicy(role.getId(), identityTwo.getId(), IdentityBasePermission.CHANGEPERMISSION);
helper.createIdentityRole(identityOne, role);
// assign default role
helper.createIdentityRole(identityOne, roleService.getByCode(InitDemoData.DEFAULT_ROLE_NAME));
//
try {
loginService.login(new LoginDto(identityOne.getUsername(), identityOne.getPassword()));
//
IdmRoleRequestDto roleRequest = new IdmRoleRequestDto();
roleRequest.setApplicant(identityTwo.getId());
roleRequest.setRequestedByType(RoleRequestedByType.MANUALLY);
roleRequest = roleRequestService.save(roleRequest, IdmBasePermission.CREATE);
//
Assert.notNull(roleRequest.getId());
} finally {
logout();
}
}
Aggregations