use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class OpenDJController method addEntriesFromLdifFile.
public List<Entry> addEntriesFromLdifFile(String filename) throws IOException, LDIFException {
List<Entry> retval = new ArrayList<>();
LDIFImportConfig importConfig = new LDIFImportConfig(filename);
LDIFReader ldifReader = new LDIFReader(importConfig);
for (; ; ) {
Entry ldifEntry = ldifReader.readEntry();
if (ldifEntry == null) {
break;
}
addEntry(ldifEntry);
retval.add(ldifEntry);
}
return retval;
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class OpenDJController method addEntry.
public void addEntry(String ldif) throws IOException, LDIFException {
LDIFImportConfig importConfig = new LDIFImportConfig(IOUtils.toInputStream(ldif, "utf-8"));
LDIFReader ldifReader = new LDIFReader(importConfig);
Entry ldifEntry = ldifReader.readEntry();
addEntry(ldifEntry);
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class TestOpenDj method test140AddAndModifyAccountJack.
@Test
public void test140AddAndModifyAccountJack() throws Exception {
final String TEST_NAME = "test140AddAndModifyAccountJack";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
ShadowType object = unmarshallValueFromFile(ACCOUNT_JACK_FILE, ShadowType.class);
System.out.println(SchemaDebugUtil.prettyPrint(object));
System.out.println(object.asPrismObject().debugDump());
String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result);
assertEquals(ACCOUNT_JACK_OID, addedObjectOid);
ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(ACCOUNT_JACK_CHANGE_FILE, ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<ShadowType> delta = DeltaConvertor.createObjectDelta(objectChange, object.asPrismObject().getDefinition());
ItemPath icfNamePath = new ItemPath(ShadowType.F_ATTRIBUTES, getSecondaryIdentifierQName());
PrismPropertyDefinition icfNameDef = object.asPrismObject().getDefinition().findPropertyDefinition(icfNamePath);
ItemDelta renameDelta = PropertyDelta.createModificationReplaceProperty(icfNamePath, icfNameDef, "uid=rename,ou=People,dc=example,dc=com");
((Collection) delta.getModifications()).add(renameDelta);
display("Object change", delta);
// WHEN
TestUtil.displayWhen(TEST_NAME);
provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
ShadowType accountType = provisioningService.getObject(ShadowType.class, ACCOUNT_JACK_OID, null, taskManager.createTaskInstance(), result).asObjectable();
display("Object after change", accountType);
String uid = ShadowUtil.getSingleStringAttributeValue(accountType, getPrimaryIdentifierQName());
List<Object> snValues = ShadowUtil.getAttributeValues(accountType, new QName(RESOURCE_NS, "sn"));
assertNotNull("No 'sn' attribute", snValues);
assertFalse("Surname attributes must not be empty", snValues.isEmpty());
assertEquals(1, snValues.size());
//check icf_name in the shadow object fetched only from the repository
ShadowType repoShadow = repositoryService.getObject(ShadowType.class, objectChange.getOid(), null, result).asObjectable();
String name = ShadowUtil.getSingleStringAttributeValue(repoShadow, getSecondaryIdentifierQName());
assertEquals("After rename, dn is not equal.", "uid=rename,ou=people,dc=example,dc=com", name);
assertEquals("shadow name not changed after rename", "uid=rename,ou=People,dc=example,dc=com", repoShadow.getName().getOrig());
String changedSn = (String) snValues.get(0);
assertNotNull(uid);
// Check if object was modified in LDAP
Entry response = openDJController.searchAndAssertByEntryUuid(uid);
display("LDAP account", response);
OpenDJController.assertAttribute(response, "sn", "First");
assertEquals("First", changedSn);
assertShadows(3);
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class TestOpenDj method test170DisableAccount.
@Test
public void test170DisableAccount() throws Exception {
final String TEST_NAME = "test170DisableAccount";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
ShadowType object = parseObjectType(ACCOUNT_DISABLE_SIMULATED_FILE, ShadowType.class);
System.out.println(SchemaDebugUtil.prettyPrint(object));
System.out.println(object.asPrismObject().debugDump());
String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, taskManager.createTaskInstance(), result);
assertEquals(ACCOUNT_DISABLE_SIMULATED_OID, addedObjectOid);
ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(REQUEST_DISABLE_ACCOUNT_SIMULATED_FILE, ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<ShadowType> delta = DeltaConvertor.createObjectDelta(objectChange, object.asPrismObject().getDefinition());
display("Object change", delta);
// WHEN
TestUtil.displayWhen(TEST_NAME);
provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
ShadowType accountType = provisioningService.getObject(ShadowType.class, ACCOUNT_DISABLE_SIMULATED_OID, null, taskManager.createTaskInstance(), result).asObjectable();
display("Object after change", accountType);
assertEquals("The account was not disabled in the shadow", ActivationStatusType.DISABLED, accountType.getActivation().getAdministrativeStatus());
String uid = ShadowUtil.getSingleStringAttributeValue(accountType, getPrimaryIdentifierQName());
assertNotNull(uid);
// Check if object was modified in LDAP
Entry response = openDJController.searchAndAssertByEntryUuid(uid);
display("LDAP account", response);
String disabled = openDJController.getAttributeValue(response, "ds-pwp-account-disabled");
assertNotNull("no ds-pwp-account-disabled attribute in account " + uid, disabled);
display("ds-pwp-account-disabled after change: " + disabled);
assertEquals("ds-pwp-account-disabled not set to \"TRUE\"", "TRUE", disabled);
PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, ACCOUNT_DISABLE_SIMULATED_OID, null, result);
ActivationType repoActivation = repoShadow.asObjectable().getActivation();
assertNotNull("No activation in repo", repoActivation);
XMLGregorianCalendar repoDisableTimestamp = repoActivation.getDisableTimestamp();
assertNotNull("No activation disableTimestamp in repo", repoDisableTimestamp);
assertEquals("Wrong activation disableTimestamp in repo", XmlTypeConverter.createXMLGregorianCalendar(2001, 2, 3, 4, 5, 6), repoDisableTimestamp);
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class TestOpenDj method test184UnlockAccount.
@Test
public void test184UnlockAccount() throws Exception {
final String TEST_NAME = "test184UnlockAccount";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
ObjectDelta<ShadowType> delta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, prismContext, LockoutStatusType.NORMAL);
// WHEN
provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result);
// THEN
result.computeStatus();
assertSuccess(result);
PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, taskManager.createTaskInstance(), result);
display("Object after change", shadow);
String uid = ShadowUtil.getSingleStringAttributeValue(shadow.asObjectable(), getPrimaryIdentifierQName());
assertNotNull(uid);
// Check if object was modified in LDAP
Entry response = openDJController.searchAndAssertByEntryUuid(uid);
display("LDAP account", response);
String pager = openDJController.getAttributeValue(response, "pager");
assertNull("Pager attribute found in account " + uid + ": " + pager, pager);
PrismAsserts.assertPropertyValue(shadow, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, LockoutStatusType.NORMAL);
}
Aggregations