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