use of eu.bcvsolutions.idm.ic.api.IcConnectorObject in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningArchiveServiceIntegrationTest method testOperationArchivateWithMultiRemovedAttributeWithEmptyValue.
@Test
public void testOperationArchivateWithMultiRemovedAttributeWithEmptyValue() {
SysSystemDto system = getHelper().createTestResourceSystem(false);
//
IcAttribute icAttributeOne = new IcAttributeImpl(getHelper().createName(), Lists.newArrayList(""));
IcConnectorObject connectorObject = new IcConnectorObjectImpl(getHelper().createName(), new IcObjectClassImpl("__mock__"), ImmutableList.of(icAttributeOne));
//
SysProvisioningOperationDto operation = prepareProvisioningOperation(system);
operation.getProvisioningContext().setConnectorObject(connectorObject);
//
SysProvisioningArchiveDto archive = service.archive(operation);
//
List<SysProvisioningAttribute> attributes = provisioningAttributeRepository.findAllByProvisioningId(archive.getId());
//
Assert.assertEquals(1, attributes.size());
Assert.assertEquals(icAttributeOne.getName(), attributes.get(0).getName());
Assert.assertTrue(attributes.get(0).isRemoved());
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorObject in project CzechIdMng by bcvsolutions.
the class DefaultAccAccountServiceTest method getConnectorObjectTest.
@Test
public void getConnectorObjectTest() {
String userOneName = "UserOne";
String eavAttributeName = helper.getSchemaColumnName("EAV_ATTRIBUTE");
SysSystemDto system = initData();
Assert.assertNotNull(system);
IdmIdentityDto identity = helper.createIdentity();
// Create role with evaluator
IdmRoleDto role = helper.createRole();
IdmAuthorizationPolicyDto policyAccount = new IdmAuthorizationPolicyDto();
policyAccount.setRole(role.getId());
policyAccount.setGroupPermission(AccGroupPermission.ACCOUNT.getName());
policyAccount.setAuthorizableType(AccAccount.class.getCanonicalName());
policyAccount.setEvaluator(ReadAccountByIdentityEvaluator.class);
authorizationPolicyService.save(policyAccount);
// Change resources (set state on exclude) .. must be call in transaction
this.getBean().persistResource(createResource(userOneName, ZonedDateTime.now()));
AccAccountDto account = new AccAccountDto();
account.setEntityType(SystemEntityType.IDENTITY);
account.setSystem(system.getId());
account.setAccountType(AccountType.PERSONAL);
account.setUid(userOneName);
account = accountService.save(account);
AccIdentityAccountDto accountIdentityOne = new AccIdentityAccountDto();
accountIdentityOne.setIdentity(identity.getId());
accountIdentityOne.setOwnership(true);
accountIdentityOne.setAccount(account.getId());
accountIdentityOne = identityAccountService.save(accountIdentityOne);
// Assign role with evaluator
helper.createIdentityRole(identity, role);
logout();
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
IcConnectorObject connectorObject = accountService.getConnectorObject(account, IdmBasePermission.READ);
Assert.assertNotNull(connectorObject);
Assert.assertEquals(userOneName, connectorObject.getUidValue());
Assert.assertNotNull(connectorObject.getAttributeByName(eavAttributeName));
Assert.assertEquals(userOneName, connectorObject.getAttributeByName(eavAttributeName).getValue());
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorObject in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningArchiveServiceIntegrationTest method differenceObjectUpdateSingleTest.
@Test
public void differenceObjectUpdateSingleTest() {
String attrName = getHelper().createName();
IcAttributeImpl icAttributeOne = new IcAttributeImpl(attrName, "TEST1");
IcConnectorObject connObjectOld = new IcConnectorObjectImpl(getHelper().createName(), new IcObjectClassImpl("__mock__"), ImmutableList.of(icAttributeOne));
IcAttributeImpl icAttributeTwo = new IcAttributeImpl(attrName, "TEST2");
IcConnectorObject connObjectNew = new IcConnectorObjectImpl(getHelper().createName(), new IcObjectClassImpl("__mock__"), ImmutableList.of(icAttributeTwo));
List<SysAttributeDifferenceDto> diffs = service.evaluateProvisioningDifferences(connObjectOld, connObjectNew);
Assert.assertEquals(1, diffs.size());
Assert.assertFalse(diffs.get(0).isMultivalue());
Assert.assertEquals(SysValueChangeType.UPDATED, diffs.get(0).getValue().getChange());
Assert.assertEquals("TEST1", diffs.get(0).getValue().getOldValue());
Assert.assertEquals("TEST2", diffs.get(0).getValue().getValue());
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorObject in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningArchiveServiceIntegrationTest method differenceObjectAddSingleTest.
@Test
public void differenceObjectAddSingleTest() {
String attrName = getHelper().createName();
IcAttributeImpl icAttributeOne = new IcAttributeImpl(attrName, "TEST1");
IcConnectorObject connObjectNew = new IcConnectorObjectImpl(getHelper().createName(), new IcObjectClassImpl("__mock__"), ImmutableList.of(icAttributeOne));
IcConnectorObject connObjectOld = new IcConnectorObjectImpl(getHelper().createName(), new IcObjectClassImpl("__mock__"), ImmutableList.of());
List<SysAttributeDifferenceDto> diffs = service.evaluateProvisioningDifferences(connObjectOld, connObjectNew);
Assert.assertEquals(1, diffs.size());
Assert.assertFalse(diffs.get(0).isMultivalue());
Assert.assertEquals(SysValueChangeType.ADDED, diffs.get(0).getValue().getChange());
Assert.assertEquals(null, diffs.get(0).getValue().getOldValue());
Assert.assertEquals("TEST1", diffs.get(0).getValue().getValue());
}
Aggregations