Search in sources :

Example 6 with IdmRoleFilter

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();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 7 with IdmRoleFilter

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));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleCatalogueRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 8 with IdmRoleFilter

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));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) RoleType(eu.bcvsolutions.idm.core.api.domain.RoleType) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 9 with IdmRoleFilter

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());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 10 with IdmRoleFilter

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));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter)17 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)13 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)13 Test (org.junit.Test)13 TestRoleResource (eu.bcvsolutions.idm.acc.entity.TestRoleResource)5 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)4 SysSyncActionLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto)4 SysSyncItemLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto)4 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)4 SysSyncActionLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncActionLogFilter)4 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)4 SysSyncItemLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncItemLogFilter)4 SysSyncLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter)4 RoleType (eu.bcvsolutions.idm.core.api.domain.RoleType)2 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)2 ImmutableList (com.google.common.collect.ImmutableList)1 TestHelper (eu.bcvsolutions.idm.acc.TestHelper)1 ReconciliationMissingAccountActionType (eu.bcvsolutions.idm.acc.domain.ReconciliationMissingAccountActionType)1 SynchronizationActionType (eu.bcvsolutions.idm.acc.domain.SynchronizationActionType)1 SynchronizationLinkedActionType (eu.bcvsolutions.idm.acc.domain.SynchronizationLinkedActionType)1