Search in sources :

Example 11 with VsRequestDto

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

the class VsReqeustServiceTest 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 12 with VsRequestDto

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

the class BasicVirtualConnector method create.

@Override
public IcUidAttribute create(IcObjectClass objectClass, List<IcAttribute> attributes) {
    Assert.notNull(objectClass, "Object class cannot be null!");
    Assert.notNull(attributes, "Attributes cannot be null!");
    if (!IcObjectClassInfo.ACCOUNT.equals(objectClass.getType())) {
        throw new IcException("Only ACCOUNT object class is supported now!");
    }
    IcAttribute uidAttribute = geAttribute(attributes, IcAttributeInfo.NAME);
    if (uidAttribute == null) {
        throw new IcException("UID attribute was not found!");
    }
    Object uidValue = uidAttribute.getValue();
    if (!(uidValue instanceof String)) {
        throw new IcException(MessageFormat.format("UID attribute value [{0}] must be String!", uidValue));
    }
    // Create and execute request
    VsRequestDto request = createRequest(objectClass, attributes, (String) uidValue, VsOperationType.CREATE);
    return requestService.execute(request);
}
Also used : IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcException(eu.bcvsolutions.idm.ic.exception.IcException) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto)

Example 13 with VsRequestDto

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

the class BasicVirtualConnector method delete.

@Override
public void delete(IcUidAttribute uid, IcObjectClass objectClass) {
    Assert.notNull(objectClass, "Object class cannot be null!");
    String uidValue = validateAndGetUid(uid);
    if (!IcObjectClassInfo.ACCOUNT.equals(objectClass.getType())) {
        throw new IcException("Only ACCOUNT object class is supported now!");
    }
    // Create and execute request
    VsRequestDto request = createRequest(objectClass, null, (String) uidValue, VsOperationType.DELETE);
    requestService.execute(request);
}
Also used : IcException(eu.bcvsolutions.idm.ic.exception.IcException) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto)

Example 14 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)

Example 15 with VsRequestDto

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

the class VsReqeustServiceTest method realizeUpdateAndDeleteRequestsTest.

@Test
public void realizeUpdateAndDeleteRequestsTest() {
    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);
    // Delete identity
    identityService.delete(userOne);
    // Test read rights (none requests can be returned for UserOne)
    IdmIdentityDto userTwo = helper.createIdentity("vsUserTwo");
    super.logout();
    loginService.login(new LoginDto(userTwo.getUsername(), new GuardedString("password")));
    requests = requestService.find(requestFilter, null, IdmBasePermission.READ).getContent();
    Assert.assertEquals("We found request without correct rights!", 0, requests.size());
    // Test read rights (3 requests must be returned for UserImplementer)
    super.logout();
    loginService.login(new LoginDto(USER_IMPLEMENTER_NAME, new GuardedString("password")));
    requests = requestService.find(requestFilter, null, IdmBasePermission.READ).getContent();
    Assert.assertEquals(3, 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);
    VsRequestDto deleteRequest = requests.stream().filter(req -> VsRequestState.IN_PROGRESS == req.getState() && VsOperationType.DELETE == req.getOperationType()).findFirst().orElse(null);
    Assert.assertNotNull("Request with delete not found!", deleteRequest);
    VsRequestDto createRequest = requests.stream().filter(req -> VsRequestState.IN_PROGRESS == req.getState() && VsOperationType.CREATE == req.getOperationType()).findFirst().orElse(null);
    Assert.assertNotNull("Request with create not found!", createRequest);
    // Realize create request
    request = requestService.realize(createRequest);
    // Realize update request
    request = requestService.realize(changeRequest);
    // Realize delete request
    request = requestService.realize(deleteRequest);
    // Find only archived
    requestFilter.setOnlyArchived(Boolean.TRUE);
    requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(3, requests.size());
    boolean foundNotRealized = requests.stream().filter(req -> VsRequestState.REALIZED != req.getState()).findFirst().isPresent();
    Assert.assertTrue("Found not realized requests!", !foundNotRealized);
}
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) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) 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)

Aggregations

VsRequestDto (eu.bcvsolutions.idm.vs.dto.VsRequestDto)20 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)11 VsRequestFilter (eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter)11 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)10 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)10 Test (org.junit.Test)10 LoginDto (eu.bcvsolutions.idm.core.security.api.dto.LoginDto)9 VsAccountDto (eu.bcvsolutions.idm.vs.dto.VsAccountDto)9 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)8 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)4 IcException (eu.bcvsolutions.idm.ic.exception.IcException)4 VsConnectorObjectDto (eu.bcvsolutions.idm.vs.dto.VsConnectorObjectDto)4 IcAttribute (eu.bcvsolutions.idm.ic.api.IcAttribute)3 ArrayList (java.util.ArrayList)3 SysSystemEntityFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter)2 SysSystemService (eu.bcvsolutions.idm.acc.service.api.SysSystemService)2 IdmIdentityService (eu.bcvsolutions.idm.core.api.service.IdmIdentityService)2 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)2 IcConnectorConfiguration (eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration)2 IcUidAttribute (eu.bcvsolutions.idm.ic.api.IcUidAttribute)2