Skip to content

Commit

Permalink
fixing tests - case sensitivity issues..
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Sep 18, 2014
1 parent 4d5c589 commit 00c7025
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
Expand Up @@ -556,8 +556,6 @@ public PrismObject<ShadowType> createRepositoryShadow(PrismObject<ShadowType> sh
throws SchemaException {

ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(shadow);

normalizeAttributes(shadow, objectClassDefinition);

PrismObject<ShadowType> repoShadow = shadow.clone();
ResourceAttributeContainer repoAttributesContainer = ShadowUtil
Expand Down Expand Up @@ -608,6 +606,8 @@ public PrismObject<ShadowType> createRepositoryShadow(PrismObject<ShadowType> sh
if (repoShadowType.isProtectedObject() != null){
repoShadowType.setProtectedObject(null);
}

normalizeAttributes(repoShadow, objectClassDefinition);

return repoShadow;
}
Expand Down
Expand Up @@ -929,7 +929,7 @@ public void test016addAccountDirrectAlreadyExists() throws Exception {
ShadowType.class, abombaOid, null, parentResult)
.asObjectable();
assertShadowName(abombaShadow,
"uid=abomba,ou=people,dc=example,dc=com");
"uid=abomba,OU=people,DC=example,DC=com");

// assertAttribute(abombaShadow, SchemaConstants.ICFS_NAME, "uid=abomba,OU=people,DC=example,DC=com");

Expand All @@ -944,7 +944,7 @@ public void test016addAccountDirrectAlreadyExists() throws Exception {
ShadowType.class, abomOid, null, parentResult)
.asObjectable();
assertShadowName(abomShadow,
"uid=abomba1,ou=people,dc=example,dc=com");
"uid=abomba1,OU=people,DC=example,DC=com");

ReferenceDelta abombaDeleteAccDelta = ReferenceDelta
.createModificationDelete(ShadowType.class,
Expand Down Expand Up @@ -991,7 +991,7 @@ public void test016addAccountDirrectAlreadyExists() throws Exception {
ShadowType.class, abombaOid2, null, result)
.asObjectable();
assertShadowName(abombaShadow2,
"uid=abomba,ou=people,dc=example,dc=com");
"uid=abomba,OU=people,DC=example,DC=com");


result.computeStatus();
Expand Down
Expand Up @@ -15,6 +15,8 @@
*/
package com.evolveum.midpoint.testing.sanity;

import static com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString;
import static com.evolveum.midpoint.prism.util.PrismAsserts.assertParentConsistency;
import static com.evolveum.midpoint.test.IntegrationTestTools.assertAttribute;
import static com.evolveum.midpoint.test.IntegrationTestTools.assertAttributeNotNull;
import static com.evolveum.midpoint.test.IntegrationTestTools.assertNoRepoCache;
Expand Down Expand Up @@ -48,12 +50,6 @@
import javax.xml.namespace.QName;
import javax.xml.ws.Holder;

