1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
28
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 }