001 /*
002 * Copyright 2007 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 junit.framework.TestCase;
019
020 import org.kuali.rice.core.security.credentials.Credentials;
021 import org.kuali.rice.core.security.credentials.CredentialsSource.CredentialsType;
022 import org.kuali.rice.ksb.security.credentials.UsernamePasswordCredentials;
023 import org.kuali.rice.ksb.security.credentials.UsernamePasswordCredentialsSource;
024
025 /**
026 *
027 * @author Kuali Rice Team (rice.collab@kuali.org)
028 * @since 0.9
029 *
030 */
031 public class UsernamePasswordCredentialsSourceTest extends TestCase {
032
033 private static final String USERNAME = "username";
034
035 private static final String PASSWORD = "password";
036
037 private UsernamePasswordCredentialsSource credentialsSource;
038
039 protected void setUp() throws Exception {
040 this.credentialsSource = new UsernamePasswordCredentialsSource(
041 USERNAME, PASSWORD);
042 super.setUp();
043 }
044
045 public void testGetter() {
046 final Credentials c = this.credentialsSource
047 .getCredentials("http://www.cnn.com");
048 assertNotNull(c);
049 assertTrue(c instanceof UsernamePasswordCredentials);
050
051 final UsernamePasswordCredentials upc = (UsernamePasswordCredentials) c;
052 assertEquals(USERNAME, upc.getUsername());
053 assertEquals(PASSWORD, upc.getPassword());
054
055 assertEquals(CredentialsType.USERNAME_PASSWORD,
056 this.credentialsSource.getSupportedCredentialsType());
057 }
058 }