1 package net.trajano.commons.testing.test;
2
3 import javax.ws.rs.ProcessingException;
4 import javax.ws.rs.client.Client;
5 import javax.ws.rs.client.ClientBuilder;
6
7 import net.trajano.commons.testing.DisableSslCertificateCheckUtil;
8
9 import org.junit.Test;
10
11
12
13
14
15
16
17 public class DisableSslCertificateChecksJaxRsIT {
18
19
20
21
22 @Test
23 public void testHttpsConnectionToGoogle() throws Exception {
24 final Client client = ClientBuilder
25 .newBuilder()
26 .hostnameVerifier(
27 DisableSslCertificateCheckUtil.NULL_HOSTNAME_VERIFIER)
28 .sslContext(
29 DisableSslCertificateCheckUtil
30 .buildUnsecureSslContext()).build();
31 client.target(
32 "https://accounts.google.com/.well-known/openid-configuration")
33 .request().get();
34 }
35
36
37
38
39
40
41
42 @Test
43 public void testInvalidCertificate() throws Exception {
44 final Client client = ClientBuilder
45 .newBuilder()
46 .hostnameVerifier(
47 DisableSslCertificateCheckUtil.NULL_HOSTNAME_VERIFIER)
48 .sslContext(
49 DisableSslCertificateCheckUtil
50 .buildUnsecureSslContext()).build();
51 client.target("https://tv.eurosport.com/").request().get();
52 }
53
54
55
56
57
58
59
60 @Test(expected = ProcessingException.class)
61 public void testInvalidCertificateFailure() throws Exception {
62 final Client client = ClientBuilder.newClient();
63 client.target("https://tv.eurosport.com/").request().get();
64 }
65 }