import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.xnode.PrimitiveXNode;
import com.evolveum.midpoint.prism.xnode.XNode;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.opends.server.core.ModifyOperation;
Expand All @@ -69,6 +65,7 @@
import org.opends.server.types.SearchResultEntry;
import org.opends.server.types.SearchScope;
import org.opends.server.util.ChangeRecordEntry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
Expand All @@ -85,6 +82,7 @@
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
Expand All @@ -94,6 +92,8 @@
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.delta.PropertyDelta;
import com.evolveum.midpoint.prism.match.MatchingRule;
import com.evolveum.midpoint.prism.match.MatchingRuleRegistry;
import com.evolveum.midpoint.prism.match.StringIgnoreCaseMatchingRule;
import com.evolveum.midpoint.prism.parser.util.XNodeProcessorUtil;
import com.evolveum.midpoint.prism.path.ItemPath;
Expand All @@ -103,6 +103,8 @@
import com.evolveum.midpoint.prism.util.PrismAsserts;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.prism.xnode.MapXNode;
import com.evolveum.midpoint.prism.xnode.PrimitiveXNode;
import com.evolveum.midpoint.prism.xnode.XNode;
import com.evolveum.midpoint.provisioning.ucf.impl.ConnectorFactoryIcfImpl;
import com.evolveum.midpoint.schema.CapabilityUtil;
import com.evolveum.midpoint.schema.DeltaConvertor;
Expand Down Expand Up @@ -139,6 +141,7 @@
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.PropertyReferenceListType;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.SelectorQualifiedGetOptionsType;
Expand All @@ -148,6 +151,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
Expand Down Expand Up @@ -345,6 +349,9 @@ public class TestSanity extends AbstractModelIntegrationTest {

private int lastSyncToken;

@Autowired(required = true)
private MatchingRuleRegistry matchingRuleRegistry;

// This will get called from the superclass to init the repository
// It will be called only once
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
Expand Down Expand Up @@ -671,7 +678,7 @@ public void test002AddDerbyResource() throws Exception {
assertNoRepoCache();

PrismObject<ResourceType> resource = PrismTestUtil.parseObject(new File(RESOURCE_DERBY_FILENAME));
PrismAsserts.assertParentConsistency(resource);
assertParentConsistency(resource);
fillInConnectorRef(resource, IntegrationTestTools.DBTABLE_CONNECTOR_TYPE, result);

OperationResultType resultType = new OperationResultType();
Expand Down Expand Up @@ -958,11 +965,11 @@ public void test010AddUser() throws Exception {

PrismObject<UserType> user = PrismTestUtil.parseObject(USER_JACK_FILE);
UserType userType = user.asObjectable();
PrismAsserts.assertParentConsistency(user);
assertParentConsistency(user);

// Encrypt Jack's password
protector.encrypt(userType.getCredentials().getPassword().getValue());
PrismAsserts.assertParentConsistency(user);
assertParentConsistency(user);

OperationResultType result = new OperationResultType();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(result);
Expand Down Expand Up @@ -990,7 +997,7 @@ public void test010AddUser() throws Exception {
display("repository.getObject result", repoResult);
TestUtil.assertSuccess("getObject has failed", repoResult);
AssertJUnit.assertEquals(USER_JACK_OID, repoUser.getOid());
PrismAsserts.assertEqualsPolyString("fullName", userType.getFullName(), repoUser.getFullName());
assertEqualsPolyString("fullName", userType.getFullName(), repoUser.getFullName());

// TODO: better checks
}
Expand Down Expand Up @@ -1296,7 +1303,7 @@ public void test016ProvisioningSearchAccountsIterative() throws SchemaException,
// ObjectQuery q = QueryConvertor.createObjectQuery(ResourceObjectShadowType.class, query, prismContext);

final Collection<ObjectType> objects = new HashSet<ObjectType>();

final MatchingRule caseIgnoreMatchingRule = matchingRuleRegistry.getMatchingRule(StringIgnoreCaseMatchingRule.NAME, DOMUtil.XSD_STRING);
ResultHandler handler = new ResultHandler<ObjectType>() {

@Override
Expand All @@ -1316,8 +1323,7 @@ public boolean handle(PrismObject<ObjectType> prismObject, OperationResult paren
assertNotNull("No ICF UID", icfUid);
String icfName = getNormalizedAttributeValue(shadow, refinedAccountDefinition, SchemaConstants.ICFS_NAME);
assertNotNull("No ICF NAME", icfName);

assertEquals("Wrong shadow name", shadow.getName().getOrig(), icfName);
PrismAsserts.assertEquals("Wrong shadow name", caseIgnoreMatchingRule, shadow.getName().getOrig(), icfName);
assertNotNull("Missing LDAP uid", getAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "uid")));
assertNotNull("Missing LDAP cn", getAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "cn")));
assertNotNull("Missing LDAP sn", getAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "sn")));
Expand Down Expand Up @@ -1580,8 +1586,8 @@ public void test030Disable() throws IOException, JAXBException, FaultMessage,
UserType repoUserType = repoUser.asObjectable();

// Check if nothing else was modified
PrismAsserts.assertEqualsPolyString("wrong repo fullName", "Cpt. Jack Sparrow", repoUserType.getFullName());
PrismAsserts.assertEqualsPolyString("wrong repo locality", "somewhere", repoUserType.getLocality());
assertEqualsPolyString("wrong repo fullName", "Cpt. Jack Sparrow", repoUserType.getFullName());
assertEqualsPolyString("wrong repo locality", "somewhere", repoUserType.getLocality());

// Check if appropriate accountRef is still there
List<ObjectReferenceType> accountRefs = repoUserType.getLinkRef();
Expand Down Expand Up @@ -2903,7 +2909,7 @@ public void test103LiveSyncLink() throws Exception {
String accountOid = accountRefs.get(0).getOid();
ShadowType account = searchAccountByOid(accountOid);

PrismAsserts.assertEqualsPolyString("Name doesn't match", "uid=e,ou=people,dc=example,dc=com", account.getName());
assertEqualsPolyString("Name doesn't match", "uid=e,ou=People,dc=example,dc=com", account.getName());

assertAndStoreSyncTokenIncrement(syncCycle, 4);
checkAllShadows();
Expand Down Expand Up @@ -2946,7 +2952,7 @@ public void test104LiveSyncCreateNoLocation() throws Exception {
String accountOid = accountRefs.get(0).getOid();
ShadowType account = searchAccountByOid(accountOid);

PrismAsserts.assertEqualsPolyString("Name doesn't match", "uid=" + userName + ",ou=people,dc=example,dc=com", account.getName());
assertEqualsPolyString("Name doesn't match", "uid=" + userName + ",ou=People,dc=example,dc=com", account.getName());
// assertEquals("Name doesn't match", "uid=" + userName + ",ou=People,dc=example,dc=com", account.getName());
Collection<String> localities = getAttributeValues(account, new QName(IMPORT_OBJECTCLASS.getNamespaceURI(), "l"));
assertNotNull("null value list for attribute 'l'", localities);
Expand Down

0 comments on commit 00c7025

Please sign in to comment.