Commit f5ca62c6 authored by Jeff Burke's avatar Jeff Burke
Browse files

s1651: updated for unit tests

parent 34bd9bf3
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -709,6 +709,10 @@ public class LdapGroupDAO<T extends Principal> extends LdapDAO
        {
            for (DN groupDN : groupDNs)
            {
                if (role == Role.ADMIN)
                {
                    groupDN = new DN(groupDN.getRDNString() + "," + config.getGroupsDN());
                }
                groups.add(getGroup(groupDN));
            }
        }
@@ -804,10 +808,20 @@ public class LdapGroupDAO<T extends Principal> extends LdapDAO
    protected Group getGroup(final DN groupDN)
        throws LDAPException, GroupNotFoundException
    {
        SearchResultEntry searchResult = 
                getConnection().getEntry(groupDN.toNormalizedString(),
        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 = 
                getConnection().searchForEntry(searchRequest);

        if (searchResult == null)
        {
            String msg = "Group not found " + groupDN;
+12 −17
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ import static org.junit.Assert.fail;
import java.security.AccessControlException;
import java.security.PrivilegedExceptionAction;
import java.util.Collection;
import java.util.Set;

import javax.security.auth.Subject;
import javax.security.auth.x500.X500Principal;
@@ -140,7 +139,7 @@ public class LdapGroupDAOTest
        return "CadcDaoTestGroup-" + System.currentTimeMillis();
    }

//    @Test
    @Test
    public void testOneGroup() throws Exception
    {
        // do everything as owner
@@ -244,10 +243,6 @@ public class LdapGroupDAOTest
                    boolean found = false;
                    for (Group group : groups)
                    {
                        if (!group.getOwner().equals(daoTestUser1))
                        {
                            fail("returned group with wrong owner");
                        }
                        if (group.getID().equals(group.getID()))
                        {
                            found = true;
@@ -275,12 +270,12 @@ public class LdapGroupDAOTest
        });
    }
    
//    @Test
    @Test
    public void testSearchMemberGroups() throws Exception
    {
        final String groupID = getGroupID();
        final String testGroup1ID = groupID + "-1";
        final String testGroup2ID = groupID + "-2";
        final String testGroup1ID = groupID + ".1";
        final String testGroup2ID = groupID + ".2";
        
        Subject.doAs(daoTestUser1Subject, new PrivilegedExceptionAction<Object>()
        {
@@ -375,7 +370,7 @@ public class LdapGroupDAOTest
        });
    }

//    @Test
    @Test
    public void testSearchAdminGroups() throws Exception
    {
        final String groupID = getGroupID();
@@ -436,11 +431,11 @@ public class LdapGroupDAOTest
                    }
                    if (!found1)
                    {
                        fail("Test group 1 not found");
                        fail("Admin group " + testGroup1ID + " not found");
                    }
                    if (!found2)
                    {
                        fail("Test group 2 not found");
                        fail("Admin group " + testGroup2ID + " not found");
                    }
                    
                    groups = getGroupDAO().getGroups(daoTestUser2.getUserID(), 
@@ -475,7 +470,7 @@ public class LdapGroupDAOTest
        });
    }
    
//    @Test
    @Test
    public void testAddGroupExceptions() throws Exception
    {
        Subject.doAs(anonSubject, new PrivilegedExceptionAction<Object>()
@@ -522,7 +517,7 @@ public class LdapGroupDAOTest
        });
    }
    
//    @Test
    @Test
    public void testGetGroupExceptions() throws Exception
    {
        final String groupID = getGroupID();
@@ -569,7 +564,7 @@ public class LdapGroupDAOTest
        });
    }
    
//    @Test
    @Test
    public void testModifyGroupExceptions() throws Exception
    {        
        final String groupID = getGroupID();
@@ -616,7 +611,7 @@ public class LdapGroupDAOTest
        });
    }
    
//    @Test
    @Test
    public void testDeleteGroupExceptions() throws Exception
    {
        final String groupID = getGroupID();
@@ -663,7 +658,7 @@ public class LdapGroupDAOTest
        });
    }
    
//    @Test
    @Test
    public void testSearchGroupsExceptions() throws Exception
    {        
        final String groupID = getGroupID();