Package org.geoserver.security

Source Code of org.geoserver.security.SecureTreeNodeTest

package org.geoserver.security;

import junit.framework.TestCase;

import org.acegisecurity.providers.TestingAuthenticationToken;

public class SecureTreeNodeTest extends TestCase {

    private TestingAuthenticationToken anonymous;

    @Override
    protected void setUp() throws Exception {
        anonymous = new TestingAuthenticationToken("anonymous", null, null);
    }

    public void testEmptyRoot() {
        SecureTreeNode root = new SecureTreeNode();

        // smoke tests
        assertNull(root.getChild("NotThere"));
        assertEquals(SecureTreeNode.EVERYBODY, root.getAuthorizedRoles(AccessMode.READ));
        assertEquals(SecureTreeNode.EVERYBODY, root.getAuthorizedRoles(AccessMode.WRITE));

        // empty, deepest node is itself
        SecureTreeNode node = root.getDeepestNode(new String[] { "a", "b" });
        assertSame(root, node);

        // allows access to everyone
        assertTrue(root.canAccess(anonymous, AccessMode.WRITE));
        assertTrue(root.canAccess(anonymous, AccessMode.READ));
       
        // make sure this includes not having a current user as well
        assertTrue(root.canAccess(null, AccessMode.WRITE));
        assertTrue(root.canAccess(null, AccessMode.READ));
    }
   
   
}
TOP

Related Classes of org.geoserver.security.SecureTreeNodeTest

TOP
Copyright © 2018 www.massapi.com. 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.