Search in sources :

Example 41 with VsRequestDto

use of eu.bcvsolutions.idm.vs.dto.VsRequestDto in project CzechIdMng by bcvsolutions.

the class DefaultVsRequestServiceIntegrationTest method filterByImplementersTest.

@Test
public void filterByImplementersTest() {
    IdmIdentityDto implementerIdentity1 = helper.createIdentity(helper.createName());
    IdmIdentityDto implementerIdentity2 = helper.createIdentity(helper.createName());
    IdmRoleDto implementerRole = helper.createRole(helper.createName());
    IdmIdentityDto userIdentity = helper.createIdentity(helper.createName());
    IdmRoleDto userRole = helper.createRole(helper.createName());
    // system with implementer by identity
    VsSystemDto vsConfig1 = new VsSystemDto();
    vsConfig1.setName(helper.createName());
    vsConfig1.setImplementers(Arrays.asList(implementerIdentity1.getId()));
    SysSystemDto system1 = helper.createVirtualSystem(vsConfig1);
    helper.createRoleSystem(userRole, system1);
    // system with implementer by role
    VsSystemDto vsConfig2 = new VsSystemDto();
    vsConfig2.setName(helper.createName());
    vsConfig2.setImplementerRoles(Arrays.asList(implementerRole.getId()));
    SysSystemDto system2 = helper.createVirtualSystem(vsConfig2);
    helper.createRoleSystem(userRole, system2);
    // assign user and implementer roles
    helper.assignRoles(helper.getPrimeContract(implementerIdentity2.getId()), false, implementerRole);
    helper.assignRoles(helper.getPrimeContract(userIdentity.getId()), false, userRole);
    // no filter used, find all requests
    VsRequestFilter requestFilter = new VsRequestFilter();
    List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
    Assert.assertTrue(requests.size() >= 2);
    // find requests defined by implementer identity
    requestFilter = new VsRequestFilter();
    requestFilter.setImplementers(Arrays.asList(implementerIdentity1.getId()));
    requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    Assert.assertEquals(requests.get(0).getSystem(), system1.getId());
    // find requests defined by implementer role
    requestFilter = new VsRequestFilter();
    requestFilter.setImplementers(Arrays.asList(implementerIdentity2.getId()));
    requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    Assert.assertEquals(requests.get(0).getSystem(), system2.getId());
    // prove that no requests are found when identity is not an implementer
    requestFilter = new VsRequestFilter();
    requestFilter.setImplementers(Arrays.asList(userIdentity.getId()));
    requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(0, requests.size());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) VsSystemDto(eu.bcvsolutions.idm.vs.dto.VsSystemDto) VsRequestFilter(eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 42 with VsRequestDto

use of eu.bcvsolutions.idm.vs.dto.VsRequestDto in project CzechIdMng by bcvsolutions.

the class DefaultVsRequestServiceIntegrationTest method createAndRealizeRequestWithNoteTest.

@Test
public void createAndRealizeRequestWithNoteTest() {
    SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
    this.assignRoleSystem(system, helper.createIdentity(USER_ONE_NAME), ROLE_ONE_NAME);
    // Find created requests
    VsRequestFilter requestFilter = new VsRequestFilter();
    requestFilter.setSystemId(system.getId());
    requestFilter.setUid(USER_ONE_NAME);
    List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    VsRequestDto request = requests.get(0);
    Assert.assertEquals(USER_ONE_NAME, request.getUid());
    Assert.assertEquals(VsOperationType.CREATE, request.getOperationType());
    Assert.assertEquals(VsRequestState.IN_PROGRESS, request.getState());
    VsAccountDto account = accountService.findByUidSystem(USER_ONE_NAME, system.getId());
    Assert.assertNull("Account must be null, because request was not realized yet!", account);
    // We try realize the request
    super.logout();
    loginService.login(new LoginDto(USER_IMPLEMENTER_NAME, new GuardedString("password")));
    String note = helper.createName();
    request = requestService.realize(request, note);
    Assert.assertEquals(VsRequestState.REALIZED, request.getState());
    account = accountService.findByUidSystem(USER_ONE_NAME, system.getId());
    Assert.assertNotNull("Account cannot be null, because request was realized!", account);
    request = requestService.get(request.getId());
    Assert.assertEquals(note, request.getReason());
}
Also used : VsAccountDto(eu.bcvsolutions.idm.vs.dto.VsAccountDto) VsRequestFilter(eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 43 with VsRequestDto

use of eu.bcvsolutions.idm.vs.dto.VsRequestDto in project CzechIdMng by bcvsolutions.

the class DefaultVsRequestServiceIntegrationTest method createMoreRequestsTest.

@Test
public void createMoreRequestsTest() {
    String changed = "changed";
    SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
    this.assignRoleSystem(system, helper.createIdentity(USER_ONE_NAME), ROLE_ONE_NAME);
    // Find created requests
    VsRequestFilter requestFilter = new VsRequestFilter();
    requestFilter.setSystemId(system.getId());
    requestFilter.setUid(USER_ONE_NAME);
    List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    VsRequestDto request = requests.get(0);
    Assert.assertEquals(USER_ONE_NAME, request.getUid());
    Assert.assertEquals(VsOperationType.CREATE, request.getOperationType());
    Assert.assertEquals(VsRequestState.IN_PROGRESS, request.getState());
    VsAccountDto account = accountService.findByUidSystem(USER_ONE_NAME, system.getId());
    Assert.assertNull("Account must be null, because request was not realized yet!", account);
    IdmIdentityDto userOne = identityService.getByUsername(USER_ONE_NAME);
    userOne.setFirstName(changed);
    userOne.setLastName(changed);
    identityService.save(userOne);
    // Duplicated save ... not invoke provisioning
    identityService.save(userOne);
    requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(2, requests.size());
    VsRequestDto changeRequest = requests.stream().filter(req -> VsRequestState.IN_PROGRESS == req.getState() && VsOperationType.UPDATE == req.getOperationType()).findFirst().orElse(null);
    Assert.assertNotNull("Request with change not found!", changeRequest);
}
Also used : VsAccountDto(eu.bcvsolutions.idm.vs.dto.VsAccountDto) VsRequestFilter(eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 44 with VsRequestDto

use of eu.bcvsolutions.idm.vs.dto.VsRequestDto in project CzechIdMng by bcvsolutions.

the class VsRequestController method getDto.

@Override
public VsRequestDto getDto(Serializable backendId) {
    VsRequestDto requestDto = super.getDto(backendId);
    // Request was not found
    if (requestDto == null) {
        return null;
    }
    // Add list of implementers
    addImplementers(requestDto);
    return requestDto;
}
Also used : VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto)

Example 45 with VsRequestDto

use of eu.bcvsolutions.idm.vs.dto.VsRequestDto in project CzechIdMng by bcvsolutions.

the class DefaultVsRequestService method createRequest.

@Override
@Transactional
public VsRequestDto createRequest(VsRequestDto req) {
    Assert.notNull(req, "Request cannot be null!");
    // Save new request
    req.setState(VsRequestState.CONCEPT);
    VsRequestDto request = this.save(req);
    return this.get(request.getId());
}
Also used : VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

VsRequestDto (eu.bcvsolutions.idm.vs.dto.VsRequestDto)50 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)37 VsRequestFilter (eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter)37 Test (org.junit.Test)35 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)29 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)27 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)26 VsAccountDto (eu.bcvsolutions.idm.vs.dto.VsAccountDto)24 LoginDto (eu.bcvsolutions.idm.core.security.api.dto.LoginDto)19 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)13 VsConnectorObjectDto (eu.bcvsolutions.idm.vs.dto.VsConnectorObjectDto)7 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)6 UUID (java.util.UUID)6 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)5 ArrayList (java.util.ArrayList)5 SysSystemEntityFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter)4 IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)4 IcObjectClass (eu.bcvsolutions.idm.ic.api.IcObjectClass)4 IcException (eu.bcvsolutions.idm.ic.exception.IcException)4 IcResultsHandler (eu.bcvsolutions.idm.ic.filter.api.IcResultsHandler)4