Skip to content

Commit

Permalink
Fixing disappearing of associations in case of rename on ref.integrit…
Browse files Browse the repository at this point in the history
…y-providing resource.
  • Loading branch information
mederly committed Nov 27, 2014
1 parent 31e5574 commit c6bae17
Show file tree
Hide file tree
Showing 13 changed files with 862 additions and 25 deletions.
Expand Up @@ -47,6 +47,7 @@ public class DummyConfiguration extends AbstractConfiguration {
private boolean generateDefaultValues = false;
private boolean tolerateDuplicateValues = true;
private boolean varyLetterCase = false;
private boolean referentialIntegrity = false;
private String uselessString;
private GuardedString uselessGuardedString;

Expand Down Expand Up @@ -236,7 +237,17 @@ public boolean isVaryLetterCase() {
public void setVaryLetterCase(boolean value) {
this.varyLetterCase = value;
}


@ConfigurationProperty(displayMessageKey = "UI_REFERENTIAL_INTEGRITY",
helpMessageKey = "UI_REFERENTIAL_INTEGRITY_HELP")
public boolean isReferentialIntegrity() {
return referentialIntegrity;
}

public void setReferentialIntegrity(boolean referentialIntegrity) {
this.referentialIntegrity = referentialIntegrity;
}

/**
* {@inheritDoc}
*/
Expand Down
Expand Up @@ -274,8 +274,10 @@ public Uid update(ObjectClass objectClass, Uid uid, Set<Attribute> replaceAttrib
throw new org.identityconnectors.framework.common.exceptions.UnknownUidException(e.getMessage(), e);
} catch (ObjectAlreadyExistsException e) {
throw new org.identityconnectors.framework.common.exceptions.AlreadyExistsException(e.getMessage(), e);
} catch (SchemaViolationException e) {
throw new org.identityconnectors.framework.common.exceptions.ConnectorException("Schema exception: " + e.getMessage(), e);
}
// We need to change the returned uid here (only if the mode is not set to UUID)
// We need to change the returned uid here (only if the mode is not set to UUID)
if (!(configuration.getUidMode().equals(DummyConfiguration.UID_MODE_UUID))){
uid = new Uid(newName);
}
Expand Down
Expand Up @@ -52,6 +52,10 @@ public void addMember(String newMember) throws SchemaViolationException, Connect
addAttributeValue(ATTR_MEMBERS_NAME, newMember);
}

public boolean containsMember(String member) {
return getMembers().contains(member); // TODO ok? what about case ignoring scenarios?
}

public void removeMember(String newMember) throws SchemaViolationException, ConnectException, FileNotFoundException {
removeAttributeValue(ATTR_MEMBERS_NAME, newMember);
}
Expand Down
Expand Up @@ -642,8 +642,14 @@ public void deleteAccountByName(String id) throws ObjectDoesNotExistException, C
deleteObjectByName(DummyAccount.class, accounts, id);
}

public void renameAccount(String id, String oldUsername, String newUsername) throws ObjectDoesNotExistException, ObjectAlreadyExistsException, ConnectException, FileNotFoundException {
public void renameAccount(String id, String oldUsername, String newUsername) throws ObjectDoesNotExistException, ObjectAlreadyExistsException, ConnectException, FileNotFoundException, SchemaViolationException {
renameObject(DummyAccount.class, accounts, id, oldUsername, newUsername);
for (DummyGroup group : groups.values()) {
if (group.containsMember(oldUsername)) {
group.removeMember(oldUsername);
group.addMember(newUsername);
}
}
}

public String addGroup(DummyGroup newGroup) throws ObjectAlreadyExistsException, ConnectException, FileNotFoundException, SchemaViolationException {
Expand Down
Expand Up @@ -77,4 +77,7 @@ public boolean isTolerant() {
return BooleanUtils.isNotFalse(resourceObjectAssociationType.isTolerant());
}

public boolean requiresExplicitReferentialIntegrity() {
return !BooleanUtils.isFalse(getResourceObjectAssociationType().isExplicitReferentialIntegrity()); // because default is TRUE
}
}
Expand Up @@ -136,7 +136,13 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra
protected static final String RESOURCE_DUMMY_BLACK_OID = "10000000-0000-0000-0000-000000000305";
protected static final String RESOURCE_DUMMY_BLACK_NAME = "black";
protected static final String RESOURCE_DUMMY_BLACK_NAMESPACE = MidPointConstants.NS_RI;


// Orange dummy resource for testing associations with resource-provided referential integrity
protected static final String RESOURCE_DUMMY_ORANGE_FILENAME = COMMON_DIR_PATH + "/resource-dummy-orange.xml";
protected static final String RESOURCE_DUMMY_ORANGE_OID = "10000000-0000-0000-0000-000000001104";
protected static final String RESOURCE_DUMMY_ORANGE_NAME = "orange";
protected static final String RESOURCE_DUMMY_ORANGE_NAMESPACE = MidPointConstants.NS_RI;

protected static final String RESOURCE_DUMMY_SCHEMALESS_FILENAME = COMMON_DIR_PATH + "/resource-dummy-schemaless-no-schema.xml";
protected static final String RESOURCE_DUMMY_SCHEMALESS_OID = "ef2bc95b-76e0-59e2-86d6-9999dddd0000";
protected static final String RESOURCE_DUMMY_SCHEMALESS_NAME = "schemaless";
Expand Down
Expand Up @@ -126,7 +126,12 @@ public class AbstractInitializedModelIntegrationTest extends AbstractConfiguredM
protected DummyResourceContoller dummyResourceCtlBlack;
protected ResourceType resourceDummyBlackType;
protected PrismObject<ResourceType> resourceDummyBlack;


protected DummyResource dummyResourceOrange;
protected DummyResourceContoller dummyResourceCtlOrange;
protected ResourceType resourceDummyOrangeType;
protected PrismObject<ResourceType> resourceDummyOrange;

protected ResourceType resourceDummySchemalessType;
protected PrismObject<ResourceType> resourceDummySchemaless;

Expand Down Expand Up @@ -195,7 +200,15 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
resourceDummyBlack = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_BLACK_FILENAME, RESOURCE_DUMMY_BLACK_OID, initTask, initResult);
resourceDummyBlackType = resourceDummyBlack.asObjectable();
dummyResourceCtlBlack.setResource(resourceDummyBlack);


