]
Tuyen Nguyen The updated GTNPORTAL-3583:
----------------------------------------
Status: Pull Request Sent (was: Open)
Git Pull Request:
Picketlink IDM implementation does not implement
GroupHandler#addChild() correctly
----------------------------------------------------------------------------------
Key: GTNPORTAL-3583
URL:
https://issues.jboss.org/browse/GTNPORTAL-3583
Project: GateIn Portal
Issue Type: Bug
Reporter: Tuyen Nguyen The
Assignee: Tuyen Nguyen The
Api doc of GroupHandler#addChild() tell that an exception is thrown if the method fail to
persist the new group or *there is already one child group with the same group name in the
database* or any registered listener fail to handle the event.
But the IDM implementation does not throw exception when add new groupChild same name
with existing one, it will update attribute of existing one to be the same new one.
And This test case is failure:
{code}
@Test
public void testAddDuplicateGroup() throws Exception {
/* Create a parent group with name is: GroupParent */
String parentName = "testDuplicateGroup_GroupParent";
Group groupParent = groupHandler_.createGroupInstance();
groupParent.setGroupName(parentName);
groupParent.setDescription("This is description");
groupHandler_.addChild(null, groupParent, true);
groupParent = groupHandler_.findGroupById(groupParent.getId());
/* Create a child group with name: Group1 */
Group groupChild1 = groupHandler_.createGroupInstance();
groupChild1.setGroupName("testAddDuplicateGroup");
groupChild1.setLabel("Group1 Label");
groupHandler_.addChild(groupParent, groupChild1, true);
assertEquals(groupHandler_.findGroupById(groupChild1.getId()).getLabel(),
"Group1 Label");
try {
//. Add new group with same name
Group groupChild2 = groupHandler_.createGroupInstance();
groupChild2.setGroupName("testAddDuplicateGroup");
groupChild2.setLabel("Group2 Label");
groupHandler_.addChild(groupParent, groupChild2, true);
fail("Exception should be thrown because group child is
existing");
} catch (Exception ex) {
}
assertEquals(groupHandler_.findGroupById(groupChild1.getId()).getLabel(),
"Group1 Label");
}
{code}
We should update IDM implementation of this method to align with the API doc.