Skip to content

Commit

Permalink
Finishing the story test
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Apr 15, 2014
1 parent 409e5c6 commit a34bc26
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 17 deletions.
Expand Up @@ -124,10 +124,10 @@ protected List<V> transformSingleValue(ExpressionVariables variables, PlusMinusZ
ExpressionEvaluationContext params, String contextDescription, Task task, OperationResult result)
throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("transformSingleValue in {}\nvariables:\n{}\nvalueDestination: {}\nuseNew: {}",
new Object[]{contextDescription, variables.debugDump(1), valueDestination, useNew});
}
// if (LOGGER.isTraceEnabled()) {
// LOGGER.trace("transformSingleValue in {}\nvariables:\n{}\nvalueDestination: {}\nuseNew: {}",
// new Object[]{contextDescription, variables.debugDump(1), valueDestination, useNew});
// }

QName targetTypeQName = getExpressionEvaluatorType().getTargetType();
if (targetTypeQName == null) {
Expand Down
Expand Up @@ -215,6 +215,9 @@ public class TestVillage extends AbstractStoryTest {
private static final String ACCOUNT_TELEKE_USERNAME = "tőlőkë";
private static final String ACCOUNT_TELEKE_FIST_NAME = "Félix";
private static final String ACCOUNT_TELEKE_LAST_NAME = "Tőlőkë";

private static final File GROUP_GOV_MONKEY_ISLAND_LDIF_FILE = new File(TEST_DIR, "group-gov-monkey-island.ldif");
private static final File GROUP_EXEC_MONKEY_ISLAND_LDIF_FILE = new File(TEST_DIR, "group-exec-monkey-island.ldif");

protected static DummyResource dummyResourceSrc;
protected static DummyResourceContoller dummyResourceCtlSrc;
Expand Down Expand Up @@ -263,6 +266,10 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
// Role
importObjectFromFile(ROLE_BASIC_FILE, initResult);

// LDAP content
openDJController.addEntryFromLdifFile(GROUP_GOV_MONKEY_ISLAND_LDIF_FILE);
openDJController.addEntryFromLdifFile(GROUP_EXEC_MONKEY_ISLAND_LDIF_FILE);

// Tasks
importObjectFromFile(TASK_LIVE_SYNC_DUMMY_SOURCE_FILE, initResult);

Expand Down Expand Up @@ -312,15 +319,6 @@ public void test100AddSrcAccountHerman() throws Exception {
assertAccount(user, RESOURCE_DUMMY_SOURCE_OID);
assertAssignments(user, 0);
}

private void assertLocGov(PrismObject<UserType> user, String expLoc, String expOrg) {
UserType userType = user.asObjectable();
PrismAsserts.assertEqualsPolyString("Wrong locality in "+user, expLoc, userType.getLocality());
PrismAsserts.assertEqualsCollectionUnordered("Wrong organization in "+user, userType.getOrganization(),
PrismTestUtil.createPolyStringType(expOrg));
PrismAsserts.assertEqualsCollectionUnordered("Wrong organizationalUnit in "+user, userType.getOrganizationalUnit(),
PrismTestUtil.createPolyStringType(expOrg+":"+expLoc));
}

@Test
public void test102HermanAssignBasicRole() throws Exception {
Expand All @@ -337,6 +335,7 @@ public void test102HermanAssignBasicRole() throws Exception {
PrismObject<UserType> userAfter = getUser(user.getOid());
assertUserLdap(userAfter, ACCOUNT_HERMAN_FIST_NAME, ACCOUNT_HERMAN_LAST_NAME);
assertLocGov(userAfter, ACCOUNT_HERMAN_LOC, ACCOUNT_HERMAN_ORG);
assertLdapLocGov(userAfter, ACCOUNT_HERMAN_LOC, ACCOUNT_HERMAN_ORG);
}

@Test
Expand All @@ -360,6 +359,16 @@ public void test110AddSrcAccountLemonhead() throws Exception {
PrismObject<UserType> userAfter = findUserByUsername(USER_LEMONHEAD_NAME);
assertUserLdap(userAfter, ACCOUNT_LEMONHEAD_FIST_NAME, ACCOUNT_LEMONHEAD_LAST_NAME);
assertLocGov(userAfter, ACCOUNT_LEMONHEAD_LOC, ACCOUNT_LEMONHEAD_ORG);
assertLdapLocGov(userAfter, ACCOUNT_LEMONHEAD_LOC, ACCOUNT_LEMONHEAD_ORG);
}

private void assertLocGov(PrismObject<UserType> user, String expLoc, String expOrg) {
UserType userType = user.asObjectable();
PrismAsserts.assertEqualsPolyString("Wrong locality in "+user, expLoc, userType.getLocality());
PrismAsserts.assertEqualsCollectionUnordered("Wrong organization in "+user, userType.getOrganization(),
PrismTestUtil.createPolyStringType(expOrg));
PrismAsserts.assertEqualsCollectionUnordered("Wrong organizationalUnit in "+user, userType.getOrganizationalUnit(),
PrismTestUtil.createPolyStringType(expOrg+":"+expLoc));
}

private void assertUserLdap(PrismObject<UserType> userAfter, String firstName, String lastName) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException {
Expand All @@ -381,4 +390,18 @@ private void assertUserLdap(PrismObject<UserType> userAfter, String firstName, S
IntegrationTestTools.assertIcfsNameAttribute(shadow, "uid="+username+",ou=people,dc=example,dc=com");
}

private void assertLdapLocGov(PrismObject<UserType> user, String expLoc, String expOrg) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, DirectoryException {
UserType userType = user.asObjectable();

String groupCn = expOrg+":"+expLoc;
String groupDn = "cn="+groupCn+",ou=groups,"+openDJController.getSuffix();
SearchResultEntry groupEntry = openDJController.fetchAndAssertEntry(groupDn, "groupOfUniqueNames");
display("Group entry", groupEntry);

PrismReferenceValue accountLinkRef = getLinkRef(user, RESOURCE_OPENDJ_OID);
PrismObject<ShadowType> accountShadow = getShadowModel(accountLinkRef.getOid());
String accountDn = IntegrationTestTools.getIcfsNameAttribute(accountShadow);
openDJController.assertUniqueMember(groupEntry, accountDn);
}

}
6 changes: 3 additions & 3 deletions testing/story/src/test/resources/logback-test.xml
Expand Up @@ -49,11 +49,11 @@
<logger name="com.evolveum.midpoint.model.expr" level="TRACE" />
<logger name="com.evolveum.midpoint.model.util" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.sync" level="TRACE" />
<logger name="com.evolveum.midpoint.model.sync.CorrelationConfirmationEvaluator" level="TRACE" />
<logger name="com.evolveum.midpoint.model.sync.CorrelationConfirmationEvaluator" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning" level="DEBUG" />
<logger name="com.evolveum.midpoint.expression" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.common.expression" level="TRACE" />
<logger name="com.evolveum.midpoint.model.common.expression.Expression" level="TRACE" />
<logger name="com.evolveum.midpoint.model.common.expression" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.common.expression.Expression" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.common.mapping" level="TRACE" />
<logger name="com.evolveum.midpoint.common.monitor" level="DEBUG" />
<logger name="com.evolveum.midpoint.notifications" level="DEBUG" />
Expand Down
@@ -0,0 +1,4 @@
dn: cn=Exec:Monkey Island,ou=groups,dc=example,dc=com
cn: Gov:Monkey Island
objectclass: top
objectclass: groupOfUniqueNames
@@ -0,0 +1,4 @@
dn: cn=Gov:Monkey Island,ou=groups,dc=example,dc=com
cn: Gov:Monkey Island
objectclass: top
objectclass: groupOfUniqueNames
5 changes: 4 additions & 1 deletion testing/story/src/test/resources/village/role-basic.xml
Expand Up @@ -31,6 +31,9 @@
<association>
<ref>ri:group</ref>
<outbound>
<source>
<path>organizationalUnit</path>
</source>
<expression>
<associationTargetSearch>
<filter>
Expand All @@ -41,7 +44,7 @@
</q:path>
<expression>
<script>
<code>'cn='+user.getOrganizationalUnit()+',ou=groups,dc=example,dc=com'</code>
<code>'cn='+organizationalUnit+',ou=groups,dc=example,dc=com'</code>
</script>
</expression>
</q:equal>
Expand Down

0 comments on commit a34bc26

Please sign in to comment.