Search in sources :

Example 81 with Entry

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;
}
Also used : Entry(org.opends.server.types.Entry) ChangeRecordEntry(org.opends.server.util.ChangeRecordEntry) ModifyChangeRecordEntry(org.opends.server.util.ModifyChangeRecordEntry) SearchResultEntry(org.opends.server.types.SearchResultEntry) ModifyDNChangeRecordEntry(org.opends.server.util.ModifyDNChangeRecordEntry) JarEntry(java.util.jar.JarEntry) LDIFImportConfig(org.opends.server.types.LDIFImportConfig) LDIFReader(org.opends.server.util.LDIFReader) ArrayList(java.util.ArrayList)

Example 82 with Entry

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);
}
Also used : Entry(org.opends.server.types.Entry) ChangeRecordEntry(org.opends.server.util.ChangeRecordEntry) ModifyChangeRecordEntry(org.opends.server.util.ModifyChangeRecordEntry) SearchResultEntry(org.opends.server.types.SearchResultEntry) ModifyDNChangeRecordEntry(org.opends.server.util.ModifyDNChangeRecordEntry) JarEntry(java.util.jar.JarEntry) LDIFImportConfig(org.opends.server.types.LDIFImportConfig) LDIFReader(org.opends.server.util.LDIFReader)

Example 83 with Entry

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);
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) Task(com.evolveum.midpoint.task.api.Task) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) Entry(org.opends.server.types.Entry) Collection(java.util.Collection) PrismObject(com.evolveum.midpoint.prism.PrismObject) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 84 with Entry

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);
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Task(com.evolveum.midpoint.task.api.Task) Entry(org.opends.server.types.Entry) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 85 with Entry

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Entry(org.opends.server.types.Entry) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Aggregations

Entry (org.opends.server.types.Entry)87 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)45 Test (org.testng.annotations.Test)44 Task (com.evolveum.midpoint.task.api.Task)43 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)40 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)29 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)14 QName (javax.xml.namespace.QName)11 SearchResultEntry (org.opends.server.types.SearchResultEntry)11 LDIFImportConfig (org.opends.server.types.LDIFImportConfig)10 LDIFReader (org.opends.server.util.LDIFReader)10 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)9 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 JarEntry (java.util.jar.JarEntry)6 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)6 ModifyChangeRecordEntry (org.opends.server.util.ModifyChangeRecordEntry)6 ModifyDNChangeRecordEntry (org.opends.server.util.ModifyDNChangeRecordEntry)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)4