dummyResourceCtlOrange = DummyResourceContoller.create(RESOURCE_DUMMY_ORANGE_NAME, resourceDummyOrange);
dummyResourceCtlOrange.extendSchemaPirate();
dummyResourceOrange = dummyResourceCtlOrange.getDummyResource();
resourceDummyOrange = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_ORANGE_FILENAME, RESOURCE_DUMMY_ORANGE_OID, initTask, initResult);
resourceDummyOrangeType = resourceDummyOrange.asObjectable();
dummyResourceCtlOrange.setResource(resourceDummyOrange);


resourceDummySchemaless = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_SCHEMALESS_FILENAME, RESOURCE_DUMMY_SCHEMALESS_OID, initTask, initResult);
resourceDummySchemalessType = resourceDummySchemaless.asObjectable();

Expand Down
Expand Up @@ -307,7 +307,12 @@ public void test300AddRoleWimp() throws Exception {
// assertEquals("Wrong group description", GROUP_DUMMY_LANDLUBERS_DESCRIPTION,
// dummyGroup.getAttributeValue(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION));
assertNoGroupMembers(dummyGroup);
}

DummyGroup dummyGroupAtOrange = dummyResourceOrange.getGroupByName(GROUP_DUMMY_WIMPS_NAME);
assertNotNull("No group on orange dummy resource", dummyGroupAtOrange);
display("Group @orange", dummyGroupAtOrange);
assertNoGroupMembers(dummyGroupAtOrange);
}

@Test
public void test310AssignRoleWimpToLargo() throws Exception {
Expand All @@ -332,6 +337,11 @@ public void test310AssignRoleWimpToLargo() throws Exception {
// assertEquals("Wrong group description", GROUP_DUMMY_LANDLUBERS_DESCRIPTION,
// dummyGroup.getAttributeValue(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION));
assertGroupMember(dummyGroup, USER_LARGO_USERNAME);

DummyGroup dummyGroupAtOrange = dummyResourceOrange.getGroupByName(GROUP_DUMMY_WIMPS_NAME);
assertNotNull("No group on orange dummy resource", dummyGroupAtOrange);
display("Group @orange", dummyGroupAtOrange);
assertGroupMember(dummyGroupAtOrange, USER_LARGO_USERNAME);
}

/**
Expand All @@ -340,13 +350,12 @@ public void test310AssignRoleWimpToLargo() throws Exception {
*/
@Test
public void test311RenameLargo() throws Exception {
final String TEST_NAME = "test310AssignRoleWimpToLargo";
final String TEST_NAME = "test311RenameLargo";
TestUtil.displayTestTile(this, TEST_NAME);

Task task = taskManager.createTaskInstance(TestEntitlements.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();



// WHEN
modifyUserReplace(USER_LARGO_OID, UserType.F_NAME, task, result, PrismTestUtil.createPolyString("newLargo"));

Expand All @@ -361,7 +370,12 @@ public void test311RenameLargo() throws Exception {
// dummyGroup.getAttributeValue(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION));
assertNoGroupMember(dummyGroup, USER_LARGO_USERNAME);
assertGroupMember(dummyGroup, "newLargo");
}


DummyGroup dummyGroupAtOrange = dummyResourceOrange.getGroupByName(GROUP_DUMMY_WIMPS_NAME);
assertNotNull("No group on orange dummy resource", dummyGroupAtOrange);
display("Group", dummyGroupAtOrange);
assertNoGroupMember(dummyGroupAtOrange, USER_LARGO_USERNAME);
assertGroupMember(dummyGroupAtOrange, "newLargo");
}

}

0 comments on commit c6bae17

Please sign in to comment.