Search in sources :

Example 6 with TestEngine

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

the class ShortURLConstructorTest method getConstructor.

private URLConstructor getConstructor(String prefix) throws WikiException {
    if (prefix != null)
        props.setProperty(ShortURLConstructor.PROP_PREFIX, prefix);
    testEngine = new TestEngine(props);
    URLConstructor constr = new ShortURLConstructor();
    constr.initialize(testEngine, props);
    return constr;
}
Also used : TestEngine(org.apache.wiki.TestEngine)

Example 7 with TestEngine

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

the class AuthenticationManagerTest method setUp.

@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    m_engine = new TestEngine(props);
    m_auth = m_engine.getAuthenticationManager();
    m_groupMgr = m_engine.getGroupManager();
    m_session = WikiSessionTest.adminSession(m_engine);
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) Before(org.junit.Before)

Example 8 with TestEngine

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

the class MarkdownRendererTest method setUp.

@Before
public void setUp() throws Exception {
    CacheManager.getInstance().removeAllCaches();
    props.setProperty("jspwiki.translatorReader.matchEnglishPlurals", "true");
    props.setProperty("jspwiki.fileSystemProvider.pageDir", "./target/md-pageDir");
    props.setProperty("jspwiki.renderingManager.markupParser", MarkdownParser.class.getName());
    props.setProperty("jspwiki.renderingManager.renderer", MarkdownRenderer.class.getName());
    testEngine = new TestEngine(props);
}
Also used : TestEngine(org.apache.wiki.TestEngine) MarkdownParser(org.apache.wiki.parser.markdown.MarkdownParser) MarkdownRenderer(org.apache.wiki.render.markdown.MarkdownRenderer) Before(org.junit.Before)

Example 9 with TestEngine

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

the class AuthorizationManagerTest method testUserPolicy.

