diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/ldap/OpenDJController.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/ldap/OpenDJController.java index de99fc0d28f..c66e9d5591f 100755 --- a/infra/test-util/src/main/java/com/evolveum/midpoint/test/ldap/OpenDJController.java +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/ldap/OpenDJController.java @@ -539,6 +539,8 @@ private LinkedHashSet getSearchAttributes() { LinkedHashSet attrs = new LinkedHashSet(); attrs.add("*"); attrs.add("ds-pwp-account-disabled"); + attrs.add("createTimestamp"); + attrs.add("modifyTimestamp"); return attrs; } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java index a4fe57f8c6f..61d3c9b8c64 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java @@ -98,6 +98,8 @@ public class TestUnix extends AbstractStoryTest { protected static final String OPENDJ_GIDNUMBER_ATTRIBUTE_NAME = "gidNumber"; protected static final String OPENDJ_UID_ATTRIBUTE_NAME = "uid"; protected static final String OPENDJ_LABELED_URI_ATTRIBUTE_NAME = "labeledURI"; + protected static final String OPENDJ_MODIFY_TIMESTAMP_ATTRIBUTE_NAME = "modifyTimestamp"; + protected static final QName OPENDJ_MODIFY_TIMESTAMP_ATTRIBUTE_QNAME = new QName(RESOURCE_OPENDJ_NAMESPACE, OPENDJ_MODIFY_TIMESTAMP_ATTRIBUTE_NAME); public static final File ROLE_BASIC_FILE = new File(TEST_DIR, "role-basic.xml"); public static final String ROLE_BASIC_OID = "10000000-0000-0000-0000-000000000601"; @@ -504,14 +506,18 @@ public void test124AssignUserLargoUnix() throws Exception { PrismObject userBefore = findUserByUsername(USER_LARGO_USERNAME); + long startTs = System.currentTimeMillis(); + // WHEN displayWhen(TEST_NAME); assignRole(userBefore.getOid(), ROLE_UNIX_OID); // THEN displayThen(TEST_NAME); - result.computeStatus(); - TestUtil.assertSuccess(result); + assertSuccess(result); + + long endTs = System.currentTimeMillis(); + PrismObject userAfter = findUserByUsername(USER_LARGO_USERNAME); assertNotNull("No user after", userAfter); display("User after", userAfter); @@ -522,8 +528,10 @@ public void test124AssignUserLargoUnix() throws Exception { PrismObject shadow = getShadowModel(accountOid); display("Shadow (model)", shadow); assertPosixAccount(shadow, USER_LARGO_UID_NUMBER); + + assertModifyTimestamp(shadow, startTs, endTs); } - + @Test public void test125RecomputeUserLargo() throws Exception { final String TEST_NAME = "test125RecomputeUserLargo"; @@ -2087,4 +2095,14 @@ private String assertUnixGroup(PrismObject shadow, Integer expectedG return entry.getDN().toString(); } + + protected void assertModifyTimestamp(PrismObject shadow, long startTs, long endTs) throws Exception { + Long actual = getTimestampAttribute(shadow); + TestUtil.assertBetween("Wrong modify timestamp attribute in "+shadow, startTs-1000, endTs+1000, actual); + } + + protected Long getTimestampAttribute(PrismObject shadow) throws Exception { + Long attributeValue = ShadowUtil.getAttributeValue(shadow, OPENDJ_MODIFY_TIMESTAMP_ATTRIBUTE_QNAME); + return attributeValue; + } } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java index d72ebdcad29..f9664311678 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnixTolerantAux.java @@ -22,6 +22,7 @@ import static org.testng.AssertJUnit.assertTrue; import java.io.File; +import java.text.ParseException; import java.util.List; import javax.xml.namespace.QName; @@ -29,6 +30,8 @@ import com.evolveum.midpoint.prism.delta.ItemDelta; import com.evolveum.midpoint.prism.delta.builder.DeltaBuilder; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; + +import org.apache.directory.api.util.GeneralizedTime; import org.jetbrains.annotations.Nullable; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; @@ -296,4 +299,17 @@ protected void assertAccountTest510(PrismObject shadow) throws Excep assertPosixAccount(shadow, null); assertGroupAssociation(shadow, groupMonkeyIslandOid); } + + @Override + protected Long getTimestampAttribute(PrismObject shadow) throws Exception { + String attributeValue = ShadowUtil.getAttributeValue(shadow, OPENDJ_MODIFY_TIMESTAMP_ATTRIBUTE_QNAME); + if (attributeValue == null) { + return null; + } + if (!attributeValue.endsWith("Z")) { + fail("Non-zulu timestamp: "+attributeValue); + } + GeneralizedTime gt = new GeneralizedTime(attributeValue); + return gt.getCalendar().getTimeInMillis(); + } } diff --git a/testing/story/src/test/resources/unix/resource-opendj-tolerant-aux.xml b/testing/story/src/test/resources/unix/resource-opendj-tolerant-aux.xml index 21900d174d4..5d0d17ecb54 100644 --- a/testing/story/src/test/resources/unix/resource-opendj-tolerant-aux.xml +++ b/testing/story/src/test/resources/unix/resource-opendj-tolerant-aux.xml @@ -54,6 +54,8 @@ entryUUID ds-pwp-account-disabled isMemberOf + modifyTimestamp + string diff --git a/testing/story/src/test/resources/unix/resource-opendj.xml b/testing/story/src/test/resources/unix/resource-opendj.xml index 01922a0244c..994261f508f 100644 --- a/testing/story/src/test/resources/unix/resource-opendj.xml +++ b/testing/story/src/test/resources/unix/resource-opendj.xml @@ -54,6 +54,7 @@ entryUUID ds-pwp-account-disabled isMemberOf + modifyTimestamp