Search in sources :

Example 71 with IdmIdentityContractDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto in project CzechIdMng by bcvsolutions.

the class ChangeIdentityPermissionTest method testCompleteTaskByStarter.

@Test
public void testCompleteTaskByStarter() {
    // approve only by help desk
    configurationService.setValue(APPROVE_BY_SECURITY_ENABLE, "false");
    configurationService.setValue(APPROVE_BY_MANAGER_ENABLE, "false");
    configurationService.setValue(APPROVE_BY_HELPDESK_ENABLE, "true");
    configurationService.setValue(APPROVE_BY_USERMANAGER_ENABLE, "false");
    // 
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    IdmIdentityDto test1 = helper.createIdentity();
    // 
    IdmRoleDto role = helper.createRole();
    // 
    // helpdesk role and identity
    IdmRoleDto helpdeskRole = helper.createRole();
    IdmIdentityDto helpdeskIdentity = helper.createIdentity();
    // add role directly
    helper.createIdentityRole(helpdeskIdentity, helpdeskRole);
    configurationService.setValue(APPROVE_BY_HELPDESK_ROLE, helpdeskRole.getCode());
    IdmIdentityContractDto contract = helper.getPrimeContract(test1.getId());
    loginAsNoAdmin(test1.getUsername());
    IdmRoleRequestDto request = createRoleRequest(test1);
    request = roleRequestService.save(request);
    IdmConceptRoleRequestDto concept = createRoleConcept(role, contract, request);
    concept = conceptRoleRequestService.save(concept);
    roleRequestService.startRequestInternal(request.getId(), true);
    request = roleRequestService.get(request.getId());
    assertEquals(RoleRequestState.IN_PROGRESS, request.getState());
    try {
        completeTasksFromUsers(helpdeskIdentity.getUsername(), "approve");
        fail("This user: " + test1.getUsername() + " can't approve task.");
    } catch (ResultCodeException ex) {
        assertTrue(CoreResultCode.FORBIDDEN.name().equals(ex.getError().getError().getStatusEnum()));
    } catch (Exception e) {
        fail("Some problem: " + e.getLocalizedMessage());
    }
    loginAsNoAdmin(helpdeskIdentity.getUsername());
    try {
        completeTasksFromUsers(helpdeskIdentity.getUsername(), "approve");
    } catch (ResultCodeException ex) {
        fail("User has permission to approve task. Error message: " + ex.getLocalizedMessage());
    } catch (Exception e) {
        fail("Some problem: " + e.getLocalizedMessage());
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test)

Example 72 with IdmIdentityContractDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto in project CzechIdMng by bcvsolutions.

the class DefaultTestHelper method createIdentityContact.

@Override
public IdmIdentityContractDto createIdentityContact(IdmIdentityDto identity, IdmTreeNodeDto position, LocalDate validFrom, LocalDate validTill) {
    IdmIdentityContractDto contract = new IdmIdentityContractDto();
    contract.setIdentity(identity.getId());
    contract.setPosition(createName());
    contract.setWorkPosition(position == null ? null : position.getId());
    contract.setValidFrom(validFrom);
    contract.setValidTill(validTill);
    return identityContractService.save(contract);
}
Also used : IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)

Example 73 with IdmIdentityContractDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto in project CzechIdMng by bcvsolutions.

the class DefaultIdentityRoleServiceTest method roleCatalogueTest.

