Search in sources :

Example 6 with FileGroupDatabase

use of org.apache.qpid.server.security.group.FileGroupDatabase in project qpid-broker-j by apache.

the class FileGroupDatabaseTest method testRemoveGroupPersistedToFile.

public void testRemoveGroupPersistedToFile() throws Exception {
    writeAndSetGroupFile("myGroup1.users", "user1,user2", "myGroup2.users", "user1,user2");
    Set<String> groups = _groupDatabase.getAllGroups();
    assertEquals(2, groups.size());
    Set<String> groupsForUser1 = _groupDatabase.getGroupsForUser(USER1);
    assertEquals(2, groupsForUser1.size());
    _groupDatabase.removeGroup(MY_GROUP1);
    groups = _groupDatabase.getAllGroups();
    assertEquals(1, groups.size());
    assertTrue(groups.contains(MY_GROUP2));
    groupsForUser1 = _groupDatabase.getGroupsForUser(USER1);
    assertEquals(1, groupsForUser1.size());
    FileGroupDatabase newGroupDatabase = new FileGroupDatabase();
    newGroupDatabase.setGroupFile(_groupFile);
    Set<String> newGroups = newGroupDatabase.getAllGroups();
    assertEquals(1, newGroups.size());
    assertTrue(newGroups.contains(MY_GROUP2));
    Set<String> newGroupsForUser1 = newGroupDatabase.getGroupsForUser(USER1);
    assertEquals(1, newGroupsForUser1.size());
    assertTrue(newGroupsForUser1.contains(MY_GROUP2));
}
Also used : FileGroupDatabase(org.apache.qpid.server.security.group.FileGroupDatabase)

Aggregations

FileGroupDatabase (org.apache.qpid.server.security.group.FileGroupDatabase)6 IOException (java.io.IOException)2 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)2 File (java.io.File)1 Principal (java.security.Principal)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)1 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)1 Group (org.apache.qpid.server.model.Group)1 GroupPrincipal (org.apache.qpid.server.security.group.GroupPrincipal)1