source: josm/trunk/test/unit/org/openstreetmap/josm/io/CertificateAmendmentTestIT.java

Last change on this file was 19223, checked in by taylor.smock, 16 months ago

Add JUnit5 tags to integration tests, functional tests, and performance tests

This should allow contributors to filter out integration tests inside the standard
test directory. Of specific note, this should reduce test runtime for contributors
by a non-trivial amount if contributors filter out the tagged tests.

For consistencies’ sake, tests in functional and performance were also
annotated. As such, if we ever merge the test directories, this will let us
filter which tests are run in CI.

Note that many functional tests don't have the annotation. This is because they
are manual tests.

  • Property svn:eol-style set to native
File size: 3.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import static org.junit.jupiter.api.Assertions.fail;
5import static org.junit.jupiter.api.Assumptions.assumeFalse;
6
7import java.io.IOException;
8import java.net.URL;
9import java.net.URLConnection;
10import java.util.ArrayList;
11import java.util.List;
12
13import javax.net.ssl.SSLHandshakeException;
14
15import org.junit.jupiter.api.BeforeAll;
16import org.junit.jupiter.api.Test;
17import org.junit.jupiter.api.Timeout;
18import org.openstreetmap.josm.TestUtils;
19import org.openstreetmap.josm.testutils.annotations.HTTPS;
20import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
21
22/**
23 * Integration tests of {@link CertificateAmendment} class.
24 */
25@HTTPS
26@IntegrationTest
27@Timeout(20)
28class CertificateAmendmentTestIT {
29 private static final List<String> errorsToIgnore = new ArrayList<>();
30
31 /**
32 * Setup test
33 * @throws IOException in case of I/O error
34 */
35 @BeforeAll
36 public static void beforeClass() throws IOException {
37 errorsToIgnore.addAll(TestUtils.getIgnoredErrorMessages(CertificateAmendmentTestIT.class));
38 }
39
40 /**
41 * Test a well-known certificate.
42 * @throws IOException in case of I/O error
43 */
44 @Test
45 void testDefault() throws IOException {
46 // something that is not embedded
47 connect("https://www.bing.com", true);
48 }
49
50 /**
51 * Test <a href="https://letsencrypt.org">Let's Encrypt</a>.
52 * @throws IOException in case of I/O error
53 */
54 @Test
55 void testLetsEncrypt() throws IOException {
56 // signed by letsencrypt's own ISRG root
57 connect("https://valid-isrgrootx1.letsencrypt.org", true);
58 // signed by letsencrypt's cross-sign CA
59 connect("https://letsencrypt.org", true);
60 // signed by letsencrypt's cross-sign CA, requires SNI
61 connect("https://acme-v02.api.letsencrypt.org", true);
62 }
63
64 /**
65 * Test overpass API.
66 * @throws IOException in case of I/O error
67 */
68 @Test
69 void testOverpass() throws IOException {
70 connect("https://overpass-api.de", true);
71 }
72
73 /**
74 * Test Dutch government.
75 * @throws IOException in case of I/O error
76 */
77 @Test
78 void testDutchGovernment() throws IOException {
79 connect("https://www.nationaalgeoregister.nl", true);
80 }
81
82 /**
83 * Test Taiwan government.
84 * @throws IOException in case of I/O error
85 */
86 @Test
87 void testTaiwanGovernment() throws IOException {
88 connect("https://grca.nat.gov.tw", true);
89 }
90
91 private static void connect(String url, boolean shouldWork) throws IOException {
92 URLConnection connection = new URL(url).openConnection();
93 try {
94 connection.connect();
95 } catch (SSLHandshakeException e) {
96 String error = "Untrusted: " + url;
97 assumeFalse(errorsToIgnore.contains(error));
98 if (shouldWork) {
99 throw new IOException(error, e);
100 } else {
101 return;
102 }
103 }
104 String error = "Expected error: " + url;
105 assumeFalse(errorsToIgnore.contains(error));
106 if (!shouldWork) {
107 fail(error);
108 }
109 }
110}
Note: See TracBrowser for help on using the repository browser.