Search in sources :

Example 1 with SysSystemEntityFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.

the class VsReqeustServiceTest method changeUidTest.

@Test
public void changeUidTest() {
    SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
    IdmIdentityDto userOne = helper.createIdentity(USER_ONE_NAME);
    identityService.save(userOne);
    this.assignRoleSystem(system, userOne, ROLE_ONE_NAME);
    // Find created requests
    VsRequestFilter requestFilter = new VsRequestFilter();
    requestFilter.setSystemId(system.getId());
    requestFilter.setUid(USER_ONE_NAME);
    requestFilter.setState(VsRequestState.IN_PROGRESS);
    List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    VsRequestDto createRequest = requests.get(0);
    Assert.assertEquals(USER_ONE_NAME, createRequest.getUid());
    Assert.assertEquals(VsOperationType.CREATE, createRequest.getOperationType());
    Assert.assertEquals(VsRequestState.IN_PROGRESS, createRequest.getState());
    VsConnectorObjectDto wish = requestService.getWishConnectorObject(createRequest);
    boolean findAttributeWithouChange = wish.getAttributes().stream().filter(attribute -> !attribute.isChanged()).findFirst().isPresent();
    Assert.assertTrue(!findAttributeWithouChange);
    // Change username attributes
    userOne.setUsername(USER_ONE_CHANGED_NAME);
    // Invoke provisioning
    identityService.save(userOne);
    requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(2, requests.size());
    // We realize the create request
    super.logout();
    loginService.login(new LoginDto(USER_IMPLEMENTER_NAME, new GuardedString("password")));
    requestService.realize(createRequest);
    requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    // get wish
    wish = requestService.getWishConnectorObject(requests.get(0));
    Assert.assertEquals(1, wish.getAttributes().stream().filter(attr -> attr.isChanged()).count());
    // Find change for firstName value
    boolean findCorrectChangedUserName = wish.getAttributes().stream().filter(attr -> attr.getValue().getValue().equals(USER_ONE_CHANGED_NAME) && attr.getValue().getOldValue().equals(USER_ONE_NAME) && VsValueChangeType.UPDATED == attr.getValue().getChange()).findFirst().isPresent();
    Assert.assertTrue(findCorrectChangedUserName);
    SysSystemEntityFilter systemEntityFilter = new SysSystemEntityFilter();
    systemEntityFilter.setSystemId(system.getId());
    systemEntityFilter.setUid(USER_ONE_NAME);
    boolean oldUserNameExist = !systemEntityService.find(systemEntityFilter, null).getContent().isEmpty();
    Assert.assertTrue(oldUserNameExist);
    // Realize change username
    requestService.realize(requests.get(0));
    // We expects change UID in SystemEntity.UID
    oldUserNameExist = !systemEntityService.find(systemEntityFilter, null).getContent().isEmpty();
    Assert.assertTrue(!oldUserNameExist);
    systemEntityFilter.setUid(USER_ONE_CHANGED_NAME);
    boolean changedUserNameExist = !systemEntityService.find(systemEntityFilter, null).getContent().isEmpty();
    Assert.assertTrue(changedUserNameExist);
}
Also used : VsConnectorObjectDto(eu.bcvsolutions.idm.vs.dto.VsConnectorObjectDto) VsRequestFilter(eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) SysSystemEntityFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 2 with SysSystemEntityFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.

the class DefaultSynchronizationService method findSystemEntity.

private SysSystemEntityDto findSystemEntity(String uid, SysSystemDto system, SystemEntityType entityType) {
    SysSystemEntityFilter systemEntityFilter = new SysSystemEntityFilter();
    systemEntityFilter.setEntityType(entityType);
    systemEntityFilter.setSystemId(system.getId());
    systemEntityFilter.setUid(uid);
    List<SysSystemEntityDto> systemEntities = systemEntityService.find(systemEntityFilter, null).getContent();
    SysSystemEntityDto systemEntity = null;
    if (systemEntities.size() == 1) {
        systemEntity = systemEntities.get(0);
    } else if (systemEntities.size() > 1) {
        throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_TO_MANY_SYSTEM_ENTITY, uid);
    }
    return systemEntity;
}
Also used : ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemEntityFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter)

Example 3 with SysSystemEntityFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemEntityServiceFilterTest method testFindByText.

