Package org.geoserver.security.impl

Examples of org.geoserver.security.impl.DataAccessRule


import junit.framework.TestCase;

public class DataAccessRuleTest extends TestCase {

    public void testEqualRoot() {
        DataAccessRule rule1 = new DataAccessRule("*", "*", AccessMode.READ);
        DataAccessRule rule2 = new DataAccessRule("*", "*", AccessMode.READ);
        assertEquals(0, rule1.compareTo(rule2));
        assertEquals(rule1, rule2);
        assertEquals(rule1.hashCode(), rule2.hashCode());
    }
View Full Code Here


        assertEquals(rule1, rule2);
        assertEquals(rule1.hashCode(), rule2.hashCode());
    }
   
    public void testDifferentRoot() {
        DataAccessRule rule1 = new DataAccessRule("*", "*", AccessMode.READ);
        DataAccessRule rule2 = new DataAccessRule("*", "*", AccessMode.WRITE);
        assertEquals(-1, rule1.compareTo(rule2));
        assertFalse(rule1.equals(rule2));
    }
View Full Code Here

        assertEquals(-1, rule1.compareTo(rule2));
        assertFalse(rule1.equals(rule2));
    }
   
    public void testDifferenPath() {
        DataAccessRule rule1 = new DataAccessRule("topp", "layer1", AccessMode.READ);
        DataAccessRule rule2 = new DataAccessRule("topp", "layer2", AccessMode.READ);
        assertEquals(-1, rule1.compareTo(rule2));
        assertFalse(rule1.equals(rule2));
    }
View Full Code Here

   
    public void testParse() {
        assertEquals(3, dao.getRules().size());
       
        // check the first rule
        DataAccessRule rule = dao.getRules().get(0);
        assertEquals("*.*.r", rule.getKey());
        assertEquals(1, rule.getRoles().size());
        assertEquals("*", rule.getRoles().iterator().next());
    }
View Full Code Here

        assertEquals("*", rule.getRoles().iterator().next());
    }
   
    public void testAdd() {
        assertEquals(3, dao.getRules().size());
        DataAccessRule newRule = dao.parseDataAccessRule("*.*.w", "ROLE_GENERIC_W");
        assertTrue(dao.addRule(newRule));
        assertEquals(4, dao.getRules().size());
        assertEquals(newRule, dao.getRules().get(1));
        assertFalse(dao.addRule(newRule));
    }
View Full Code Here

        assertEquals(newRule, dao.getRules().get(1));
        assertFalse(dao.addRule(newRule));
    }
   
    public void testRemove() {
        DataAccessRule newRule = dao.parseDataAccessRule("*.*.w", "ROLE_GENERIC_W");
        assertFalse(dao.removeRule(newRule));
        DataAccessRule first = dao.getRules().get(0);
        assertTrue(dao.removeRule(first));
        assertFalse(dao.removeRule(first));
        assertEquals(2, dao.getRules().size());
    }
View Full Code Here

            assertEquals(newValue, oldValue);
        }
    }
   
    public void testParsePlain() {
        DataAccessRule rule = dao.parseDataAccessRule("a.b.r", "ROLE_WHO_CARES");
        assertEquals("a", rule.getWorkspace());
        assertEquals("b", rule.getLayer());
        assertEquals(AccessMode.READ, rule.getAccessMode());
    }
View Full Code Here

        assertEquals("b", rule.getLayer());
        assertEquals(AccessMode.READ, rule.getAccessMode());
    }
   
    public void testParseSpaces() {
        DataAccessRule rule = dao.parseDataAccessRule(" a  . b . r ", "ROLE_WHO_CARES");
        assertEquals("a", rule.getWorkspace());
        assertEquals("b", rule.getLayer());
        assertEquals(AccessMode.READ, rule.getAccessMode());
    }
View Full Code Here

        assertEquals("b", rule.getLayer());
        assertEquals(AccessMode.READ, rule.getAccessMode());
    }
   
    public void testParseEscapedDots() {
        DataAccessRule rule = dao.parseDataAccessRule("w. a\\.b . r ", "ROLE_WHO_CARES");
        assertEquals("w", rule.getWorkspace());
        assertEquals("a.b", rule.getLayer());
        assertEquals(AccessMode.READ, rule.getAccessMode());
    }
View Full Code Here

        assertEquals(AccessMode.READ, rule.getAccessMode());
    }
   
    public void testStoreEscapedDots() throws Exception {
        dao.clear();
        dao.addRule(new DataAccessRule("it.geosolutions", "layer.dots",
                AccessMode.READ, Collections.singleton("ROLE_ABC")));
        Properties ps = dao.toProperties();
       
        assertEquals(2, ps.size());
        assertEquals("ROLE_ABC", ps.getProperty("it\\.geosolutions.layer\\.dots.r"));
View Full Code Here

TOP

Related Classes of org.geoserver.security.impl.DataAccessRule

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.