use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method mainFilterTest.
@Test
public void mainFilterTest() {
IdmIdentityDto identity = helper.createIdentity();
IdmIdentityDto identity2 = helper.createIdentity();
IdmTreeNodeDto node = helper.createTreeNode();
IdmTreeNodeDto node2 = helper.createTreeNode();
IdmIdentityContractDto contract = helper.createIdentityContact(identity, node);
IdmIdentityContractDto contract2 = helper.createIdentityContact(identity2, node2);
contract.setMain(true);
service.save(contract);
contract2.setMain(false);
service.save(contract2);
IdmIdentityContractFilter filter = new IdmIdentityContractFilter();
filter.setMain(true);
Page<IdmIdentityContractDto> result = service.find(filter, null);
assertTrue(result.getContent().contains(contract));
assertFalse(result.getContent().contains(contract2));
filter.setMain(false);
result = service.find(filter, null);
assertTrue(result.getContent().contains(contract2));
assertFalse(result.getContent().contains(contract));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testReferentialIntegrityOnRole.
@Test
public void testReferentialIntegrityOnRole() {
helper.setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, false);
try {
// prepare data
IdmRoleDto role = helper.createRole();
IdmTreeNodeDto treeNode = helper.createTreeNode();
// automatic role
IdmRoleTreeNodeDto roleTreeNode = helper.createRoleTreeNode(role, treeNode, false);
//
assertNotNull(roleTreeNode.getId());
assertEquals(roleTreeNode.getId(), roleTreeNodeService.get(roleTreeNode.getId()).getId());
//
helper.deleteRole(role.getId());
//
assertNull(roleTreeNodeService.get(roleTreeNode.getId()));
} finally {
helper.setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, true);
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method identityFilterTest.
@Test
public void identityFilterTest() {
IdmIdentityDto identity = helper.createIdentity();
IdmTreeNodeDto node = helper.createTreeNode();
IdmTreeNodeDto node2 = helper.createTreeNode();
IdmIdentityContractDto contract = helper.createIdentityContact(identity, node);
IdmIdentityContractDto contract2 = helper.createIdentityContact(identity, node2);
IdmIdentityContractFilter filter = new IdmIdentityContractFilter();
filter.setIdentity(identity.getId());
Page<IdmIdentityContractDto> result = service.find(filter, null);
assertEquals("Wrong Identity", 3, result.getTotalElements());
assertTrue(result.getContent().contains(service.getPrimeContract(identity.getId())));
assertTrue(result.getContent().contains(contract));
assertTrue(result.getContent().contains(contract2));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class RoleTransitiveEvaluatorsIntegrationTest method createIdentityWithRole.
private IdmIdentityDto createIdentityWithRole(boolean transitive) {
TEST_ROLE_ID = UUID.randomUUID();
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
IdmRoleDto role = helper.createRole(TEST_ROLE_ID, null);
IdmTreeNodeDto treeNode = helper.createTreeNode();
helper.createRoleTreeNode(role, treeNode, true);
// self policy
IdmAuthorizationPolicyDto readRolePolicy = new IdmAuthorizationPolicyDto();
readRolePolicy.setPermissions(IdmBasePermission.READ);
readRolePolicy.setRole(role.getId());
readRolePolicy.setGroupPermission(CoreGroupPermission.ROLE.getName());
readRolePolicy.setAuthorizableType(IdmRole.class.getCanonicalName());
readRolePolicy.setEvaluator(CodeableEvaluator.class);
readRolePolicy.getEvaluatorProperties().put(CodeableEvaluator.PARAMETER_IDENTIFIER, role.getId());
authorizationPolicyService.save(readRolePolicy);
if (transitive) {
// create transitive policies
IdmAuthorizationPolicyDto readRoleTreeNodePolicy = new IdmAuthorizationPolicyDto();
readRoleTreeNodePolicy.setRole(role.getId());
readRoleTreeNodePolicy.setGroupPermission(CoreGroupPermission.ROLETREENODE.getName());
readRoleTreeNodePolicy.setAuthorizableType(IdmRoleTreeNode.class.getCanonicalName());
readRoleTreeNodePolicy.setEvaluator(RoleTreeNodeByRoleEvaluator.class);
authorizationPolicyService.save(readRoleTreeNodePolicy);
//
IdmAuthorizationPolicyDto readAuthoritiesPolicy = new IdmAuthorizationPolicyDto();
readAuthoritiesPolicy.setRole(role.getId());
readAuthoritiesPolicy.setGroupPermission(CoreGroupPermission.AUTHORIZATIONPOLICY.getName());
readAuthoritiesPolicy.setAuthorizableType(IdmAuthorizationPolicy.class.getCanonicalName());
readAuthoritiesPolicy.setEvaluator(AuthorizationPolicyByRoleEvaluator.class);
authorizationPolicyService.save(readAuthoritiesPolicy);
}
// prepare identity
IdmIdentityDto identity = helper.createIdentity();
identity.setPassword(new GuardedString("heslo"));
identity = identityService.save(identity);
// assign role
helper.createIdentityRole(identity, role);
logout();
//
return identity;
}
Aggregations