01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
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: */
18: package org.apache.lenya.cms.ac.usecases;
19:
20: import java.util.HashMap;
21: import java.util.Map;
22:
23: import org.apache.cocoon.environment.Session;
24: import org.apache.lenya.ac.AccessControlException;
25: import org.apache.lenya.ac.Identity;
26: import org.apache.lenya.ac.User;
27: import org.apache.lenya.cms.usecase.AbstractUsecaseTest;
28:
29: /**
30: * Login test.
31: */
32: public class LoginTest extends AbstractUsecaseTest {
33:
34: protected static final String USER_ID = "lenya";
35: protected static final String PASSWORD = "levi";
36:
37: protected Map getRequestParameters() {
38: return getParameters();
39: }
40:
41: protected Map getParameters() {
42: Map params = new HashMap();
43: params.put(Login.USERNAME, USER_ID);
44: params.put(Login.PASSWORD, PASSWORD);
45: return params;
46: }
47:
48: protected String getUsecaseName() {
49: return "ac.login";
50: }
51:
52: protected void checkPostconditions() {
53: Session session = getRequest().getSession();
54: Identity identity = (Identity) session
55: .getAttribute(Identity.class.getName());
56: User user = identity.getUser();
57: assertNotNull(user);
58: assertEquals(user.getId(), USER_ID);
59: }
60:
61: protected void login() throws AccessControlException {
62: getAccessController().setupIdentity(getRequest());
63: }
64:
65: }
|