1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.io;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
---|
5 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
6 | import static org.junit.jupiter.api.Assertions.assertFalse;
|
---|
7 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
---|
8 |
|
---|
9 | import org.junit.jupiter.api.extension.RegisterExtension;
|
---|
10 | import org.junit.jupiter.api.Test;
|
---|
11 | import org.openstreetmap.josm.gui.io.CredentialDialog.CredentialPanel;
|
---|
12 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
13 |
|
---|
14 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Unit tests of {@link CredentialDialog} class.
|
---|
18 | */
|
---|
19 | class CredentialDialogTest {
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Setup tests
|
---|
23 | */
|
---|
24 | @RegisterExtension
|
---|
25 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
26 | public JOSMTestRules test = new JOSMTestRules().preferences();
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Test of {@link CredentialDialog.CredentialPanel} class.
|
---|
30 | */
|
---|
31 | @Test
|
---|
32 | void testCredentialPanel() {
|
---|
33 | CredentialPanel cp = new CredentialPanel(null);
|
---|
34 | cp.build();
|
---|
35 |
|
---|
36 | cp.init(null, null);
|
---|
37 | assertEquals("", cp.getUserName());
|
---|
38 | assertArrayEquals("".toCharArray(), cp.getPassword());
|
---|
39 | assertFalse(cp.isSaveCredentials());
|
---|
40 |
|
---|
41 | cp.init("user", "password");
|
---|
42 | assertEquals("user", cp.getUserName());
|
---|
43 | assertArrayEquals("password".toCharArray(), cp.getPassword());
|
---|
44 | assertTrue(cp.isSaveCredentials());
|
---|
45 |
|
---|
46 | cp.updateWarningLabel(null);
|
---|
47 | cp.updateWarningLabel("http://something_insecure");
|
---|
48 | cp.updateWarningLabel("https://something_secure");
|
---|
49 |
|
---|
50 | cp.startUserInput();
|
---|
51 | }
|
---|
52 | }
|
---|