@Test
public void roleCatalogueTest() {
    IdmIdentityDto person = testHelper.createIdentity();
    IdmIdentityDto person2 = testHelper.createIdentity();
    IdmRoleCatalogueDto catalogue = testHelper.createRoleCatalogue();
    IdmRoleCatalogueRoleDto catalogueRole = new IdmRoleCatalogueRoleDto();
    IdmRoleCatalogueRoleDto catalogueRole2 = new IdmRoleCatalogueRoleDto();
    IdmIdentityContractDto contract = testHelper.createIdentityContact(person);
    IdmIdentityContractDto contract2 = testHelper.createIdentityContact(person2);
    IdmRoleDto role = testHelper.createRole();
    IdmRoleDto role2 = testHelper.createRole();
    catalogueRole.setRoleCatalogue(catalogue.getId());
    catalogueRole.setRole(role.getId());
    catalogueRole2.setRoleCatalogue(catalogue.getId());
    catalogueRole2.setRole(role2.getId());
    IdmIdentityRoleDto roleCover = testHelper.createIdentityRole(contract, role);
    IdmIdentityRoleDto roleCover2 = testHelper.createIdentityRole(contract2, role2);
    idmRoleCatalogueRoleService.save(catalogueRole);
    idmRoleCatalogueRoleService.save(catalogueRole2);
    IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
    filter.setRoleCatalogueId(catalogue.getId());
    Page<IdmIdentityRoleDto> result = idmIdentityRoleService.find(filter, null);
    assertEquals("Wrong CatalogueRoleId", roleCover.getId(), result.getContent().get(0).getId());
    assertEquals("Wrong CatalogueRoleId2", roleCover2.getId(), result.getContent().get(1).getId());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleCatalogueRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 74 with IdmIdentityContractDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmAutomaticRoleAttributeIntegrationTest method testRemoveLastRuleWithoutCheck.

@Test
public void testRemoveLastRuleWithoutCheck() {
    String eavCode = "testingEav";
    Long testEavIdentityValue = System.currentTimeMillis();
    UUID testEavContractValue = UUID.randomUUID();
    IdmIdentityDto identity = testHelper.createIdentity();
    IdmRoleDto role = testHelper.createRole();
    IdmIdentityContractDto primeContract = testHelper.getPrimeContract(identity.getId());
    // create two eav attributes (for identity and contract)
    IdmFormAttributeDto eavAttributeIdentity = testHelper.createEavAttribute(eavCode + System.currentTimeMillis(), IdmIdentity.class, PersistentType.LONG);
    testHelper.setEavValue(identity, eavAttributeIdentity, IdmIdentity.class, testEavIdentityValue, PersistentType.LONG);
    IdmFormAttributeDto eavAttributeContract = testHelper.createEavAttribute(eavCode + System.currentTimeMillis(), IdmIdentityContract.class, PersistentType.UUID);
    testHelper.setEavValue(primeContract, eavAttributeContract, IdmIdentityContract.class, testEavContractValue, PersistentType.UUID);
    IdmAutomaticRoleAttributeDto automaticRole = testHelper.createAutomaticRole(role.getId());
    IdmAutomaticRoleAttributeRuleDto rule1 = testHelper.createAutomaticRoleRule(automaticRole.getId(), AutomaticRoleAttributeRuleComparison.EQUALS, AutomaticRoleAttributeRuleType.IDENTITY_EAV, null, eavAttributeIdentity.getId(), testEavIdentityValue.toString());
    IdmAutomaticRoleAttributeRuleDto rule2 = testHelper.createAutomaticRoleRule(automaticRole.getId(), AutomaticRoleAttributeRuleComparison.EQUALS, AutomaticRoleAttributeRuleType.CONTRACT_EAV, null, eavAttributeContract.getId(), testEavContractValue.toString());
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByIdentity(identity.getId());
    assertEquals(0, identityRoles.size());
    this.recalculateSync(automaticRole.getId());
    identityRoles = identityRoleService.findAllByIdentity(identity.getId());
    assertEquals(1, identityRoles.size());
    automaticRoleAttributeRuleService.delete(rule1);
    this.recalculateSync(automaticRole.getId());
    identityRoles = identityRoleService.findAllByIdentity(identity.getId());
    assertEquals(1, identityRoles.size());
    automaticRoleAttributeRuleService.delete(rule2);
    // in this case we not able remove the last automatic role from identity
    identityRoles = identityRoleService.findAllByIdentity(identity.getId());
    assertEquals(0, identityRoles.size());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmAutomaticRoleAttributeRuleDto(eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeRuleDto) UUID(java.util.UUID) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmAutomaticRoleAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 75 with IdmIdentityContractDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmAutomaticRoleAttributeIntegrationTest method testEmptyContract.

@Test
public void testEmptyContract() {
    String testValue = "123!@#" + System.currentTimeMillis();
    IdmRoleDto role = testHelper.createRole();
    IdmAutomaticRoleAttributeDto automaticRole = testHelper.createAutomaticRole(role.getId());
    testHelper.createAutomaticRoleRule(automaticRole.getId(), AutomaticRoleAttributeRuleComparison.EQUALS, AutomaticRoleAttributeRuleType.IDENTITY, IdmIdentity_.description.getName(), null, testValue);
    // 
    IdmIdentityDto identity = testHelper.createIdentity();
    // 
    // remove contract
    IdmIdentityContractDto primeContract = identityContractService.getPrimeContract(identity.getId());
    identityContractService.delete(primeContract);
    primeContract = identityContractService.getPrimeContract(identity.getId());
    assertNull(primeContract);
    // 
    identity.setDescription(testValue);
    identity = identityService.save(identity);
    // 
    List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByIdentity(identity.getId());
    assertEquals(0, identityRoles.size());
    // change value and recalculate
    identity.setDescription(testValue + "-test");
    identity = identityService.save(identity);
    // 
    identityRoles = identityRoleService.findAllByIdentity(identity.getId());
    assertEquals(0, identityRoles.size());
    // 
    // chnage back
    identity.setDescription(testValue);
    identity = identityService.save(identity);
    // 
    identityRoles = identityRoleService.findAllByIdentity(identity.getId());
    assertEquals(0, identityRoles.size());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmAutomaticRoleAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)220 Test (org.junit.Test)170 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)156 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)92 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)91 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)53 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)48 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)45 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)44 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)36 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)35 LocalDate (org.joda.time.LocalDate)34 ArrayList (java.util.ArrayList)31 List (java.util.List)29 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)28 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)24 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)24 Transactional (org.springframework.transaction.annotation.Transactional)24 UUID (java.util.UUID)19 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)18