Search in sources :

Example 56 with TestEngine

use of org.apache.wiki.TestEngine in project jspwiki by apache.

the class UserManagerTest method setUp.

/**
 */
@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    // Make sure user profile save workflow is OFF
    props.remove("jspwiki.approver" + UserManager.SAVE_APPROVER);
    // Make sure we are using the XML user database
    props.put(XMLUserDatabase.PROP_USERDATABASE, "target/test-classes/userdatabase.xml");
    m_engine = new TestEngine(props);
    m_mgr = m_engine.getUserManager();
    m_db = m_mgr.getUserDatabase();
    m_groupName = "Group" + System.currentTimeMillis();
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) Before(org.junit.Before)

Example 57 with TestEngine

use of org.apache.wiki.TestEngine in project jspwiki by apache.

the class AclImplTest method setUp.

/**
 * We setup the following rules: Alice = may view Bob = may view, may edit
 * Charlie = may view Dave = may view, may comment groupAcl: FooGroup =
 * Alice, Bob - may edit BarGroup = Bob, Charlie - may view
 */
@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    TestEngine engine = new TestEngine(props);
    m_groupMgr = engine.getGroupManager();
    m_session = WikiSessionTest.adminSession(engine);
    m_acl = new AclImpl();
    m_aclGroup = new AclImpl();
    m_groups = new HashMap<String, Group>();
    Principal uAlice = new WikiPrincipal("Alice");
    Principal uBob = new WikiPrincipal("Bob");
    Principal uCharlie = new WikiPrincipal("Charlie");
    Principal uDave = new WikiPrincipal("Dave");
    // Alice can view
    AclEntry ae = new AclEntryImpl();
    ae.addPermission(PagePermission.VIEW);
    ae.setPrincipal(uAlice);
    // Charlie can view
    AclEntry ae2 = new AclEntryImpl();
    ae2.addPermission(PagePermission.VIEW);
    ae2.setPrincipal(uCharlie);
    // Bob can view and edit (and by implication, comment)
    AclEntry ae3 = new AclEntryImpl();
    ae3.addPermission(PagePermission.VIEW);
    ae3.addPermission(PagePermission.EDIT);
    ae3.setPrincipal(uBob);
    // Dave can view and comment
    AclEntry ae4 = new AclEntryImpl();
    ae4.addPermission(PagePermission.VIEW);
    ae4.addPermission(PagePermission.COMMENT);
    ae4.setPrincipal(uDave);
    // Create ACL with Alice, Bob, Charlie, Dave
    m_acl.addEntry(ae);
    m_acl.addEntry(ae2);
    m_acl.addEntry(ae3);
    m_acl.addEntry(ae4);
    // Foo group includes Alice and Bob
    Group foo = m_groupMgr.parseGroup("FooGroup", "", true);
    m_groupMgr.setGroup(m_session, foo);
    foo.add(uAlice);
    foo.add(uBob);
    AclEntry ag1 = new AclEntryImpl();
    ag1.setPrincipal(foo.getPrincipal());
    ag1.addPermission(PagePermission.EDIT);
    m_aclGroup.addEntry(ag1);
    m_groups.put("FooGroup", foo);
    // Bar group includes Bob and Charlie
    Group bar = m_groupMgr.parseGroup("BarGroup", "", true);
    m_groupMgr.setGroup(m_session, bar);
    bar.add(uBob);
    bar.add(uCharlie);
    AclEntry ag2 = new AclEntryImpl();
    ag2.setPrincipal(bar.getPrincipal());
    ag2.addPermission(PagePermission.VIEW);
    m_aclGroup.addEntry(ag2);
    m_groups.put("BarGroup", bar);
}
Also used : Group(org.apache.wiki.auth.authorize.Group) WikiPrincipal(org.apache.wiki.auth.WikiPrincipal) TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) WikiPrincipal(org.apache.wiki.auth.WikiPrincipal) Principal(java.security.Principal) GroupPrincipal(org.apache.wiki.auth.GroupPrincipal) Before(org.junit.Before)

Example 58 with TestEngine

use of org.apache.wiki.TestEngine in project jspwiki by apache.

the class DefaultAclManagerTest method setUp.

@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    m_engine = new TestEngine(props);
    String text = "Foo";
    m_engine.saveText("TestDefaultPage", text);
    text = "Bar. [{ALLOW edit Charlie, Herman}] ";
    m_engine.saveText("TestAclPage", text);
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) Before(org.junit.Before)

Example 59 with TestEngine

use of org.apache.wiki.TestEngine in project jspwiki by apache.

the class GroupTest method setUp.

@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    WikiEngine engine = new TestEngine(props);
    m_wiki = engine.getApplicationName();
    m_group = new Group("TestGroup", m_wiki);
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) WikiEngine(org.apache.wiki.WikiEngine) Before(org.junit.Before)

Example 60 with TestEngine

use of org.apache.wiki.TestEngine in project jspwiki by apache.

the class WebContainerAuthorizerTest method setUp.

@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    m_engine = new TestEngine(props);
    m_authorizer = new WebContainerAuthorizer();
    m_authorizer.initialize(m_engine, props);
    m_webxml = m_authorizer.getWebXml();
    if (m_webxml == null) {
        throw new Exception("Could not load web.xml");
    }
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) Before(org.junit.Before)

Aggregations

TestEngine (org.apache.wiki.TestEngine)70 Before (org.junit.Before)49 Properties (java.util.Properties)42 WikiPage (org.apache.wiki.WikiPage)15 Test (org.junit.Test)15 WikiContext (org.apache.wiki.WikiContext)11 WikiEngine (org.apache.wiki.WikiEngine)8 File (java.io.File)4 Subject (javax.security.auth.Subject)4 WikiSessionTest (org.apache.wiki.WikiSessionTest)4 NoRequiredPropertyException (org.apache.wiki.api.exceptions.NoRequiredPropertyException)4 XMLUserDatabase (org.apache.wiki.auth.user.XMLUserDatabase)4 Attachment (org.apache.wiki.attachment.Attachment)3 WikiPrincipal (org.apache.wiki.auth.WikiPrincipal)3 StringReader (java.io.StringReader)2 Principal (java.security.Principal)2 WikiSession (org.apache.wiki.WikiSession)2 GroupPrincipal (org.apache.wiki.auth.GroupPrincipal)2 Group (org.apache.wiki.auth.authorize.Group)2 BufferedReader (java.io.BufferedReader)1