View Javadoc
1   /**
2    * Copyright 2005-2016 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.ksb.security.credentials;
17  
18  import org.junit.Before;
19  import org.junit.Test;
20  import org.kuali.rice.core.api.security.credentials.Credentials;
21  import org.kuali.rice.core.api.security.credentials.CredentialsType;
22  
23  import static org.junit.Assert.*;
24  
25  /**
26   * 
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   * @since 0.9
29   * 
30   */
31  public class UsernamePasswordCredentialsSourceTest {
32  
33  	private static final String USERNAME = "username";
34  
35  	private static final String PASSWORD = "password";
36  
37  	private UsernamePasswordCredentialsSource credentialsSource;
38  
39      @Before
40  	public void setUp() throws Exception {
41  		this.credentialsSource = new UsernamePasswordCredentialsSource(
42  				USERNAME, PASSWORD);
43  	}
44  
45      @Test
46  	public void testGetter() {
47  		final Credentials c = this.credentialsSource
48  				.getCredentials("http://www.cnn.com");
49  		assertNotNull(c);
50  		assertTrue(c instanceof UsernamePasswordCredentials);
51  
52  		final UsernamePasswordCredentials upc = (UsernamePasswordCredentials) c;
53  		assertEquals(USERNAME, upc.getUsername());
54  		assertEquals(PASSWORD, upc.getPassword());
55  
56  		assertEquals(CredentialsType.USERNAME_PASSWORD,
57  				this.credentialsSource.getSupportedCredentialsType());
58  	}
59  }