@Test
public void testUserPolicy() throws Exception {
    Properties props = TestEngine.getTestProperties();
    // Make sure we are using the default security policy file jspwiki.policy
    props.put(AuthorizationManager.POLICY, "jspwiki-testUserPolicy.policy");
    // Initialize the test engine
    m_engine = new TestEngine(props);
    m_auth = m_engine.getAuthorizationManager();
    m_groupMgr = m_engine.getGroupManager();
    m_session = WikiSessionTest.adminSession(m_engine);
    WikiSession s = WikiSessionTest.anonymousSession(m_engine);
    Assert.assertFalse("Anonymous view", m_auth.checkStaticPermission(s, PagePermission.VIEW));
    Assert.assertFalse("Anonymous edit", m_auth.checkStaticPermission(s, PagePermission.EDIT));
    Assert.assertFalse("Anonymous comment", m_auth.checkStaticPermission(s, PagePermission.COMMENT));
    Assert.assertFalse("Anonymous modify", m_auth.checkStaticPermission(s, PagePermission.MODIFY));
    Assert.assertFalse("Anonymous upload", m_auth.checkStaticPermission(s, PagePermission.UPLOAD));
    Assert.assertFalse("Anonymous rename", m_auth.checkStaticPermission(s, PagePermission.RENAME));
    Assert.assertFalse("Anonymous delete", m_auth.checkStaticPermission(s, PagePermission.DELETE));
    Assert.assertFalse("Anonymous prefs", m_auth.checkStaticPermission(s, WikiPermission.EDIT_PREFERENCES));
    Assert.assertFalse("Anonymous profile", m_auth.checkStaticPermission(s, WikiPermission.EDIT_PROFILE));
    Assert.assertFalse("Anonymous pages", m_auth.checkStaticPermission(s, WikiPermission.CREATE_PAGES));
    Assert.assertFalse("Anonymous groups", m_auth.checkStaticPermission(s, WikiPermission.CREATE_GROUPS));
    s = WikiSessionTest.assertedSession(m_engine, "Jack Sparrow");
    Assert.assertFalse("Asserted view", m_auth.checkStaticPermission(s, PagePermission.VIEW));
    Assert.assertFalse("Asserted edit", m_auth.checkStaticPermission(s, PagePermission.EDIT));
    Assert.assertFalse("Asserted comment", m_auth.checkStaticPermission(s, PagePermission.COMMENT));
    Assert.assertFalse("Asserted modify", m_auth.checkStaticPermission(s, PagePermission.MODIFY));
    Assert.assertFalse("Asserted upload", m_auth.checkStaticPermission(s, PagePermission.UPLOAD));
    Assert.assertFalse("Asserted rename", m_auth.checkStaticPermission(s, PagePermission.RENAME));
    Assert.assertFalse("Asserted delete", m_auth.checkStaticPermission(s, PagePermission.DELETE));
    Assert.assertFalse("Asserted prefs", m_auth.checkStaticPermission(s, WikiPermission.EDIT_PREFERENCES));
    Assert.assertFalse("Asserted profile", m_auth.checkStaticPermission(s, WikiPermission.EDIT_PROFILE));
    Assert.assertFalse("Asserted pages", m_auth.checkStaticPermission(s, WikiPermission.CREATE_PAGES));
    Assert.assertFalse("Asserted groups", m_auth.checkStaticPermission(s, WikiPermission.CREATE_GROUPS));
    s = WikiSessionTest.authenticatedSession(m_engine, Users.BOB, Users.BOB_PASS);
    Assert.assertTrue("Bob  view", m_auth.checkStaticPermission(s, PagePermission.VIEW));
    Assert.assertTrue("Bob edit", m_auth.checkStaticPermission(s, PagePermission.EDIT));
    Assert.assertTrue("Bob comment", m_auth.checkStaticPermission(s, PagePermission.COMMENT));
    Assert.assertTrue("Bob modify", m_auth.checkStaticPermission(s, PagePermission.MODIFY));
    Assert.assertTrue("Bob upload", m_auth.checkStaticPermission(s, PagePermission.UPLOAD));
    Assert.assertFalse("Bob rename", m_auth.checkStaticPermission(s, PagePermission.RENAME));
    Assert.assertTrue("Bob delete", m_auth.checkStaticPermission(s, PagePermission.DELETE));
    Assert.assertFalse("Bob prefs", m_auth.checkStaticPermission(s, WikiPermission.EDIT_PREFERENCES));
    Assert.assertFalse("Bob profile", m_auth.checkStaticPermission(s, WikiPermission.EDIT_PROFILE));
    Assert.assertFalse("Bob pages", m_auth.checkStaticPermission(s, WikiPermission.CREATE_PAGES));
    Assert.assertFalse("Bob groups", m_auth.checkStaticPermission(s, WikiPermission.CREATE_GROUPS));
    s = WikiSessionTest.authenticatedSession(m_engine, Users.JANNE, Users.JANNE_PASS);
    Assert.assertTrue("Janne  view", m_auth.checkStaticPermission(s, PagePermission.VIEW));
    Assert.assertTrue("Janne edit", m_auth.checkStaticPermission(s, PagePermission.EDIT));
    Assert.assertTrue("Janne comment", m_auth.checkStaticPermission(s, PagePermission.COMMENT));
    Assert.assertTrue("Janne modify", m_auth.checkStaticPermission(s, PagePermission.MODIFY));
    Assert.assertTrue("Janne upload", m_auth.checkStaticPermission(s, PagePermission.UPLOAD));
    Assert.assertFalse("Janne rename", m_auth.checkStaticPermission(s, PagePermission.RENAME));
    Assert.assertTrue("Janne delete", m_auth.checkStaticPermission(s, PagePermission.DELETE));
    Assert.assertFalse("Janne prefs", m_auth.checkStaticPermission(s, WikiPermission.EDIT_PREFERENCES));
    Assert.assertFalse("Janne profile", m_auth.checkStaticPermission(s, WikiPermission.EDIT_PROFILE));
    Assert.assertFalse("Janne pages", m_auth.checkStaticPermission(s, WikiPermission.CREATE_PAGES));
    Assert.assertFalse("Janne groups", m_auth.checkStaticPermission(s, WikiPermission.CREATE_GROUPS));
    s = WikiSessionTest.adminSession(m_engine);
    Assert.assertTrue("Admin view", m_auth.checkStaticPermission(s, PagePermission.VIEW));
    Assert.assertFalse("Admin edit", m_auth.checkStaticPermission(s, PagePermission.EDIT));
    Assert.assertFalse("Admin comment", m_auth.checkStaticPermission(s, PagePermission.COMMENT));
    Assert.assertFalse("Admin modify", m_auth.checkStaticPermission(s, PagePermission.MODIFY));
    Assert.assertFalse("Admin upload", m_auth.checkStaticPermission(s, PagePermission.UPLOAD));
    Assert.assertFalse("Admin rename", m_auth.checkStaticPermission(s, PagePermission.RENAME));
    Assert.assertFalse("Admin delete", m_auth.checkStaticPermission(s, PagePermission.DELETE));
    Assert.assertFalse("Admin prefs", m_auth.checkStaticPermission(s, WikiPermission.EDIT_PREFERENCES));
    Assert.assertFalse("Admin profile", m_auth.checkStaticPermission(s, WikiPermission.EDIT_PROFILE));
    Assert.assertFalse("Admin pages", m_auth.checkStaticPermission(s, WikiPermission.CREATE_PAGES));
    Assert.assertFalse("Admin groups", m_auth.checkStaticPermission(s, WikiPermission.CREATE_GROUPS));
}
Also used : WikiSession(org.apache.wiki.WikiSession) TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) WikiSessionTest(org.apache.wiki.WikiSessionTest) Test(org.junit.Test)

Example 10 with TestEngine

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

the class AuthorizationManagerTest method setUp.

@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    // Make sure we are using the default security policy file jspwiki.policy
    props.put(AuthorizationManager.POLICY, AuthorizationManager.DEFAULT_POLICY);
    // Initialize the test engine
    m_engine = new TestEngine(props);
    m_auth = m_engine.getAuthorizationManager();
    m_groupMgr = m_engine.getGroupManager();
    m_session = WikiSessionTest.adminSession(m_engine);
}
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