Skip to content

Commit

Permalink
Extended LDAP tests in a hope to replicate group memebership DN issue…
Browse files Browse the repository at this point in the history
…. Not successful. Also some test cleanup.
  • Loading branch information
semancik committed Aug 25, 2014
1 parent 4445540 commit 26663a5
Show file tree
Hide file tree
Showing 17 changed files with 519 additions and 98 deletions.
Expand Up @@ -41,6 +41,7 @@
import java.util.jar.JarFile;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.opends.messages.Message;
import org.opends.messages.MessageBuilder;
import org.opends.server.config.ConfigException;
Expand Down Expand Up @@ -567,12 +568,24 @@ public static void assertObjectClass(SearchResultEntry response, String expected
objectClassValues.contains(expected));
}

public void assertUniqueMember(SearchResultEntry groupEntry, String accountDn) {
public void assertUniqueMember(SearchResultEntry groupEntry, String accountDn) throws DirectoryException {
Collection<String> members = getAttributeValues(groupEntry, "uniqueMember");
MidPointAsserts.assertContainsCaseIgnore("No member "+accountDn+" in group "+getDn(groupEntry),
assertContainsDn("No member "+accountDn+" in group "+getDn(groupEntry),
members, accountDn);
}

public static void assertContainsDn(String message, Collection<String> actualValues, String expectedValue) throws DirectoryException {
AssertJUnit.assertNotNull(message+", expected "+expectedValue+", got null", actualValues);
DN expectedDn = DN.decode(expectedValue);
for (String actualValue: actualValues) {
DN actualDn = DN.decode(actualValue);
if (actualDn.compareTo(expectedDn)==0) {
return;
}
}
AssertJUnit.fail(message+", expected "+expectedValue+", got "+actualValues);
}

public void assertUniqueMember(String groupDn, String accountDn) throws DirectoryException {
SearchResultEntry groupEntry = fetchEntry(groupDn);
assertUniqueMember(groupEntry, accountDn);
Expand Down Expand Up @@ -707,4 +720,18 @@ public ChangeRecordEntry executeLdifChange(String ldif) throws IOException, LDIF
return entry;
}

public String dumpEntries() throws DirectoryException {
InternalSearchOperation op = getInternalConnection().processSearch(
LDAP_SUFFIX, SearchScope.WHOLE_SUBTREE, DereferencePolicy.NEVER_DEREF_ALIASES, 100,
100, false, "(objectclass=*)", getSearchAttributes());

StringBuilder sb = new StringBuilder();
for (SearchResultEntry searchEntry: op.getSearchEntries()) {
sb.append(searchEntry.toLDIFString());
sb.append("\n");
}

return sb.toString();
}

}
Expand Up @@ -4,7 +4,8 @@

public class MidPointTestConstants {

public static File TEST_RESOURCES_DIR = new File ("src/test/resources");
public static final String TEST_RESOURCES_PATH = "src/test/resources";
public static File TEST_RESOURCES_DIR = new File (TEST_RESOURCES_PATH);
public static File OBJECTS_DIR = new File(TEST_RESOURCES_DIR, "objects");

// copied from TestProtector - unfortunately these values are needed both in prism and in other modules
Expand Down
Expand Up @@ -86,73 +86,73 @@
*/
public class AbstractInternalModelIntegrationTest extends AbstractModelIntegrationTest {

protected static final String CONNECTOR_DUMMY_FILENAME = COMMON_DIR_NAME + "/connector-dummy.xml";
protected static final String CONNECTOR_DUMMY_FILENAME = COMMON_DIR_PATH + "/connector-dummy.xml";

public static final String SYSTEM_CONFIGURATION_FILENAME = COMMON_DIR_NAME + "/system-configuration.xml";
public static final String SYSTEM_CONFIGURATION_FILENAME = COMMON_DIR_PATH + "/system-configuration.xml";
public static final String SYSTEM_CONFIGURATION_OID = SystemObjectsType.SYSTEM_CONFIGURATION.value();

public static final File USER_ADMINISTRATOR_FILE = new File(COMMON_DIR, "user-administrator.xml");
protected static final String USER_ADMINISTRATOR_NAME = "administrator";
protected static final String USER_ADMINISTRATOR_OID = "00000000-0000-0000-0000-000000000002";

protected static final String USER_JACK_FILENAME = COMMON_DIR_NAME + "/user-jack.xml";
protected static final String USER_JACK_FILENAME = COMMON_DIR_PATH + "/user-jack.xml";
protected static final String USER_JACK_OID = "c0c010c0-d34d-b33f-f00d-111111111111";
protected static final String USER_JACK_USERNAME = "jack";

protected static final String USER_BARBOSSA_FILENAME = COMMON_DIR_NAME + "/user-barbossa.xml";
protected static final String USER_BARBOSSA_FILENAME = COMMON_DIR_PATH + "/user-barbossa.xml";
protected static final String USER_BARBOSSA_OID = "c0c010c0-d34d-b33f-f00d-111111111112";

protected static final String USER_GUYBRUSH_FILENAME = COMMON_DIR_NAME + "/user-guybrush.xml";
protected static final String USER_GUYBRUSH_FILENAME = COMMON_DIR_PATH + "/user-guybrush.xml";
protected static final String USER_GUYBRUSH_OID = "c0c010c0-d34d-b33f-f00d-111111111116";

static final String USER_ELAINE_FILENAME = COMMON_DIR_NAME + "/user-elaine.xml";
static final String USER_ELAINE_FILENAME = COMMON_DIR_PATH + "/user-elaine.xml";
protected static final String USER_ELAINE_OID = "c0c010c0-d34d-b33f-f00d-11111111111e";
protected static final String USER_ELAINE_USERNAME = "elaine";

// Largo does not have a full name set, employeeType=PIRATE
protected static final String USER_LARGO_FILENAME = COMMON_DIR_NAME + "/user-largo.xml";
protected static final String USER_LARGO_FILENAME = COMMON_DIR_PATH + "/user-largo.xml";
protected static final String USER_LARGO_OID = "c0c010c0-d34d-b33f-f00d-111111111118";

public static final File ROLE_SUPERUSER_FILE = new File(COMMON_DIR, "role-superuser.xml");
protected static final String ROLE_SUPERUSER_OID = "00000000-0000-0000-0000-000000000004";

protected static final String ACCOUNT_HBARBOSSA_DUMMY_FILENAME = COMMON_DIR_NAME + "/account-hbarbossa-dummy.xml";
protected static final String ACCOUNT_HBARBOSSA_DUMMY_FILENAME = COMMON_DIR_PATH + "/account-hbarbossa-dummy.xml";
protected static final String ACCOUNT_HBARBOSSA_DUMMY_OID = "c0c010c0-d34d-b33f-f00d-222211111112";
protected static final String ACCOUNT_HBARBOSSA_DUMMY_USERNAME = "hbarbossa";

public static final File ACCOUNT_SHADOW_JACK_DUMMY_FILE = new File(COMMON_DIR, "account-shadow-jack-dummy.xml");
public static final String ACCOUNT_JACK_DUMMY_USERNAME = "jack";

public static final String ACCOUNT_HERMAN_DUMMY_FILENAME = COMMON_DIR_NAME + "/account-herman-dummy.xml";
public static final String ACCOUNT_HERMAN_DUMMY_FILENAME = COMMON_DIR_PATH + "/account-herman-dummy.xml";
public static final String ACCOUNT_HERMAN_DUMMY_OID = "22220000-2200-0000-0000-444400004444";
public static final String ACCOUNT_HERMAN_DUMMY_USERNAME = "ht";

// public static final String ACCOUNT_HERMAN_OPENDJ_FILENAME = COMMON_DIR_NAME + "/account-herman-opendj.xml";
// public static final String ACCOUNT_HERMAN_OPENDJ_OID = "22220000-2200-0000-0000-333300003333";

public static final String ACCOUNT_SHADOW_GUYBRUSH_DUMMY_FILENAME = COMMON_DIR_NAME + "/account-shadow-guybrush-dummy.xml";
public static final String ACCOUNT_SHADOW_GUYBRUSH_DUMMY_FILENAME = COMMON_DIR_PATH + "/account-shadow-guybrush-dummy.xml";
public static final String ACCOUNT_SHADOW_GUYBRUSH_OID = "22226666-2200-6666-6666-444400004444";
public static final String ACCOUNT_GUYBRUSH_DUMMY_USERNAME = "guybrush";
public static final String ACCOUNT_GUYBRUSH_DUMMY_FILENAME = COMMON_DIR_NAME + "/account-guybrush-dummy.xml";
public static final String ACCOUNT_GUYBRUSH_DUMMY_FILENAME = COMMON_DIR_PATH + "/account-guybrush-dummy.xml";

public static final String ACCOUNT_SHADOW_ELAINE_DUMMY_FILENAME = COMMON_DIR_NAME + "/account-elaine-dummy.xml";
public static final String ACCOUNT_SHADOW_ELAINE_DUMMY_FILENAME = COMMON_DIR_PATH + "/account-elaine-dummy.xml";
public static final String ACCOUNT_SHADOW_ELAINE_DUMMY_OID = "c0c010c0-d34d-b33f-f00d-22220004000e";
public static final String ACCOUNT_ELAINE_DUMMY_USERNAME = USER_ELAINE_USERNAME;

public static final File ENTITLEMENT_SHADOW_PIRATE_DUMMY_FILE = new File(COMMON_DIR, "entitlement-shadow-pirate-dummy.xml");
public static final String ENTITLEMENT_PIRATE_DUMMY_NAME = "pirate";

public static final String ACCOUNT_SHADOW_CALYPSO_DUMMY_FILENAME = COMMON_DIR_NAME + "/account-shadow-calypso-dummy.xml";
public static final String ACCOUNT_SHADOW_CALYPSO_DUMMY_FILENAME = COMMON_DIR_PATH + "/account-shadow-calypso-dummy.xml";
public static final String ACCOUNT_CALYPSO_DUMMY_USERNAME = "calypso";

public static final String RESOURCE_DUMMY_FILENAME = COMMON_DIR_NAME + "/resource-dummy.xml";
public static final String RESOURCE_DUMMY_FILENAME = COMMON_DIR_PATH + "/resource-dummy.xml";
public static final String RESOURCE_DUMMY_OID = "10000000-0000-0000-0000-000000000004";
public static final String RESOURCE_DUMMY_NAMESPACE = "http://midpoint.evolveum.com/xml/ns/public/resource/instance/10000000-0000-0000-0000-000000000004";

public static final String USER_TEMPLATE_FILENAME = COMMON_DIR_NAME + "/user-template.xml";
public static final String USER_TEMPLATE_FILENAME = COMMON_DIR_PATH + "/user-template.xml";
public static final String USER_TEMPLATE_OID = "10000000-0000-0000-0000-000000000002";

protected static final String PASSWORD_POLICY_GLOBAL_FILENAME = COMMON_DIR_NAME + "/password-policy-global.xml";
protected static final String PASSWORD_POLICY_GLOBAL_FILENAME = COMMON_DIR_PATH + "/password-policy-global.xml";
protected static final String PASSWORD_POLICY_GLOBAL_OID = "12344321-0000-0000-0000-000000000003";

protected static final String MOCK_CLOCKWORK_HOOK_URL = MidPointConstants.NS_MIDPOINT_TEST_PREFIX + "/mockClockworkHook";
Expand Down

0 comments on commit 26663a5

Please sign in to comment.