use of org.apache.wiki.TestEngine in project jspwiki by apache.
the class RPCHandlerTest method setUp.
@Before
public void setUp() throws Exception {
CacheManager.getInstance().removeAllCaches();
m_engine = new TestEngine(m_props);
m_handler = new RPCHandler();
WikiContext ctx = new WikiContext(m_engine, new WikiPage(m_engine, "Dummy"));
m_handler.initialize(ctx);
}
use of org.apache.wiki.TestEngine in project jspwiki by apache.
the class AttachmentManagerTest method setUp.
@Before
public void setUp() throws Exception {
CacheManager m_cacheManager = CacheManager.getInstance();
m_cacheManager.clearAll();
m_cacheManager.removeAllCaches();
m_engine = new TestEngine(props);
m_manager = m_engine.getAttachmentManager();
m_engine.saveText(NAME1, "Foobar");
m_engine.saveText(NAMEU, "Foobar");
}
use of org.apache.wiki.TestEngine in project jspwiki by apache.
the class AuthenticationManagerTest method testCustomAuthorizer.
/**
* Tests a dummy WebAuthorizer that is guaranteed to return true for one
* role for each of the two <code>isInRole</code> methods.
*
* @throws Exception
*/
@Test
public void testCustomAuthorizer() throws Exception {
Properties props = TestEngine.getTestProperties();
props.put(AuthorizationManager.PROP_AUTHORIZER, "org.apache.wiki.auth.AuthenticationManagerTest$DummyAuthorizer");
m_engine = new TestEngine(props);
// Start a session without any container roles: DummyAuthorizer should ALWAYS allow AuthorizerRole
WikiSession session = WikiSessionTest.authenticatedSession(m_engine, Users.JANNE, Users.JANNE_PASS);
Assert.assertTrue(session.hasPrincipal(Role.ALL));
Assert.assertTrue(session.hasPrincipal(Role.AUTHENTICATED));
Assert.assertTrue(session.hasPrincipal(new WikiPrincipal(Users.JANNE, WikiPrincipal.LOGIN_NAME)));
Assert.assertTrue(session.hasPrincipal(new WikiPrincipal("JanneJalkanen", WikiPrincipal.WIKI_NAME)));
Assert.assertTrue(session.hasPrincipal(new WikiPrincipal("Janne Jalkanen", WikiPrincipal.FULL_NAME)));
Assert.assertTrue(session.hasPrincipal(new Role("AuthorizerRole")));
Assert.assertFalse(session.hasPrincipal(new Role("ContainerRole")));
Assert.assertFalse(session.hasPrincipal(new Role("DummyRole")));
// Try again with a container-authenticated session: DummyAuthorizer should ALSO allow ContainerRole
session = WikiSessionTest.containerAuthenticatedSession(m_engine, Users.JANNE, new Principal[0]);
Assert.assertTrue(session.hasPrincipal(Role.ALL));
Assert.assertTrue(session.hasPrincipal(Role.AUTHENTICATED));
Assert.assertTrue(session.hasPrincipal(new WikiPrincipal(Users.JANNE, WikiPrincipal.LOGIN_NAME)));
Assert.assertTrue(session.hasPrincipal(new WikiPrincipal("JanneJalkanen", WikiPrincipal.WIKI_NAME)));
Assert.assertTrue(session.hasPrincipal(new WikiPrincipal("Janne Jalkanen", WikiPrincipal.FULL_NAME)));
Assert.assertTrue(session.hasPrincipal(new Role("AuthorizerRole")));
Assert.assertTrue(session.hasPrincipal(new Role("ContainerRole")));
Assert.assertFalse(session.hasPrincipal(new Role("DummyRole")));
}
use of org.apache.wiki.TestEngine in project jspwiki by apache.
the class AuthenticationManagerTest method testCustomJAASLoginModuleOptions.
@Test
public void testCustomJAASLoginModuleOptions() throws Exception {
Properties props = TestEngine.getTestProperties();
// Supply a custom LoginModule options
props.put("jspwiki.loginModule.options.key1", "value1");
props.put("jspwiki.loginModule.options.key2", "value2");
props.put("jspwiki.loginModule.options.key3", "value3");
// Init the engine and verify that we initialized with the correct
// options
WikiEngine engine = new TestEngine(props);
AuthenticationManager authMgr = engine.getAuthenticationManager();
Map<String, String> options = authMgr.m_loginModuleOptions;
Assert.assertEquals(3, options.size());
Assert.assertTrue(options.containsKey("key1"));
Assert.assertTrue(options.containsKey("key2"));
Assert.assertTrue(options.containsKey("key3"));
Assert.assertEquals("value1", options.get("key1"));
Assert.assertEquals("value2", options.get("key2"));
Assert.assertEquals("value3", options.get("key3"));
}
use of org.apache.wiki.TestEngine in project jspwiki by apache.
the class AuthenticationManagerTest method testCustomJAASLoginModule.
@Test
public void testCustomJAASLoginModule() throws Exception {
Properties props = TestEngine.getTestProperties();
// Supply a custom LoginModule class
props.put("jspwiki.loginModule.class", "org.apache.wiki.auth.login.CookieAssertionLoginModule");
// Init the engine and verify that we initialized with a custom auth
// login module
WikiEngine engine = new TestEngine(props);
AuthenticationManager authMgr = engine.getAuthenticationManager();
Assert.assertEquals(CookieAssertionLoginModule.class, authMgr.m_loginModuleClass);
}
Aggregations