Skip to content

Commit

Permalink
Tests for usePermissiveModify in LDAP connector
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Mar 16, 2016
1 parent d4f23fc commit 2699fa0
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 5 deletions.
Expand Up @@ -1046,6 +1046,62 @@ public void test145ModifyAccountJackJpegPhoto() throws Exception {

assertShadows(3);
}

/**
* Make a duplicate modification. Add a givenName value that is already there.
* Normal LDAP should fail. So check that connector and midPoitn handles that.
*/
@Test
public void test147ModifyAccountJackGivenNameDuplicit() throws Exception {
final String TEST_NAME = "test147ModifyAccountJackGivenNameDuplicit";
TestUtil.displayTestTile(TEST_NAME);

OperationResult result = new OperationResult(TestOpenDJ.class.getName()
+ "." + TEST_NAME);

PropertyDelta<String> givenNameDelta = new PropertyDelta<>(
new ItemPath(ShadowType.F_ATTRIBUTES, new QName(RESOURCE_OPENDJ_NS, "givenName")),
null , prismContext);
givenNameDelta.addValueToAdd(new PrismPropertyValue<String>("Jack"));

// Also make an ordinary non-conflicting modification. We need to make sure that
// the operation was not ignored as a whole
PropertyDelta<String> titleDelta = new PropertyDelta<>(
new ItemPath(ShadowType.F_ATTRIBUTES, new QName(RESOURCE_OPENDJ_NS, "title")),
null , prismContext);
titleDelta.addValueToAdd(new PrismPropertyValue<String>("Great Captain"));

Collection<? extends ItemDelta> modifications = MiscSchemaUtil.createCollection(givenNameDelta, titleDelta);

display("Modifications",modifications);

// WHEN
TestUtil.displayWhen(TEST_NAME);
provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID,
modifications, null, null, taskManager.createTaskInstance(), result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

Entry entry = openDJController.searchByUid("rename");
display("LDAP Entry", entry);
OpenDJController.assertAttribute(entry, "givenName", "Jack");
OpenDJController.assertAttribute(entry, "title", "Great Captain");

PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class,
ACCOUNT_JACK_OID, null, taskManager.createTaskInstance(), result);

display("Object after change",shadow);

PrismContainer<?> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
PrismAsserts.assertPropertyValue(attributesContainer, new QName(RESOURCE_OPENDJ_NS, "givenName"), "Jack");
PrismAsserts.assertPropertyValue(attributesContainer, new QName(RESOURCE_OPENDJ_NS, "title"), "Great Captain");

assertShadows(3);
}


@Test
public void test150ChangePassword() throws Exception {
Expand Down
Expand Up @@ -541,8 +541,8 @@ public void test200AssignAccountToBarbossa() throws Exception {
}

@Test
public void test210ModifyAccountBarbossaTitle() throws Exception {
final String TEST_NAME = "test210ModifyAccountBarbossaTitle";
public void test210ModifyAccountBarbossaReplaceTitle() throws Exception {
final String TEST_NAME = "test210ModifyAccountBarbossaReplaceTitle";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Expand Down Expand Up @@ -573,6 +573,43 @@ public void test210ModifyAccountBarbossaTitle() throws Exception {
assertEquals("Shadows have moved", accountBarbossaOid, shadowOid);
}

/**
* Make a duplicate modification. Add a title value that is already there.
* Normal LDAP should fail. So check that connector and midPoint handles that.
*/
@Test
public void test212ModifyAccountBarbossaAddTitleDuplicate() throws Exception {
final String TEST_NAME = "test212ModifyAccountBarbossaAddTitleDuplicate";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

ObjectDelta<ShadowType> delta = ObjectDelta.createEmptyModifyDelta(ShadowType.class, accountBarbossaOid, prismContext);
QName attrQName = new QName(MidPointConstants.NS_RI, "title");
ResourceAttributeDefinition<String> attrDef = accountObjectClassDefinition.findAttributeDefinition(attrQName);
PropertyDelta<String> attrDelta = PropertyDelta.createModificationAddProperty(
new ItemPath(ShadowType.F_ATTRIBUTES, attrQName), attrDef, "Captain");
delta.addModification(attrDelta);

// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME);
assertAttribute(entry, "title", "Captain");

PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
String shadowOid = getSingleLinkOid(user);
assertEquals("Shadows have moved", accountBarbossaOid, shadowOid);
}

@Test
public void test220ModifyUserBarbossaPassword() throws Exception {
final String TEST_NAME = "test220ModifyUserBarbossaPassword";
Expand Down
Expand Up @@ -121,7 +121,7 @@ protected String getSyncTaskOid() {
@Override
protected void assertStepSyncToken(String syncTaskOid, int step, long tsStart, long tsEnd)
throws ObjectNotFoundException, SchemaException {
assertSyncToken(syncTaskOid, (Integer)(step+5));
assertSyncToken(syncTaskOid, (Integer)(step + 6));
}

}
2 changes: 1 addition & 1 deletion testing/conntest/src/test/resources/opendj/resource.xml
Expand Up @@ -284,7 +284,7 @@
</capabilities>

<consistency>
<avoidDuplicateValues>true</avoidDuplicateValues>
<avoidDuplicateValues>false</avoidDuplicateValues>
</consistency>

<synchronization>
Expand Down
3 changes: 2 additions & 1 deletion testing/conntest/src/test/resources/openldap/resource.xml
Expand Up @@ -48,6 +48,7 @@
<icfcldap:baseContext>dc=example,dc=com</icfcldap:baseContext>
<icfcldap:bindDn>cn=idm,ou=Administrators,dc=example,dc=com</icfcldap:bindDn>
<icfcldap:bindPassword><t:clearValue>secret</t:clearValue></icfcldap:bindPassword>
<icfcldap:usePermissiveModify>always</icfcldap:usePermissiveModify>
<icfcldap:pagingStrategy>auto</icfcldap:pagingStrategy>
<icfcldap:passwordHashAlgorithm>SSHA</icfcldap:passwordHashAlgorithm>
<icfcldap:vlvSortAttribute>uid</icfcldap:vlvSortAttribute>
Expand Down Expand Up @@ -275,7 +276,7 @@
</schemaHandling>

<consistency>
<avoidDuplicateValues>true</avoidDuplicateValues>
<avoidDuplicateValues>false</avoidDuplicateValues>
</consistency>

<synchronization>
Expand Down

0 comments on commit 2699fa0

Please sign in to comment.