01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.bus.security.credentials;
17:
18: import java.util.Arrays;
19: import java.util.List;
20:
21: import junit.framework.TestCase;
22:
23: import org.kuali.rice.security.credentials.CredentialsSource;
24: import org.kuali.rice.security.credentials.CredentialsSourceFactory;
25: import org.kuali.rice.security.credentials.CredentialsSource.CredentialsType;
26:
27: /**
28: *
29: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
30: * @version $Revision: 1.2.16.1.6.1 $ $Date: 2007/10/17 20:32:06 $
31: * @since 0.9
32: *
33: */
34: public class CredentialsSourceFactoryTest extends TestCase {
35:
36: private CredentialsSourceFactory credentialsSourceFactory;
37:
38: @Override
39: protected void setUp() throws Exception {
40: final CredentialsSourceFactory credentialsSourceFactory = new CredentialsSourceFactory();
41: final List<CredentialsSource> credentialsSources = Arrays
42: .asList(new CredentialsSource[] {
43: new UsernamePasswordCredentialsSource("test",
44: "Test"),
45: new CasProxyTicketCredentialsSource() });
46:
47: credentialsSourceFactory
48: .setCredentialsSources(credentialsSources);
49: credentialsSourceFactory.afterPropertiesSet();
50:
51: this .credentialsSourceFactory = credentialsSourceFactory;
52: super .setUp();
53: }
54:
55: public void testCredentialsSourceExistsUsernamePassword() {
56: final CredentialsSource cs = this .credentialsSourceFactory
57: .getCredentialsForType(CredentialsType.USERNAME_PASSWORD);
58: assertNotNull(cs);
59: assertEquals(CredentialsType.USERNAME_PASSWORD, cs
60: .getSupportedCredentialsType());
61: }
62:
63: public void testCredentialsSourceExistsCas() {
64: final CredentialsSource cs = this .credentialsSourceFactory
65: .getCredentialsForType(CredentialsType.CAS);
66: assertNotNull(cs);
67: assertEquals(CredentialsType.CAS, cs
68: .getSupportedCredentialsType());
69: }
70:
71: public void testCredentialsSourceNotExists() {
72: final CredentialsSource cs = this.credentialsSourceFactory
73: .getCredentialsForType(CredentialsType.JAAS);
74: assertNull(cs);
75: }
76: }
|