Package org.apache.turbine.om.security

Examples of org.apache.turbine.om.security.Group


        assertNotNull(user);

        AccessControlList acl = ss.getACL(user);
        assertNotNull(acl);

        Group turbine = ss.getGroupByName("Turbine");
        assertNotNull(turbine);

        assertEquals(0, acl.getRoles().size());
        assertEquals(1, acl.getRoles(turbine).size());
        assertEquals(0, acl.getPermissions().size());      
View Full Code Here


    public void testGroupByName()
            throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Group role = ss.getGroupByName("Turbine");
        assertNotNull(role);
        assertEquals("Turbine", role.getName());
    }
View Full Code Here

    public void testGroupById()
            throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Group role = ss.getGroupById(2);
        assertNotNull(role);
        assertEquals("Turbine", role.getName());
    }
View Full Code Here

    public void testAddGroup()
      throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Group newbie = ss.getGroupInstance();
        newbie.setName("newbie");

        ss.addGroup(newbie);

        assertEquals("Group was not added", 3, ss.getAllGroups().size());

        try
        {
            Group turbine = ss.getGroupByName("Turbine");

            ss.addGroup(turbine);
            fail("Existing Group could be added!");
        }
        catch (Exception e)
        {
            assertEquals("Wrong Exception thrown: " + e.getClass().getName(), EntityExistsException.class, e.getClass());
        }

        try
        {
            Group empty = ss.getGroupInstance();

            ss.addGroup(empty);
            fail("Group with empty Groupname could be added!");
        }
        catch (Exception e)
View Full Code Here

    {
        SecurityService ss = TurbineSecurity.getService();

        assertEquals("Group was not added", 3, ss.getAllGroups().size());

        Group newbie = ss.getGroupByName("newbie");
        assertNotNull(newbie);

        ss.removeGroup(newbie);

        try
        {
            Group foo = ss.getGroupInstance();
            foo.setName("foo");

            ss.removeGroup(foo);
            fail("Non Existing Group could be deleted!");
        }
        catch (Exception e)
View Full Code Here

    public void testSaveGroup()
      throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Group turbine = ss.getGroupByName("Turbine");

        ss.saveGroup(turbine);

        try
        {
            Group fake = ss.getGroupInstance("fake");

            ss.saveGroup(fake);
            fail("Non Existing Group could be saved!");
        }
        catch (Exception e)
View Full Code Here

    public void testRenameGroup()
      throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        Group newbie = ss.getGroupInstance("newbie");
        ss.addGroup(newbie);

        Group test = ss.getGroupByName("newbie");
        assertNotNull(test);

        ss.renameGroup(test, "fake");

        Group fake = ss.getGroupByName("fake");
        assertNotNull(fake);

//
// Now this is a Turbine Bug...
//
View Full Code Here

        SecurityService ss = TurbineSecurity.getService();

        User admin = ss.getUser("admin");
        assertNotNull(admin);

        Group global = ss.getGroupByName("global");
        assertNotNull(global);

        Role app = ss.getRoleByName("User");
        assertNotNull(app);

        AccessControlList acl = ss.getACL(admin);
        assertFalse(acl.hasRole(app, global));

        ss.grant(admin, global, app);

        AccessControlList acl2 = ss.getACL(admin);
        assertTrue(acl2.hasRole(app, global));

        // Get existing ACL modified?
        assertFalse(acl.hasRole(app, global));

        try
        {
            ss.grant(admin, global, app);
            fail("Role could be granted twice!");
        }
        catch (Exception e)
        {
            //
            // Ugh. DataBackendError? This means that our query actually hit the database and only the "unique key"
            // prevented us from a double entry. This seems to be a bug
            //
            assertEquals("Wrong Exception thrown: " + e.getClass().getName(), DataBackendException.class, e.getClass());
        }

        try
        {
            Role unknown = ss.getRoleInstance("unknown");

            ss.grant(admin, global, unknown);
            fail("Nonexisting Role could be granted!");
        }
        catch (Exception e)
        {
            assertEquals("Wrong Exception thrown: " + e.getClass().getName(), UnknownEntityException.class, e.getClass());
        }

        try
        {
            Group unknown = ss.getGroupInstance("unknown");

            ss.grant(admin, unknown, app);
            fail("Role in non existing group could be granted!");
        }
        catch (Exception e)
View Full Code Here

        SecurityService ss = TurbineSecurity.getService();

        User admin = ss.getUser("admin");
        assertNotNull(admin);

        Group global = ss.getGroupByName("global");
        assertNotNull(global);

        Role app = ss.getRoleByName("User");
        assertNotNull(app);

        AccessControlList acl = ss.getACL(admin);
        assertTrue(acl.hasRole(app, global));

        ss.revoke(admin, global, app);

        AccessControlList acl2 = ss.getACL(admin);
        assertFalse(acl2.hasRole(app, global));

        // Get existing ACL modified?
        assertTrue(acl.hasRole(app, global));

         try
         {
             Role unknown = ss.getRoleInstance("unknown");
             ss.revoke(admin, global, unknown);
             fail("Nonexisting Role could be revoked!");
         }
         catch (Exception e)
         {
             assertEquals("Wrong Exception thrown: " + e.getClass().getName(), UnknownEntityException.class, e.getClass());
         }

        try
        {
            Group unknown = ss.getGroupInstance("unknown");
            ss.revoke(admin, unknown, app);
            fail("Role in non existing group could be revoked!");
        }
        catch (Exception e)
        {
View Full Code Here

        SecurityService ss = TurbineSecurity.getService();

        User admin = ss.getUser("admin");
        assertNotNull(admin);

        Group turbine = ss.getGroupByName("Turbine");
        assertNotNull(turbine);

        AccessControlList acl = ss.getACL(admin);
        assertEquals(1, acl.getRoles(turbine).size());
View Full Code Here

TOP

Related Classes of org.apache.turbine.om.security.Group

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.