@Test
public void testFindByText() {
    SysSystemDto system = helper.createTestResourceSystem(false);
    SysSystemEntityDto entityOne = createEntitySystem(getHelper().createName(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
    createEntitySystem(getHelper().createName(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
    createEntitySystem(getHelper().createName(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
    // 
    SysSystemEntityFilter testFilter = new SysSystemEntityFilter();
    testFilter.setText(entityOne.getUid());
    List<SysSystemEntityDto> results = entityService.find(testFilter, null).getContent();
    Assert.assertEquals(1, results.size());
    Assert.assertEquals(entityOne.getId(), results.get(0).getId());
}
Also used : SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemEntityFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 4 with SysSystemEntityFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemEntityServiceFilterTest method testUid.

@Test
public void testUid() {
    SysSystemDto system = helper.createTestResourceSystem(false);
    SysSystemEntityDto entity1 = createEntitySystem("test1-" + System.currentTimeMillis(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
    createEntitySystem("test2-" + System.currentTimeMillis(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
    createEntitySystem("test3-" + System.currentTimeMillis(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
    // 
    SysSystemEntityFilter testFilter = new SysSystemEntityFilter();
    testFilter.setUid(entity1.getUid());
    Page<SysSystemEntityDto> pages = entityService.find(testFilter, null);
    assertEquals(1, pages.getTotalElements());
    assertEquals(entity1.getId(), pages.getContent().get(0).getId());
}
Also used : SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysSystemEntityFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 5 with SysSystemEntityFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.

the class DefaultVsRequestServiceIntegrationTest method changeUidTest.

@Test
public void changeUidTest() {
    SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
    IdmIdentityDto userOne = helper.createIdentity(USER_ONE_NAME);
    identityService.save(userOne);
    this.assignRoleSystem(system, userOne, ROLE_ONE_NAME);
    // Find created requests
    VsRequestFilter requestFilter = new VsRequestFilter();
    requestFilter.setSystemId(system.getId());
    requestFilter.setUid(USER_ONE_NAME);
    requestFilter.setState(VsRequestState.IN_PROGRESS);
    List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    VsRequestDto createRequest = requests.get(0);
    Assert.assertEquals(USER_ONE_NAME, createRequest.getUid());
    Assert.assertEquals(VsOperationType.CREATE, createRequest.getOperationType());
    Assert.assertEquals(VsRequestState.IN_PROGRESS, createRequest.getState());
    VsConnectorObjectDto wish = requestService.getWishConnectorObject(createRequest);
    boolean findAttributeWithouChange = wish.getAttributes().stream().filter(attribute -> !attribute.isChanged()).findFirst().isPresent();
    Assert.assertTrue(!findAttributeWithouChange);
    // Change username attributes
    userOne.setUsername(USER_ONE_CHANGED_NAME);
    // Invoke provisioning
    identityService.save(userOne);
    requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(2, requests.size());
    // We realize the create request
    super.logout();
    loginService.login(new LoginDto(USER_IMPLEMENTER_NAME, new GuardedString("password")));
    requestService.realize(createRequest);
    requests = requestService.find(requestFilter, null).getContent();
    Assert.assertEquals(1, requests.size());
    // get wish
    wish = requestService.getWishConnectorObject(requests.get(0));
    Assert.assertEquals(1, wish.getAttributes().stream().filter(attr -> attr.isChanged()).count());
    // Find change for firstName value
    boolean findCorrectChangedUserName = wish.getAttributes().stream().filter(attr -> attr.getValue().getValue().equals(USER_ONE_CHANGED_NAME) && attr.getValue().getOldValue().equals(USER_ONE_NAME) && SysValueChangeType.UPDATED == attr.getValue().getChange()).findFirst().isPresent();
    Assert.assertTrue(findCorrectChangedUserName);
    SysSystemEntityFilter systemEntityFilter = new SysSystemEntityFilter();
    systemEntityFilter.setSystemId(system.getId());
    systemEntityFilter.setUid(USER_ONE_NAME);
    boolean oldUserNameExist = !systemEntityService.find(systemEntityFilter, null).getContent().isEmpty();
    Assert.assertTrue(oldUserNameExist);
    // Realize change username
    requestService.realize(requests.get(0));
    // We expects change UID in SystemEntity.UID
    oldUserNameExist = !systemEntityService.find(systemEntityFilter, null).getContent().isEmpty();
    Assert.assertTrue(!oldUserNameExist);
    systemEntityFilter.setUid(USER_ONE_CHANGED_NAME);
    boolean changedUserNameExist = !systemEntityService.find(systemEntityFilter, null).getContent().isEmpty();
    Assert.assertTrue(changedUserNameExist);
}
Also used : VsConnectorObjectDto(eu.bcvsolutions.idm.vs.dto.VsConnectorObjectDto) VsRequestFilter(eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) SysSystemEntityFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

SysSystemEntityFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter)14 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)8 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)8 Test (org.junit.Test)8 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)7 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)2 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)2 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)2 LoginDto (eu.bcvsolutions.idm.core.security.api.dto.LoginDto)2 VsConnectorObjectDto (eu.bcvsolutions.idm.vs.dto.VsConnectorObjectDto)2 VsRequestDto (eu.bcvsolutions.idm.vs.dto.VsRequestDto)2 VsRequestFilter (eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter)2 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)1 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)1 AccAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter)1 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)1 AccUniformPasswordSystemFilter (eu.bcvsolutions.idm.acc.dto.filter.AccUniformPasswordSystemFilter)1 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)1 SysSchemaObjectClassFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter)1 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)1