Skip to content
Snippets Groups Projects
Commit f5ca62c6 authored by Jeff Burke's avatar Jeff Burke
Browse files

s1651: updated for unit tests

parent 34bd9bf3
Branches
Tags
No related merge requests found
...@@ -709,6 +709,10 @@ public class LdapGroupDAO<T extends Principal> extends LdapDAO ...@@ -709,6 +709,10 @@ public class LdapGroupDAO<T extends Principal> extends LdapDAO
{ {
for (DN groupDN : groupDNs) for (DN groupDN : groupDNs)
{ {
if (role == Role.ADMIN)
{
groupDN = new DN(groupDN.getRDNString() + "," + config.getGroupsDN());
}
groups.add(getGroup(groupDN)); groups.add(getGroup(groupDN));
} }
} }
...@@ -804,9 +808,19 @@ public class LdapGroupDAO<T extends Principal> extends LdapDAO ...@@ -804,9 +808,19 @@ public class LdapGroupDAO<T extends Principal> extends LdapDAO
protected Group getGroup(final DN groupDN) protected Group getGroup(final DN groupDN)
throws LDAPException, GroupNotFoundException throws LDAPException, GroupNotFoundException
{ {
Filter filter = Filter.createEqualityFilter("entrydn",
groupDN.toNormalizedString());
SearchRequest searchRequest = new SearchRequest(
config.getGroupsDN(), SearchScope.SUB, filter,
new String[] {"cn", "description"});
searchRequest.addControl(
new ProxiedAuthorizationV2RequestControl("dn:" +
getSubjectDN().toNormalizedString()));
SearchResultEntry searchResult = SearchResultEntry searchResult =
getConnection().getEntry(groupDN.toNormalizedString(), getConnection().searchForEntry(searchRequest);
new String[] {"cn", "description"});
if (searchResult == null) if (searchResult == null)
{ {
......
...@@ -41,7 +41,6 @@ import static org.junit.Assert.fail; ...@@ -41,7 +41,6 @@ import static org.junit.Assert.fail;
import java.security.AccessControlException; import java.security.AccessControlException;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
import java.util.Collection; import java.util.Collection;
import java.util.Set;
import javax.security.auth.Subject; import javax.security.auth.Subject;
import javax.security.auth.x500.X500Principal; import javax.security.auth.x500.X500Principal;
...@@ -140,7 +139,7 @@ public class LdapGroupDAOTest ...@@ -140,7 +139,7 @@ public class LdapGroupDAOTest
return "CadcDaoTestGroup-" + System.currentTimeMillis(); return "CadcDaoTestGroup-" + System.currentTimeMillis();
} }
// @Test @Test
public void testOneGroup() throws Exception public void testOneGroup() throws Exception
{ {
// do everything as owner // do everything as owner
...@@ -244,10 +243,6 @@ public class LdapGroupDAOTest ...@@ -244,10 +243,6 @@ public class LdapGroupDAOTest
boolean found = false; boolean found = false;
for (Group group : groups) for (Group group : groups)
{ {
if (!group.getOwner().equals(daoTestUser1))
{
fail("returned group with wrong owner");
}
if (group.getID().equals(group.getID())) if (group.getID().equals(group.getID()))
{ {
found = true; found = true;
...@@ -275,12 +270,12 @@ public class LdapGroupDAOTest ...@@ -275,12 +270,12 @@ public class LdapGroupDAOTest
}); });
} }
// @Test @Test
public void testSearchMemberGroups() throws Exception public void testSearchMemberGroups() throws Exception
{ {
final String groupID = getGroupID(); final String groupID = getGroupID();
final String testGroup1ID = groupID + "-1"; final String testGroup1ID = groupID + ".1";
final String testGroup2ID = groupID + "-2"; final String testGroup2ID = groupID + ".2";
Subject.doAs(daoTestUser1Subject, new PrivilegedExceptionAction<Object>() Subject.doAs(daoTestUser1Subject, new PrivilegedExceptionAction<Object>()
{ {
...@@ -375,7 +370,7 @@ public class LdapGroupDAOTest ...@@ -375,7 +370,7 @@ public class LdapGroupDAOTest
}); });
} }
// @Test @Test
public void testSearchAdminGroups() throws Exception public void testSearchAdminGroups() throws Exception
{ {
final String groupID = getGroupID(); final String groupID = getGroupID();
...@@ -436,11 +431,11 @@ public class LdapGroupDAOTest ...@@ -436,11 +431,11 @@ public class LdapGroupDAOTest
} }
if (!found1) if (!found1)
{ {
fail("Test group 1 not found"); fail("Admin group " + testGroup1ID + " not found");
} }
if (!found2) if (!found2)
{ {
fail("Test group 2 not found"); fail("Admin group " + testGroup2ID + " not found");
} }
groups = getGroupDAO().getGroups(daoTestUser2.getUserID(), groups = getGroupDAO().getGroups(daoTestUser2.getUserID(),
...@@ -475,7 +470,7 @@ public class LdapGroupDAOTest ...@@ -475,7 +470,7 @@ public class LdapGroupDAOTest
}); });
} }
// @Test @Test
public void testAddGroupExceptions() throws Exception public void testAddGroupExceptions() throws Exception
{ {
Subject.doAs(anonSubject, new PrivilegedExceptionAction<Object>() Subject.doAs(anonSubject, new PrivilegedExceptionAction<Object>()
...@@ -522,7 +517,7 @@ public class LdapGroupDAOTest ...@@ -522,7 +517,7 @@ public class LdapGroupDAOTest
}); });
} }
// @Test @Test
public void testGetGroupExceptions() throws Exception public void testGetGroupExceptions() throws Exception
{ {
final String groupID = getGroupID(); final String groupID = getGroupID();
...@@ -569,7 +564,7 @@ public class LdapGroupDAOTest ...@@ -569,7 +564,7 @@ public class LdapGroupDAOTest
}); });
} }
// @Test @Test
public void testModifyGroupExceptions() throws Exception public void testModifyGroupExceptions() throws Exception
{ {
final String groupID = getGroupID(); final String groupID = getGroupID();
...@@ -616,7 +611,7 @@ public class LdapGroupDAOTest ...@@ -616,7 +611,7 @@ public class LdapGroupDAOTest
}); });
} }
// @Test @Test
public void testDeleteGroupExceptions() throws Exception public void testDeleteGroupExceptions() throws Exception
{ {
final String groupID = getGroupID(); final String groupID = getGroupID();
...@@ -663,7 +658,7 @@ public class LdapGroupDAOTest ...@@ -663,7 +658,7 @@ public class LdapGroupDAOTest
}); });
} }
// @Test @Test
public void testSearchGroupsExceptions() throws Exception public void testSearchGroupsExceptions() throws Exception
{ {
final String groupID = getGroupID(); final String groupID = getGroupID();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment