use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultRoleSynchronizationServiceTest method provisioningB_CreateAccounts.
@Test
public void provisioningB_CreateAccounts() {
IdmRoleFilter filter = new IdmRoleFilter();
filter.setProperty(IdmRole_.code.getName());
filter.setValue(ROLE_NAME_TEN);
IdmRoleDto roleTen = roleService.find(filter, null).getContent().get(0);
Assert.assertNotNull(roleTen);
// Check state before provisioning
TestRoleResource ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
Assert.assertNull(ten);
// Create mapping for provisioning
SysSystemMappingDto mapping = this.createProvisionigMapping();
// Save IDM role (must invoke provisioning)
roleService.save(roleTen);
// Check state before provisioning
ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
Assert.assertNotNull(ten);
// Delete role mapping
systemMappingService.delete(mapping);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class IdmRoleControllerRestTest method testFindByBaseCode.
@Test
public void testFindByBaseCode() {
IdmRoleDto roleOne = prepareDto();
roleOne.setCode(null);
roleOne.setBaseCode(getHelper().createName());
IdmRoleDto roleOneCreated = createDto(roleOne);
IdmRoleDto roleTwo = prepareDto();
roleTwo.setCode(null);
roleTwo.setBaseCode(getHelper().createName());
roleTwo = createDto(roleTwo);
//
IdmRoleFilter filter = new IdmRoleFilter();
filter.setBaseCode(roleOne.getBaseCode());
List<IdmRoleDto> roles = find(filter);
Assert.assertEquals(1, roles.size());
Assert.assertTrue(roles.stream().anyMatch(r -> r.getId().equals(roleOneCreated.getId())));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class RoleSynchronizationExecutor method findByAttribute.
@Override
protected IdmRoleDto findByAttribute(String idmAttributeName, String value) {
CorrelationFilter filter = getEntityFilter();
filter.setProperty(idmAttributeName);
filter.setValue(value);
List<IdmRoleDto> entities = roleService.find((IdmRoleFilter) filter, null).getContent();
if (CollectionUtils.isEmpty(entities)) {
return null;
}
if (entities.size() > 1) {
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_CORRELATION_TO_MANY_RESULTS, ImmutableMap.of("correlationAttribute", idmAttributeName, "value", value));
}
if (entities.size() == 1) {
return entities.get(0);
}
return null;
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultAuthorizationManagerIntegrationTest method testPredicate.
@Test
public void testPredicate() {
loginAsAdmin();
// prepare role
IdmRoleDto role = getHelper().createRole();
getHelper().createUuidPolicy(role.getId(), role.getId(), IdmBasePermission.READ);
getHelper().createBasePolicy(role.getId(), IdmBasePermission.AUTOCOMPLETE);
// prepare identity
IdmIdentityDto identity = getHelper().createIdentity();
identity.setPassword(new GuardedString("heslo"));
identityService.save(identity);
// assign role
getHelper().createIdentityRole(identity, role);
logout();
//
// empty without login
IdmRoleFilter filter = new IdmRoleFilter();
assertEquals(0, roleService.find(filter, null, IdmBasePermission.READ).getTotalElements());
assertEquals(0, roleService.find(filter, null, IdmBasePermission.AUTOCOMPLETE).getTotalElements());
//
try {
getHelper().login(identity);
//
// evaluate access
assertEquals(1, roleService.find(filter, null, IdmBasePermission.READ).getTotalElements());
assertEquals(roleService.find(null).getTotalElements(), roleService.find(filter, null, IdmBasePermission.AUTOCOMPLETE).getTotalElements());
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class RoleForRequestEvaluatorIntegrationTest method getRoleAsUser.
private Page<IdmRoleDto> getRoleAsUser(IdmIdentityDto user, IdmRoleDto role) {
try {
loginService.login(new LoginDto(user.getUsername(), new GuardedString(TEST_PWD)));
//
IdmRoleFilter rf = getRoleFilter("code", role.getCode());
Page<IdmRoleDto> readRole = roleService.find(rf, null, IdmBasePermission.READ);
return readRole;
} finally {
logout();
}
}
Aggregations