Skip to content

Commit

Permalink
timestampPresentation test
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Aug 24, 2017
1 parent b3a1a6a commit a13ffc1
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
Expand Up @@ -539,6 +539,8 @@ private LinkedHashSet<String> getSearchAttributes() {
LinkedHashSet<String> attrs = new LinkedHashSet<String>();
attrs.add("*");
attrs.add("ds-pwp-account-disabled");
attrs.add("createTimestamp");
attrs.add("modifyTimestamp");
return attrs;
}

Expand Down
Expand Up @@ -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";
Expand Down Expand Up @@ -504,14 +506,18 @@ public void test124AssignUserLargoUnix() throws Exception {

PrismObject<UserType> 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<UserType> userAfter = findUserByUsername(USER_LARGO_USERNAME);
assertNotNull("No user after", userAfter);
display("User after", userAfter);
Expand All @@ -522,8 +528,10 @@ public void test124AssignUserLargoUnix() throws Exception {
PrismObject<ShadowType> 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";
Expand Down Expand Up @@ -2087,4 +2095,14 @@ private String assertUnixGroup(PrismObject<ShadowType> shadow, Integer expectedG

return entry.getDN().toString();
}

protected void assertModifyTimestamp(PrismObject<ShadowType> 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<ShadowType> shadow) throws Exception {
Long attributeValue = ShadowUtil.getAttributeValue(shadow, OPENDJ_MODIFY_TIMESTAMP_ATTRIBUTE_QNAME);
return attributeValue;
}
}
Expand Up @@ -22,13 +22,16 @@
import static org.testng.AssertJUnit.assertTrue;

import java.io.File;
import java.text.ParseException;
import java.util.List;

import javax.xml.namespace.QName;

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;
Expand Down Expand Up @@ -296,4 +299,17 @@ protected void assertAccountTest510(PrismObject<ShadowType> shadow) throws Excep
assertPosixAccount(shadow, null);
assertGroupAssociation(shadow, groupMonkeyIslandOid);
}

@Override
protected Long getTimestampAttribute(PrismObject<ShadowType> 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();
}
}
Expand Up @@ -54,6 +54,8 @@
<icfcldap:vlvSortAttribute>entryUUID</icfcldap:vlvSortAttribute>
<icfcldap:operationalAttributes>ds-pwp-account-disabled</icfcldap:operationalAttributes>
<icfcldap:operationalAttributes>isMemberOf</icfcldap:operationalAttributes>
<icfcldap:operationalAttributes>modifyTimestamp</icfcldap:operationalAttributes>
<icfcldap:timestampPresentation>string</icfcldap:timestampPresentation>
</icfc:configurationProperties>

<icfc:resultsHandlerConfiguration>
Expand Down
1 change: 1 addition & 0 deletions testing/story/src/test/resources/unix/resource-opendj.xml
Expand Up @@ -54,6 +54,7 @@
<icfcldap:vlvSortAttribute>entryUUID</icfcldap:vlvSortAttribute>
<icfcldap:operationalAttributes>ds-pwp-account-disabled</icfcldap:operationalAttributes>
<icfcldap:operationalAttributes>isMemberOf</icfcldap:operationalAttributes>
<icfcldap:operationalAttributes>modifyTimestamp</icfcldap:operationalAttributes>
</icfc:configurationProperties>

<icfc:resultsHandlerConfiguration>
Expand Down

0 comments on commit a13ffc1

Please sign in to comment.