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(InitTestData.TEST_USER_1);
// prepare role
IdmRoleDto role = helper.createRole();
helper.createUuidPolicy(role.getId(), role.getId(), IdmBasePermission.READ);
helper.createBasePolicy(role.getId(), IdmBasePermission.AUTOCOMPLETE);
// prepare identity
IdmIdentityDto identity = helper.createIdentity();
identity.setPassword(new GuardedString("heslo"));
identityService.save(identity);
// assign role
helper.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 {
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
//
// 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 DefaultIdmRoleServiceIntegrationTest method catalogueFilterTest.
@Test
public void catalogueFilterTest() {
IdmRoleDto role = new IdmRoleDto();
role.setName("PetrSadloRole");
role = roleService.save(role);
IdmRoleCatalogueDto catalogue = helper.createRoleCatalogue();
IdmRoleCatalogueRoleDto catalogueRole = new IdmRoleCatalogueRoleDto();
catalogueRole.setRole(role.getId());
catalogueRole.setRoleCatalogue(catalogue.getId());
catalogueRole = idmRoleCatalogueRoleService.save(catalogueRole);
IdmRoleFilter filter = new IdmRoleFilter();
filter.setRoleCatalogueId(catalogue.getId());
Page<IdmRoleDto> result = roleService.find(filter, null);
assertEquals("Wrong catalogue", 1, result.getTotalElements());
assertTrue("Wrong catalogue id #1", result.getContent().contains(role));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleServiceIntegrationTest method typeFilterTest.
@Test
public void typeFilterTest() {
IdmRoleDto role = helper.createRole();
IdmRoleDto role2 = helper.createRole();
IdmRoleDto role3 = helper.createRole();
RoleType type = RoleType.LOGIN;
RoleType type2 = RoleType.BUSINESS;
role = roleService.get(role.getId());
role.setRoleType(type);
role = roleService.save(role);
role2 = roleService.get(role2.getId());
role2.setRoleType(type);
role2 = roleService.save(role2);
role3 = roleService.get(role3.getId());
role3.setRoleType(type2);
role3 = roleService.save(role3);
IdmRoleFilter filter = new IdmRoleFilter();
filter.setRoleType(type);
Page<IdmRoleDto> result = roleService.find(filter, null);
assertEquals("Wrong type #1", 2, result.getTotalElements());
assertTrue("Wrong type #1 contains", result.getContent().contains(role));
filter.setRoleType(type2);
result = roleService.find(filter, null);
assertEquals("Wrong type #2", 1, result.getTotalElements());
assertTrue("Wrong type #2 contains", result.getContent().contains(role3));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleServiceIntegrationTest method guaranteeFilterTest.
@Test
public void guaranteeFilterTest() {
IdmIdentityDto identity = helper.createIdentity();
IdmRoleDto role = new IdmRoleDto();
role.setName("IgnacMikinaRole");
helper.createRole();
IdmRoleGuaranteeDto roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role.getId());
roleGuarantee.setGuarantee(identity.getId());
role.setGuarantees(Lists.newArrayList(roleGuarantee));
role = roleService.save(role);
IdmRoleFilter filter = new IdmRoleFilter();
filter.setGuaranteeId(identity.getId());
Page<IdmRoleDto> result = roleService.find(filter, null);
assertEquals("Wrong guarantee", 1, result.getTotalElements());
assertEquals("Wrong guarantee id", role.getId(), result.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleServiceIntegrationTest method textFilterTest.
@Test
public void textFilterTest() {
helper.createRole("SomeName001");
helper.createRole("SomeName002");
helper.createRole("SomeName003");
helper.createRole("SomeName104");
IdmRoleDto role5 = new IdmRoleDto();
role5.setDescription("SomeName005");
role5.setName("SomeName105");
role5 = roleService.save(role5);
IdmRoleFilter filter = new IdmRoleFilter();
filter.setText("SomeName00");
Page<IdmRoleDto> result = roleService.find(filter, null);
assertEquals("Wrong text filter", 4, result.getTotalElements());
assertEquals("Wrong text filter description", true, result.getContent().contains(role5));
}
Aggregations