Skip to content

Commit

Permalink
Fixed handling of auxiliary object classes in provisioning (MID-4483)…
Browse files Browse the repository at this point in the history
…. Improved LDAP longtests.
  • Loading branch information
semancik committed Mar 2, 2018
1 parent b4cff8d commit dc0135a
Show file tree
Hide file tree
Showing 10 changed files with 369 additions and 188 deletions.
Expand Up @@ -934,4 +934,20 @@ public void assertPassword(String entryDn, String password) throws DirectoryExce
}
}

public void assertHasObjectClass(Entry entry, String expectedObjectclass) {
Collection<String> objectclasses = getAttributeValues(entry, "objectClass");
if (!objectclasses.contains(expectedObjectclass)) {
AssertJUnit.fail("Expected that entry "+entry.getDN()+" will have object class '"+expectedObjectclass
+"'. But it has object classes: "+objectclasses);
}
}

public void assertHasNoObjectClass(Entry entry, String expectedObjectclass) {
Collection<String> objectclasses = getAttributeValues(entry, "objectClass");
if (objectclasses.contains(expectedObjectclass)) {
AssertJUnit.fail("Expected that entry "+entry.getDN()+" will NOT have object class '"+expectedObjectclass
+"'. But it was there: "+objectclasses);
}
}

}
Expand Up @@ -799,6 +799,10 @@ public String getIdentifier() {
public String toHumanReadableDescription() {
return "auxiliary object class construction " + construction;
}
@Override
public String toString() {
return "extractor(" + toHumanReadableDescription() +")";
}
};
Collection<PrismValueDeltaSetTripleProducer<PrismPropertyValue<QName>,PrismPropertyDefinition<QName>>> col = new ArrayList<>(1);
col.add(prod);
Expand Down
Expand Up @@ -777,9 +777,9 @@ private void checkType(Object o) {
}

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Before decideIfTolerateAssociation:");
LOGGER.trace("areCValues:\n{}", DebugUtil.debugDump(areCValues));
LOGGER.trace("shouldBeCValues:\n{}", DebugUtil.debugDump(shouldBeCValues));
LOGGER.trace(" association {} before decideIfTolerateAssociation:", assocName.getLocalPart());
LOGGER.trace(" areCValues:\n{}", DebugUtil.debugDump(areCValues));
LOGGER.trace(" shouldBeCValues:\n{}", DebugUtil.debugDump(shouldBeCValues));
}

decideIfTolerateAssociation(projCtx, associationDefinition, areCValues, shouldBeCValues, associationValueMatcher,
Expand Down Expand Up @@ -928,7 +928,7 @@ private <T> void recordDelta(ValueMatcher<T> valueMatcher, LensProjectionContext
new ItemPath(parentPath, attrDef.getName()));
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Reconciliation will {} value of attribute {}: {} because {}", changeType,
LOGGER.trace(" reconciliation will {} value of attribute {}: {} because {}", changeType,
PrettyPrinter.prettyPrint(attrDef.getName()), value, reason);
}

Expand Down
Expand Up @@ -1453,22 +1453,27 @@ public boolean isRepositoryOnlyModification(Collection<? extends ItemDelta> modi
}

private boolean isResourceModification(ItemDelta itemDelta) {
if (new ItemPath(ShadowType.F_ATTRIBUTES).equivalent(itemDelta.getParentPath())) {
ItemPath path = itemDelta.getPath();
ItemPath parentPath = itemDelta.getParentPath();
if (new ItemPath(ShadowType.F_ATTRIBUTES).equivalent(parentPath)) {
return true;
}
if (new ItemPath(ShadowType.F_ASSOCIATION).equivalent(itemDelta.getParentPath())) {
if (new ItemPath(ShadowType.F_AUXILIARY_OBJECT_CLASS).equivalent(path)) {
return true;
}
if (new ItemPath(ShadowType.F_ASSOCIATION).equivalent(itemDelta.getPath())) {
if (new ItemPath(ShadowType.F_ASSOCIATION).equivalent(parentPath)) {
return true;
}
if (new ItemPath(ShadowType.F_ACTIVATION).equivalent(itemDelta.getParentPath())) {
if (new ItemPath(ShadowType.F_ASSOCIATION).equivalent(path)) {
return true;
}
if (new ItemPath(ShadowType.F_ACTIVATION).equivalent(itemDelta.getPath())) { // should not occur, but for completeness...
if (new ItemPath(ShadowType.F_ACTIVATION).equivalent(parentPath)) {
return true;
}
if (SchemaConstants.PATH_PASSWORD.equivalent(itemDelta.getParentPath())) {
if (new ItemPath(ShadowType.F_ACTIVATION).equivalent(path)) { // should not occur, but for completeness...
return true;
}
if (SchemaConstants.PATH_PASSWORD.equivalent(parentPath)) {
return true;
}
return false;
Expand Down
Expand Up @@ -121,6 +121,8 @@ public abstract class AbstractLongTest extends AbstractModelIntegrationTest {
protected static final String USER_GUYBRUSH_FULL_NAME = "Guybrush Threepwood";

public static final String DOT_JPG_FILENAME = "src/test/resources/common/dot.jpg";

protected PrismObject<UserType> userAdministrator;

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
Expand All @@ -142,10 +144,43 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
// config.asObjectable().getVersion(), initResult);

// administrator
PrismObject<UserType> userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult);
login(userAdministrator);

}

@Override
protected PrismObject<UserType> getDefaultActor() {
return userAdministrator;
}

protected Entry createLdapEntry(String uid, String name) throws IOException, LDIFException {
StringBuilder sb = new StringBuilder();
String dn = "uid="+uid+","+openDJController.getSuffixPeople();
sb.append("dn: ").append(dn).append("\n");
sb.append("objectClass: inetOrgPerson\n");
sb.append("uid: ").append(uid).append("\n");
sb.append("cn: ").append(name).append("\n");
sb.append("sn: ").append(name).append("\n");
LDIFImportConfig importConfig = new LDIFImportConfig(IOUtils.toInputStream(sb.toString(), "utf-8"));
LDIFReader ldifReader = new LDIFReader(importConfig);
Entry ldifEntry = ldifReader.readEntry();
return ldifEntry;
}

protected void loadLdapEntries(String prefix, int numEntries) throws LDIFException, IOException {
long ldapPopStart = System.currentTimeMillis();

for(int i=0; i < numEntries; i++) {
String name = "user"+i;
Entry entry = createLdapEntry(prefix+i, name);
openDJController.addEntry(entry);
}

long ldapPopEnd = System.currentTimeMillis();

display("Loaded "+numEntries+" LDAP entries in "+((ldapPopEnd-ldapPopStart)/1000)+" seconds");
}

}

0 comments on commit dc0135a

Please sign in to comment.