Changeset 14089 in josm for trunk/test
- Timestamp:
- 2018-08-05T16:51:25+02:00 (6 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/io
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/io/CertificateAmendmentTest.java
r13944 r14089 2 2 package org.openstreetmap.josm.io; 3 3 4 import java.io.IOException;5 import java.net.URL;6 import java.net.URLConnection;7 8 import javax.net.ssl.SSLHandshakeException;9 10 import org.junit.Assert;11 4 import org.junit.Rule; 12 5 import org.junit.Test; … … 26 19 @Rule 27 20 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 28 public JOSMTestRules test = new JOSMTestRules() .platform().https().timeout(20000);21 public JOSMTestRules test = new JOSMTestRules(); 29 22 30 23 /** … … 36 29 UtilityClassTestUtil.assertUtilityClassWellDefined(CertificateAmendment.class); 37 30 } 38 39 /**40 * Test a well-known certificate.41 * @throws IOException in case of I/O error42 */43 @Test44 public void testDefault() throws IOException {45 // something that is not embedded46 connect("https://www.bing.com", true);47 }48 49 /**50 * Test <a href="https://letsencrypt.org">Let's Encrypt</a>.51 * @throws IOException in case of I/O error52 */53 @Test54 public void testLetsEncrypt() throws IOException {55 // signed by letsencrypt's own ISRG root56 // (not included yet)57 // TODO: they switched to cross-sign CA, re-enable it if ISRG root is used again58 // connect("https://helloworld.letsencrypt.org", false);59 // signed by letsencrypt's cross-sign CA60 connect("https://letsencrypt.org", true);61 // signed by letsencrypt's cross-sign CA, requires SNI62 connect("https://acme-v01.api.letsencrypt.org", true);63 }64 65 /**66 * Test a broken certificate.67 * @throws IOException in case of I/O error68 */69 @Test70 public void testBrokenCert() throws IOException {71 // broken at the moment (may get fixed some day)72 connect("https://www.pcwebshop.co.uk", false);73 }74 75 /**76 * Test overpass API.77 * @throws IOException in case of I/O error78 */79 @Test80 public void testOverpass() throws IOException {81 connect("https://overpass-api.de", true);82 }83 84 /**85 * Test Dutch government.86 * @throws IOException in case of I/O error87 */88 @Test89 public void testDutchGovernment() throws IOException {90 connect("https://geodata.nationaalgeoregister.nl", true);91 }92 93 private static void connect(String url, boolean shouldWork) throws IOException {94 URLConnection connection = new URL(url).openConnection();95 try {96 connection.connect();97 } catch (SSLHandshakeException e) {98 if (shouldWork) {99 e.printStackTrace();100 Assert.fail("Untrusted: " + url);101 } else {102 return;103 }104 }105 if (!shouldWork) {106 Assert.fail("Expected error: " + url);107 }108 }109 31 }
Note:
See TracChangeset
for help on using the changeset viewer.