Search in sources :

Example 66 with Entry

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

the class TestLdapUniversity method loadEntries.

private void loadEntries(String prefix) throws LDIFException, IOException {
    long ldapPopStart = System.currentTimeMillis();
    final int BATCH = 200;
    final int TICK = 1000;
    //        List<String> namesToAdd = new ArrayList<>(BATCH);
    for (int i = 0; i < NUM_LDAP_ENTRIES; i++) {
        String name = "user" + i;
        Entry entry = createEntry(prefix + i, "e" + i, name);
        openDJController.addEntry(entry);
        //            }
        if ((i + 1) % TICK == 0 && (i + 1) < NUM_LDAP_ENTRIES) {
            display("Loaded " + (i + 1) + " LDAP entries in " + ((System.currentTimeMillis() - ldapPopStart) / 1000) + " seconds, continuing...");
        }
    }
    //        if (!namesToAdd.isEmpty()) {
    //            addToGroups(namesToAdd);
    //        }
    long ldapPopEnd = System.currentTimeMillis();
    display("Loaded " + NUM_LDAP_ENTRIES + " LDAP entries in " + ((ldapPopEnd - ldapPopStart) / 1000) + " seconds");
}
Also used : Entry(org.opends.server.types.Entry)

Example 67 with Entry

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

the class ConsistencyTest method test150RecomputeUserAccountNotFound.

/**
	 * Recompute user => account not found => reaction: Re-create account
	 * MID-3093
	 */
@Test
public void test150RecomputeUserAccountNotFound() throws Exception {
    final String TEST_NAME = "test150RecomputeUserAccountNotFound";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<UserType> userGuybrushFromFile = PrismTestUtil.parseObject(new File(USER_GUYBRUSH_FILENAME));
    userGuybrushFromFile.asObjectable().getLinkRef().clear();
    repoAddObject(userGuybrushFromFile, result);
    assignAccount(USER_GUYBRUSH_OID, RESOURCE_OPENDJ_OID, null);
    PrismObject<UserType> userBefore = getUser(USER_GUYBRUSH_OID);
    display("User before", userBefore);
    String accountShadowOid = assertOneAccountRef(userBefore);
    PrismObject<ShadowType> shadowBefore = getShadowModel(accountShadowOid);
    display("Model Shadow before", shadowBefore);
    String dn = ShadowUtil.getAttributeValue(shadowBefore, RESOURCE_OPENDJ_SECONDARY_IDENTIFIER);
    openDJController.delete(dn);
    PrismObject<ShadowType> repoShadowBefore = repositoryService.getObject(ShadowType.class, accountShadowOid, null, result);
    assertNotNull("Repo shadow is gone!", repoShadowBefore);
    display("Repository shadow before", repoShadowBefore);
    assertTrue("Oh my! Shadow is dead!", repoShadowBefore.asObjectable().isDead() != Boolean.TRUE);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    recomputeUser(USER_GUYBRUSH_OID, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userAfter = getUser(USER_GUYBRUSH_OID);
    display("User after", userAfter);
    String accountShadowOidAfter = assertOneAccountRef(userAfter);
    PrismObject<ShadowType> shadowAfter = getShadowModel(accountShadowOidAfter);
    display("Shadow after", shadowAfter);
    Entry entryAfter = openDJController.fetchEntry(dn);
    display("Entry after", entryAfter);
}
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) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) File(java.io.File) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 68 with Entry

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

the class TestLdapFlat method getAndAssertUser.

@Override
protected PrismObject<UserType> getAndAssertUser(String username, String directOrgGroupname, String... indirectGroupNames) throws SchemaException, CommonException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException {
    PrismObject<UserType> user = super.getAndAssertUser(username, directOrgGroupname, indirectGroupNames);
    Entry accountEntry = openDJController.searchSingle("uid=" + username);
    Entry groupEntry = openDJController.searchSingle("cn=" + directOrgGroupname);
    assertNotNull("No group LDAP entry for " + directOrgGroupname, groupEntry);
    openDJController.assertUniqueMember(groupEntry, accountEntry.getDN().toString());
    if (indirectGroupNames != null) {
        for (String expectedGroupName : indirectGroupNames) {
            groupEntry = openDJController.searchSingle("cn=" + expectedGroupName);
            assertNotNull("No group LDAP entry for " + expectedGroupName, groupEntry);
            openDJController.assertUniqueMember(groupEntry, accountEntry.getDN().toString());
        }
    }
    return user;
}
Also used : Entry(org.opends.server.types.Entry) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 69 with Entry

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

the class TestLdapHierarchical method getAndAssertFunctionalOrg.

@Override
protected PrismObject<OrgType> getAndAssertFunctionalOrg(String orgName, String directParentOrgOid) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException, ExpressionEvaluationException {
    PrismObject<OrgType> org = super.getAndAssertFunctionalOrg(orgName, directParentOrgOid);
    if (directParentOrgOid != null && !ORG_TOP_OID.equals(directParentOrgOid)) {
        Entry groupEntry = openDJController.searchSingle("cn=" + orgName);
        PrismObject<OrgType> parentOrg = getObject(OrgType.class, directParentOrgOid);
        Entry parentGroupEntry = openDJController.searchSingle("cn=" + parentOrg.getName());
        assertNotNull("No group LDAP entry for " + parentOrg.getName(), parentGroupEntry);
        display("parent group entry", openDJController.toHumanReadableLdifoid(parentGroupEntry));
        openDJController.assertUniqueMember(parentGroupEntry, groupEntry.getDN().toString());
    }
    String ouOid = getLinkRefOid(org, RESOURCE_OPENDJ_OID, ShadowKindType.GENERIC, LDAP_OU_INTENT);
    PrismObject<ShadowType> ouShadow = getShadowModel(ouOid);
    display("Org " + orgName + " ou shadow", ouShadow);
    Entry groupEntry = openDJController.searchSingle("ou=" + orgName);
    assertNotNull("No UO LDAP entry for " + orgName, groupEntry);
    display("OU entry", openDJController.toHumanReadableLdifoid(groupEntry));
    openDJController.assertObjectClass(groupEntry, "organizationalUnit");
    String expectedDn = getOuDn(org);
    assertEquals("Wrong OU DN", expectedDn, groupEntry.getDN().toString().toLowerCase());
    return org;
}
Also used : Entry(org.opends.server.types.Entry) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)

Example 70 with Entry

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

the class TestLdapNested method getAndAssertFunctionalOrg.

@Override
protected PrismObject<OrgType> getAndAssertFunctionalOrg(String orgName, String directParentOrgOid) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException, ExpressionEvaluationException {
    PrismObject<OrgType> org = super.getAndAssertFunctionalOrg(orgName, directParentOrgOid);
    if (directParentOrgOid != null && !ORG_TOP_OID.equals(directParentOrgOid)) {
        Entry groupEntry = openDJController.searchSingle("cn=" + orgName);
        PrismObject<OrgType> parentOrg = getObject(OrgType.class, directParentOrgOid);
        Entry parentGroupEntry = openDJController.searchSingle("cn=" + parentOrg.getName());
        assertNotNull("No group LDAP entry for " + parentOrg.getName(), parentGroupEntry);
        openDJController.assertUniqueMember(parentGroupEntry, groupEntry.getDN().toString());
    }
    return org;
}
Also used : Entry(org.opends.server.types.Entry) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)

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