use of org.apache.wiki.auth.WikiPrincipal in project jspwiki by apache.
the class AclImplTest method testBob.
@Test
public void testBob() {
// Bob should be able to view, edit, and comment but not delete
Principal wup = new WikiPrincipal("Bob");
Assert.assertTrue("view", inArray(m_acl.findPrincipals(PagePermission.VIEW), wup));
Assert.assertTrue("edit", inArray(m_acl.findPrincipals(PagePermission.EDIT), wup));
Assert.assertTrue("comment", inArray(m_acl.findPrincipals(PagePermission.COMMENT), wup));
Assert.assertFalse("delete", inArray(m_acl.findPrincipals(PagePermission.DELETE), wup));
}
use of org.apache.wiki.auth.WikiPrincipal in project jspwiki by apache.
the class DefaultAclManagerTest method testPrintAcl.
@Test
public void testPrintAcl() {
// Verify that the printed Acl for the test page is OK
WikiPage page = m_engine.getPage("TestAclPage");
Acl acl = m_engine.getAclManager().getPermissions(page);
String aclString = DefaultAclManager.printAcl(acl);
Assert.assertEquals("[{ALLOW edit Charlie,Herman}]\n", aclString);
// Create an ACL from scratch
acl = new AclImpl();
AclEntry entry = new AclEntryImpl();
entry.setPrincipal(new WikiPrincipal("Charlie"));
entry.addPermission(PermissionFactory.getPagePermission("Main:Foo", "view"));
entry.addPermission(PermissionFactory.getPagePermission("Main:Foo", "edit"));
acl.addEntry(entry);
entry = new AclEntryImpl();
entry.setPrincipal(new WikiPrincipal("Devin"));
entry.addPermission(PermissionFactory.getPagePermission("Main:Foo", "edit"));
entry.addPermission(PermissionFactory.getPagePermission("Main:Foo", "delete"));
acl.addEntry(entry);
// Verify that the printed ACL is OK
String expectedValue = "[{ALLOW delete Devin}]\n[{ALLOW edit Charlie,Devin}]\n[{ALLOW view Charlie}]\n";
Assert.assertEquals(expectedValue, DefaultAclManager.printAcl(acl));
}
use of org.apache.wiki.auth.WikiPrincipal in project jspwiki by apache.
the class GroupTest method testEquals2.
@Test
public void testEquals2() {
Principal u1 = new WikiPrincipal("Alice");
Principal u2 = new WikiPrincipal("Bob");
m_group.add(u1);
m_group.add(u2);
Group group2 = new Group("Group2", m_wiki);
Principal u3 = new WikiPrincipal("Alice");
Principal u4 = new WikiPrincipal("Charlie");
group2.add(u3);
group2.add(u4);
Assert.assertFalse(m_group.equals(group2));
}
use of org.apache.wiki.auth.WikiPrincipal in project jspwiki by apache.
the class GroupTest method testEquals1.
@Test
public void testEquals1() {
Principal u1 = new WikiPrincipal("Alice");
Principal u2 = new WikiPrincipal("Bob");
m_group.add(u1);
m_group.add(u2);
Group group2 = new Group("TestGroup", m_wiki);
Principal u3 = new WikiPrincipal("Alice");
Principal u4 = new WikiPrincipal("Bob");
group2.add(u3);
group2.add(u4);
Assert.assertTrue(m_group.equals(group2));
}
use of org.apache.wiki.auth.WikiPrincipal in project jspwiki by apache.
the class GroupTest method testEquals3.
@Test
public void testEquals3() {
Group group1 = new Group("Blib", m_wiki);
Principal u1 = new WikiPrincipal("Alice");
Principal u2 = new WikiPrincipal("Bob");
group1.add(u1);
group1.add(u2);
Group group2 = new Group("Blib", m_wiki);
Principal u3 = new WikiPrincipal("Alice");
Principal u4 = new WikiPrincipal("Bob");
group2.add(u3);
group2.add(u4);
Assert.assertTrue(group1.equals(group2));
}
Aggregations