Search in sources :

Example 61 with Entry

use of org.opends.server.types.Entry in project midpoint by Evolveum.

the class ConsistencyTest method test400GetDiscoveryAddCommunicationProblemAlreadyExists.

//TODO: enable after notify failure will be implemented..
@Test(enabled = false)
public void test400GetDiscoveryAddCommunicationProblemAlreadyExists() throws Exception {
    final String TEST_NAME = "test400GetDiscoveryAddCommunicationProblemAlreadyExists";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    openDJController.assumeStopped();
    OperationResult parentResult = new OperationResult(TEST_NAME);
    repoAddObjectFromFile(USER_DISCOVERY_FILENAME, parentResult);
    assertUserNoAccountRef(USER_DISCOVERY_OID, parentResult);
    Task task = taskManager.createTaskInstance();
    //REQUEST_USER_MODIFY_ADD_ACCOUNT_COMMUNICATION_PROBLEM
    requestToExecuteChanges(REQUEST_USER_MODIFY_ASSIGN_ACCOUNT, USER_DISCOVERY_OID, UserType.class, task, null, parentResult);
    parentResult.computeStatus();
    display("add object communication problem result: ", parentResult);
    assertEquals("Expected success but got: " + parentResult.getStatus(), OperationResultStatus.HANDLED_ERROR, parentResult.getStatus());
    String accountOid = assertUserOneAccountRef(USER_DISCOVERY_OID);
    openDJController.start();
    assertTrue(EmbeddedUtils.isRunning());
    Entry entry = openDJController.addEntryFromLdifFile(LDIF_DISCOVERY_FILENAME);
    Entry searchResult = openDJController.searchByUid("discovery");
    OpenDJController.assertAttribute(searchResult, "l", "Caribbean");
    OpenDJController.assertAttribute(searchResult, "givenName", "discovery");
    OpenDJController.assertAttribute(searchResult, "sn", "discovery");
    OpenDJController.assertAttribute(searchResult, "cn", "discovery");
    OpenDJController.assertAttribute(searchResult, "mail", "discovery@deep.in.the.caribbean.com");
    String dn = searchResult.getDN().toString();
    assertEquals("DN attribute " + dn + " not equals", dn, "uid=discovery,ou=people,dc=example,dc=com");
    modifyResourceAvailabilityStatus(AvailabilityStatusType.UP, parentResult);
    modelService.getObject(ShadowType.class, accountOid, null, task, parentResult);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Entry(org.opends.server.types.Entry) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 62 with Entry

use of org.opends.server.types.Entry in project midpoint by Evolveum.

the class TestLdap method test202AssignLdapAccountToGuybrush.

/**
	 * Just a first step for the following test.
	 * Also, Guybrush has a photo. Check that binary property mapping works.
	 */
@Test
public void test202AssignLdapAccountToGuybrush() throws Exception {
    final String TEST_NAME = "test202AssignLdapAccountToGuybrush";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestLdap.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    byte[] photoIn = Files.readAllBytes(Paths.get(DOT_JPG_FILENAME));
    display("Photo in", MiscUtil.binaryToHex(photoIn));
    modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_JPEG_PHOTO, task, result, photoIn);
    Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(UserType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
    PrismObject<UserType> userBefore = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, options, task, result);
    display("User before", userBefore);
    byte[] userJpegPhotoBefore = userBefore.asObjectable().getJpegPhoto();
    assertEquals("Photo byte length changed (user before)", photoIn.length, userJpegPhotoBefore.length);
    assertTrue("Photo bytes do not match (user before)", Arrays.equals(photoIn, userJpegPhotoBefore));
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    assignAccount(USER_GUYBRUSH_OID, RESOURCE_OPENDJ_OID, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    Entry entry = assertOpenDjAccount(USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME, true);
    byte[] jpegPhotoLdap = OpenDJController.getAttributeValueBinary(entry, "jpegPhoto");
    assertNotNull("No jpegPhoto in LDAP entry", jpegPhotoLdap);
    assertEquals("Byte length changed (LDAP)", photoIn.length, jpegPhotoLdap.length);
    assertTrue("Bytes do not match (LDAP)", Arrays.equals(photoIn, jpegPhotoLdap));
    PrismObject<UserType> userAfter = modelService.getObject(UserType.class, USER_GUYBRUSH_OID, options, task, result);
    display("User after", userAfter);
    String accountOid = getSingleLinkOid(userAfter);
    PrismObject<ShadowType> shadow = getShadowModel(accountOid);
    PrismContainer<?> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
    QName jpegPhotoQName = new QName(RESOURCE_OPENDJ_NAMESPACE, "jpegPhoto");
    PrismProperty<byte[]> jpegPhotoAttr = attributesContainer.findProperty(jpegPhotoQName);
    byte[] photoBytesOut = jpegPhotoAttr.getValues().get(0).getValue();
    display("Photo bytes out", MiscUtil.binaryToHex(photoBytesOut));
    assertEquals("Photo byte length changed (shadow)", photoIn.length, photoBytesOut.length);
    assertTrue("Photo bytes do not match (shadow)", Arrays.equals(photoIn, photoBytesOut));
    assertUsers(NUM_INITIAL_USERS);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Entry(org.opends.server.types.Entry) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 63 with Entry

use of org.opends.server.types.Entry in project midpoint by Evolveum.

the class TestLdap method loadEntries.

private void loadEntries(String prefix) throws LDIFException, IOException {
    long ldapPopStart = System.currentTimeMillis();
    for (int i = 0; i < NUM_LDAP_ENTRIES; i++) {
        String name = "user" + i;
        Entry entry = createEntry(prefix + i, name);
        openDJController.addEntry(entry);
    }
    long ldapPopEnd = System.currentTimeMillis();
    display("Loaded " + NUM_LDAP_ENTRIES + " LDAP entries (prefix " + prefix + ") in " + ((ldapPopEnd - ldapPopStart) / 1000) + " seconds");
}
Also used : Entry(org.opends.server.types.Entry)

Example 64 with Entry

use of org.opends.server.types.Entry in project midpoint by Evolveum.

the class TestGenericSynchronization method loadOpenDJ.

private int loadOpenDJ(int[] TREE_SIZE, int[] USER_COUNT, String dnSuffix, int count) throws IOException, LDIFException {
    if (TREE_SIZE.length == 0) {
        return count;
    }
    for (int i = 0; i < TREE_SIZE[0]; i++) {
        String ou = "L" + TREE_SIZE.length + "o" + i;
        String newSuffix = "ou=" + ou + ',' + dnSuffix;
        Entry org = createOrgEntry(ou, dnSuffix);
        logCreateEntry(org);
        ldapOrgCount++;
        openDJController.addEntry(org);
        count++;
        for (int u = 0; u < USER_COUNT[0]; u++) {
            // We have to make uid globally unique. Otherwise correlation takes place and it will
            // "collapse" several accounts into one user
            String uid = "L" + TREE_SIZE.length + "o" + i + "u" + u + "c" + ldapdUserCount;
            String sn = "Doe" + uid;
            Entry user = createUserEntry(uid, newSuffix, sn);
            logCreateEntry(user);
            openDJController.addEntry(user);
            ldapdUserCount++;
            count++;
        }
        count += loadOpenDJ(ArrayUtils.remove(TREE_SIZE, 0), ArrayUtils.remove(USER_COUNT, 0), newSuffix, 0);
    }
    return count;
}
Also used : Entry(org.opends.server.types.Entry)

Example 65 with Entry

use of org.opends.server.types.Entry in project midpoint by Evolveum.

the class TestGenericSynchronization method createOrgEntry.

private Entry createOrgEntry(String ou, String suffix) throws IOException, LDIFException {
    StringBuilder sb = new StringBuilder();
    String dn = "ou=" + ou + "," + suffix;
    sb.append("dn: ").append(dn).append("\n");
    sb.append("objectClass: organizationalUnit\n");
    sb.append("ou: ").append(ou).append("\n");
    sb.append("description: ").append("This is sparta! ...or " + ou).append("\n");
    LDIFImportConfig importConfig = new LDIFImportConfig(IOUtils.toInputStream(sb.toString(), "utf-8"));
    LDIFReader ldifReader = new LDIFReader(importConfig);
    Entry ldifEntry = ldifReader.readEntry();
    return ldifEntry;
}
Also used : Entry(org.opends.server.types.Entry) LDIFImportConfig(org.opends.server.types.LDIFImportConfig) LDIFReader(org.opends.server.util.LDIFReader)

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