View Javadoc

1   /**
2    * Copyright 2011-2013 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  package org.kuali.mobility.shared;
16  
17  import org.apache.log4j.Logger;
18  import org.junit.Before;
19  import org.junit.Test;
20  
21  import static org.junit.Assert.assertFalse;
22  import static org.junit.Assert.assertTrue;
23  
24  /**
25   * @author Kuali Mobility Team (mobility.collab@kuali.org)
26   */
27  public class LoginServiceImplTest {
28  	private static final Logger LOG = Logger.getLogger(LoginServiceImplTest.class);
29  
30  	private LoginService service;
31  
32  	@Before
33  	public void preTest() {
34  		setService(new LoginServiceImpl());
35  	}
36  
37  	@Test
38  	public void testIsValidUser() {
39  		boolean response = getService().isValidUser("mitch");
40  		assertTrue("Failed to find valid user in LoginService.",response);
41  		response = getService().isValidUser("yoda");
42  		assertFalse("Found valid user when we should not have.",response);
43  	}
44  
45  	@Test
46  	public void testIsValidLogin() {
47  		boolean response = getService().isValidLogin("mitch","fae53351b9effc708e764e871bef3119");
48  		assertTrue("Failed to validate login in LoginService.",response);
49  		response = getService().isValidLogin("yoda","abcdefghijklmnopqrstuvwxyz");
50  		assertFalse("Found valid login for invalid user when we should not have.",response);
51  		response = getService().isValidLogin("nate","abcdefghijklmnopqrstuvwxyz");
52  		assertFalse("Found valid login for valid user with bad password when we should not have.",response);
53  	}
54  
55  	public LoginService getService() {
56  		return service;
57  	}
58  
59  	public void setService(LoginService service) {
60  		this.service = service;
61  	}
62  }