diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestOpenDJ.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestOpenDJ.java index 187fa88565b..0fc33c609e4 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestOpenDJ.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestOpenDJ.java @@ -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 givenNameDelta = new PropertyDelta<>( + new ItemPath(ShadowType.F_ATTRIBUTES, new QName(RESOURCE_OPENDJ_NS, "givenName")), + null , prismContext); + givenNameDelta.addValueToAdd(new PrismPropertyValue("Jack")); + + // Also make an ordinary non-conflicting modification. We need to make sure that + // the operation was not ignored as a whole + PropertyDelta titleDelta = new PropertyDelta<>( + new ItemPath(ShadowType.F_ATTRIBUTES, new QName(RESOURCE_OPENDJ_NS, "title")), + null , prismContext); + titleDelta.addValueToAdd(new PrismPropertyValue("Great Captain")); + + Collection 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 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 { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java index 5ddcd9438ca..63598430358 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapConnTest.java @@ -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 @@ -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 delta = ObjectDelta.createEmptyModifyDelta(ShadowType.class, accountBarbossaOid, prismContext); + QName attrQName = new QName(MidPointConstants.NS_RI, "title"); + ResourceAttributeDefinition attrDef = accountObjectClassDefinition.findAttributeDefinition(attrQName); + PropertyDelta 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 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"; diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDj.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDj.java index 5d7303c985d..54ed335d30d 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDj.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestOpenDj.java @@ -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)); } } diff --git a/testing/conntest/src/test/resources/opendj/resource.xml b/testing/conntest/src/test/resources/opendj/resource.xml index 2839ccc3b61..82e4783e2ae 100644 --- a/testing/conntest/src/test/resources/opendj/resource.xml +++ b/testing/conntest/src/test/resources/opendj/resource.xml @@ -284,7 +284,7 @@ - true + false diff --git a/testing/conntest/src/test/resources/openldap/resource.xml b/testing/conntest/src/test/resources/openldap/resource.xml index f6923716b63..d0807f3df6a 100644 --- a/testing/conntest/src/test/resources/openldap/resource.xml +++ b/testing/conntest/src/test/resources/openldap/resource.xml @@ -48,6 +48,7 @@ dc=example,dc=com cn=idm,ou=Administrators,dc=example,dc=com secret + always auto SSHA uid @@ -275,7 +276,7 @@ - true + false