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

s1666: updated GroupDAO unit tests

parent c4bf1457
No related branches found
No related tags found
No related merge requests found
...@@ -139,7 +139,7 @@ public class LdapGroupDAOTest ...@@ -139,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
...@@ -222,7 +222,7 @@ public class LdapGroupDAOTest ...@@ -222,7 +222,7 @@ public class LdapGroupDAOTest
}); });
} }
// @Test @Test
public void testSearchOwnerGroups() throws Exception public void testSearchOwnerGroups() throws Exception
{ {
Subject.doAs(daoTestUser1Subject, new PrivilegedExceptionAction<Object>() Subject.doAs(daoTestUser1Subject, new PrivilegedExceptionAction<Object>()
...@@ -270,7 +270,7 @@ public class LdapGroupDAOTest ...@@ -270,7 +270,7 @@ public class LdapGroupDAOTest
}); });
} }
// @Test @Test
public void testSearchMemberGroups() throws Exception public void testSearchMemberGroups() throws Exception
{ {
final String groupID = getGroupID(); final String groupID = getGroupID();
...@@ -371,7 +371,7 @@ public class LdapGroupDAOTest ...@@ -371,7 +371,7 @@ public class LdapGroupDAOTest
}); });
} }
// @Test @Test
public void testSearchAdminGroups() throws Exception public void testSearchAdminGroups() throws Exception
{ {
final String groupID = getGroupID(); final String groupID = getGroupID();
...@@ -492,7 +492,7 @@ public class LdapGroupDAOTest ...@@ -492,7 +492,7 @@ public class LdapGroupDAOTest
Group testGroup2 = new Group(testGroup2ID, daoTestUser1); Group testGroup2 = new Group(testGroup2ID, daoTestUser1);
testGroup2 = getGroupDAO().addGroup(testGroup2); testGroup2 = getGroupDAO().addGroup(testGroup2);
log.debug("add group: " + testGroup2ID); log.debug("add group: " + testGroup2ID);
Thread.sleep(1000); // sleep to let memberof plugin do its work //Thread.sleep(1000); // sleep to let memberof plugin do its work
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -563,7 +563,7 @@ public class LdapGroupDAOTest ...@@ -563,7 +563,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>()
...@@ -610,7 +610,7 @@ public class LdapGroupDAOTest ...@@ -610,7 +610,7 @@ public class LdapGroupDAOTest
}); });
} }
// @Test @Test
public void testGetGroupExceptions() throws Exception public void testGetGroupExceptions() throws Exception
{ {
final String groupID = getGroupID(); final String groupID = getGroupID();
...@@ -662,23 +662,24 @@ public class LdapGroupDAOTest ...@@ -662,23 +662,24 @@ public class LdapGroupDAOTest
} }
}); });
Subject.doAs(daoTestUser2Subject, new PrivilegedExceptionAction<Object>() // All access ACI's will allow anonymous access
{ // Subject.doAs(daoTestUser2Subject, new PrivilegedExceptionAction<Object>()
public Object run() throws Exception // {
{ // public Object run() throws Exception
try // {
{ // try
getGroupDAO().getGroup(groupID); // {
fail("getGroup with anonymous access should throw " + // getGroupDAO().getGroup(groupID);
"AccessControlException"); // fail("getGroup with anonymous access should throw " +
} // "AccessControlException");
catch (AccessControlException ignore) {} // }
return null; // catch (AccessControlException ignore) {}
} // return null;
}); // }
// });
} }
// @Test @Test
public void testModifyGroupExceptions() throws Exception public void testModifyGroupExceptions() throws Exception
{ {
final String groupID = getGroupID(); final String groupID = getGroupID();
...@@ -725,7 +726,7 @@ public class LdapGroupDAOTest ...@@ -725,7 +726,7 @@ public class LdapGroupDAOTest
}); });
} }
// @Test @Test
public void testDeleteGroupExceptions() throws Exception public void testDeleteGroupExceptions() throws Exception
{ {
final String groupID = getGroupID(); final String groupID = getGroupID();
...@@ -772,7 +773,7 @@ public class LdapGroupDAOTest ...@@ -772,7 +773,7 @@ public class LdapGroupDAOTest
}); });
} }
// @Test @Test
public void testSearchGroupsExceptions() throws Exception public void testSearchGroupsExceptions() throws Exception
{ {
final String groupID = getGroupID(); final String groupID = getGroupID();
...@@ -820,6 +821,29 @@ public class LdapGroupDAOTest ...@@ -820,6 +821,29 @@ public class LdapGroupDAOTest
} }
}); });
//
// change the user
// Subject.doAs(daoTestUser2Subject, new PrivilegedExceptionAction<Object>()
// {
// public Object run() throws Exception
// {
// try
// {
// Group group = getGroupDAO().getGroup(groupID);
// assertTrue(group == null);
//
// fail("searchGroups with un-authorized user should throw " +
// "AccessControlException");
// }
// catch (AccessControlException ignore)
// {
//
// }
//
// return null;
// }
// });
Subject.doAs(daoTestUser1Subject, new PrivilegedExceptionAction<Object>() Subject.doAs(daoTestUser1Subject, new PrivilegedExceptionAction<Object>()
{ {
public Object run() throws Exception public Object run() throws Exception
...@@ -828,32 +852,6 @@ public class LdapGroupDAOTest ...@@ -828,32 +852,6 @@ public class LdapGroupDAOTest
return null; return null;
} }
}); });
// change the user
Subject.doAs(daoTestUser2Subject, new PrivilegedExceptionAction<Object>()
{
public Object run() throws Exception
{
try
{
Group group = getGroupDAO().getGroup(groupID);
assertTrue(group == null);
fail("searchGroups with un-authorized user should throw " +
"AccessControlException");
}
catch (AccessControlException ignore)
{
}
return null;
}
});
} }
private void assertGroupsEqual(Group gr1, Group gr2) private void assertGroupsEqual(Group gr1, Group gr2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment