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());
}
}
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);
}
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());
}
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());
}
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());
}
Aggregations