1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.mail; |
21 |
|
|
22 |
|
import javax.mail.PasswordAuthentication; |
23 |
|
|
24 |
|
import org.junit.Test; |
25 |
|
|
26 |
|
import static org.hamcrest.CoreMatchers.equalTo; |
27 |
|
import static org.junit.Assert.assertThat; |
28 |
|
import static org.mockito.Mockito.mock; |
29 |
|
import static org.mockito.Mockito.when; |
30 |
|
|
31 |
|
|
32 |
|
@link |
33 |
|
|
34 |
|
@version |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.14 |
|
36 |
|
public class XWikiAuthenticatorTest |
37 |
|
{ |
38 |
|
private static final String MAIL_USER = "mailuser"; |
39 |
|
|
40 |
|
private static final String MAIL_PASSWORD = "mailpassword"; |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
42 |
1 |
@Test... |
43 |
|
public void testJavaMailPasswordAuthentication() throws Exception |
44 |
|
{ |
45 |
1 |
MailSenderConfiguration mailSenderConfiguration = mock(MailSenderConfiguration.class); |
46 |
1 |
when(mailSenderConfiguration.getUsername()).thenReturn(MAIL_USER); |
47 |
1 |
when(mailSenderConfiguration.getPassword()).thenReturn(MAIL_PASSWORD); |
48 |
|
|
49 |
1 |
XWikiAuthenticator xWikiAuthenticator = new XWikiAuthenticator(mailSenderConfiguration); |
50 |
1 |
PasswordAuthentication passwordAuthentication = xWikiAuthenticator.getPasswordAuthentication(); |
51 |
|
|
52 |
1 |
assertThat(passwordAuthentication.getUserName(), equalTo(MAIL_USER)); |
53 |
1 |
assertThat(passwordAuthentication.getPassword(), equalTo(MAIL_PASSWORD)); |
54 |
|
} |
55 |
|
} |