01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.clientapp;
18:
19: import javax.servlet.http.HttpServletRequest;
20:
21: import org.junit.Test;
22: import org.kuali.workflow.test.WorkflowTestCase;
23: import org.springframework.mock.web.MockHttpServletRequest;
24:
25: import edu.iu.uis.eden.KEWServiceLocator;
26: import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
27: import edu.iu.uis.eden.user.WorkflowUser;
28: import edu.iu.uis.eden.web.session.UserSession;
29:
30: /**
31: * Verify that the {@link SimpleWebAuthenticationService} can get the logged in user
32: * from the request param.
33: *
34: * @author rkirkend
35: */
36: public class SimpleWebAuthenticationTest extends WorkflowTestCase {
37:
38: @Test
39: public void testGetLoggedInUserFromRequest() throws Exception {
40: HttpServletRequest request = new MockHttpServletRequest();
41: request
42: .setAttribute(
43: SimpleWebAuthenticationService.LOGGED_IN_USER_REQUEST_ATT_KEY,
44: "rkirkend");
45: String networkId = new SimpleWebAuthenticationService()
46: .getNetworkId(request);
47: assertEquals("NetworkId on request is rkirkend", "rkirkend",
48: networkId);
49: }
50:
51: /**
52: * Verify that this method doesn't blow an obvious NPE at this point.
53: * @throws Exception
54: */
55: @Test
56: public void testUpdateUserSession() throws Exception {
57: WorkflowUser user = KEWServiceLocator.getUserService()
58: .getWorkflowUser(new NetworkIdVO("rkirkend"));
59: UserSession userSession = new UserSession(user);
60: HttpServletRequest request = new MockHttpServletRequest();
61: assertNotNull(
62: "Should return same usersession that was passed in",
63: new SimpleWebAuthenticationService().updateUserSession(
64: userSession, request));
65: }
66: }
|