01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: TestAuthenticationUtils.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.authentication;
09:
10: import com.uwyn.rife.TestCaseServerside;
11: import com.uwyn.rife.engine.SiteBuilder;
12: import com.uwyn.rife.test.MockConversation;
13: import com.uwyn.rife.test.MockResponse;
14:
15: public class TestAuthenticationUtils extends TestCaseServerside {
16: public TestAuthenticationUtils(int siteType, String name) {
17: super (siteType, name);
18: }
19:
20: public void testStartAuthSession() throws Throwable {
21: SiteBuilder builder = new SiteBuilder(
22: "site/authentication_memory_input.xml");
23: MockConversation conversation = new MockConversation(builder
24: .getSite());
25:
26: MockResponse response = conversation
27: .doRequest("/authenticationutils/startauthsession");
28: String authid = response.getText();
29:
30: SessionValidator validator = SessionValidatorRetriever
31: .getSessionValidator(builder.getSite(),
32: ".INPUT.MEMORY_AUTHENTICATED_BASIC", null);
33: assertTrue(validator.getSessionManager().isSessionValid(authid,
34: "127.0.0.1"));
35: }
36:
37: public void testStartAuthSession2() throws Throwable {
38: SiteBuilder builder = new SiteBuilder(
39: "site/authentication_memory_input.xml");
40: MockConversation conversation = new MockConversation(builder
41: .getSite());
42:
43: MockResponse response = conversation
44: .doRequest("/authenticationutils/startauthsession2");
45: String authid = response.getText();
46:
47: SessionValidator validator = SessionValidatorRetriever
48: .getSessionValidator(builder.getSite(),
49: ".INPUT.MEMORY_AUTHENTICATED_BASIC", null);
50: assertTrue(validator.getSessionManager().isSessionValid(authid,
51: "127.0.0.1"));
52: }
53: }
|