2525import org .apache .http .impl .client .HttpClientBuilder ;
2626import org .apache .http .impl .client .HttpClients ;
2727import org .apache .http .impl .conn .PoolingClientConnectionManager ;
28- import org .junit .Ignore ;
2928import org .junit .Test ;
3029
3130/**
3231 * This test requires a localhost server over HTTPS <br>
3332 * It should only be manually run, not part of the automated build
3433 * */
35- public class HttpsClientLiveManualTest {
34+ public class HttpsClientSslLiveTest {
35+
36+ // "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1" // local
37+ // "https://mms.nw.ru/" // hosted
38+ private static final String HOST_WITH_SSL = "https://mms.nw.ru/" ;
3639
3740 // tests
3841
3942 @ Test (expected = SSLPeerUnverifiedException .class )
40- @ Ignore ("Only for a server that has HTTPS enabled (on 8443)" )
4143 public final void whenHttpsUrlIsConsumed_thenException () throws ClientProtocolException , IOException {
4244 final CloseableHttpClient httpClient = HttpClientBuilder .create ().build ();
4345
44- final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1" ;
45- final HttpGet getMethod = new HttpGet (urlOverHttps );
46+ final HttpGet getMethod = new HttpGet (HOST_WITH_SSL );
4647 final HttpResponse response = httpClient .execute (getMethod );
4748 assertThat (response .getStatusLine ().getStatusCode (), equalTo (200 ));
4849 }
@@ -58,13 +59,12 @@ public final boolean isTrusted(final X509Certificate[] certificate, final String
5859 };
5960 final SSLSocketFactory sf = new SSLSocketFactory (acceptingTrustStrategy , SSLSocketFactory .ALLOW_ALL_HOSTNAME_VERIFIER );
6061 final SchemeRegistry registry = new SchemeRegistry ();
61- registry .register (new Scheme ("https" , 8443 , sf ));
62+ registry .register (new Scheme ("https" , 443 , sf ));
6263 final ClientConnectionManager ccm = new PoolingClientConnectionManager (registry );
6364
6465 final CloseableHttpClient httpClient = new DefaultHttpClient (ccm );
6566
66- final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1" ;
67- final HttpGet getMethod = new HttpGet (urlOverHttps );
67+ final HttpGet getMethod = new HttpGet (HOST_WITH_SSL );
6868 final HttpResponse response = httpClient .execute (getMethod );
6969 assertThat (response .getStatusLine ().getStatusCode (), equalTo (200 ));
7070
@@ -80,8 +80,7 @@ public final void givenHttpClientPost4_3_whenAcceptingAllCertificates_thenCanCon
8080
8181 // new
8282
83- final String urlOverHttps = "https://localhost:8443/spring-security-rest-basic-auth/api/bars/1" ;
84- final HttpGet getMethod = new HttpGet (urlOverHttps );
83+ final HttpGet getMethod = new HttpGet (HOST_WITH_SSL );
8584 final HttpResponse response = httpClient .execute (getMethod );
8685 assertThat (response .getStatusLine ().getStatusCode (), equalTo (200 ));
8786 }
0 commit comments