001 /**
002 * Copyright 2005-2012 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.ksb.security.credentials;
017
018 import org.junit.Before;
019 import org.junit.Test;
020 import org.kuali.rice.core.api.security.credentials.Credentials;
021 import org.kuali.rice.core.api.security.credentials.CredentialsType;
022
023 import static org.junit.Assert.*;
024
025 /**
026 *
027 * @author Kuali Rice Team (rice.collab@kuali.org)
028 * @since 0.9
029 *
030 */
031 public class UsernamePasswordCredentialsSourceTest {
032
033 private static final String USERNAME = "username";
034
035 private static final String PASSWORD = "password";
036
037 private UsernamePasswordCredentialsSource credentialsSource;
038
039 @Before
040 public void setUp() throws Exception {
041 this.credentialsSource = new UsernamePasswordCredentialsSource(
042 USERNAME, PASSWORD);
043 }
044
045 @Test
046 public void testGetter() {
047 final Credentials c = this.credentialsSource
048 .getCredentials("http://www.cnn.com");
049 assertNotNull(c);
050 assertTrue(c instanceof UsernamePasswordCredentials);
051
052 final UsernamePasswordCredentials upc = (UsernamePasswordCredentials) c;
053 assertEquals(USERNAME, upc.getUsername());
054 assertEquals(PASSWORD, upc.getPassword());
055
056 assertEquals(CredentialsType.USERNAME_PASSWORD,
057 this.credentialsSource.getSupportedCredentialsType());
058 }
059 }