diff options
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java | 44 | ||||
-rw-r--r-- | src/test/java/org/onap/clamp/clds/it/HttpsItCase.java | 24 |
2 files changed, 32 insertions, 36 deletions
diff --git a/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java b/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java index 69277baf9..beb07504a 100644 --- a/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/HttpConnectionManagerItCase.java @@ -69,23 +69,21 @@ public class HttpConnectionManagerItCase { @Autowired HttpConnectionManager httpConnectionManager; - private static TrustManager[] trustAllCerts = new TrustManager[]{ - new X509TrustManager() { + private static TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { - @Override - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return null; - } + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } - @Override - public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { - } + @Override + public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { + } - @Override - public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { - } + @Override + public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { } - }; + } }; private void enableSslNoCheck() throws NoSuchAlgorithmException, KeyManagementException { SSLContext sc = SSLContext.getInstance("SSL"); @@ -109,8 +107,8 @@ public class HttpConnectionManagerItCase { @Test public void testHttpGet() throws Exception { - String response = httpConnectionManager - .doHttpRequest("http://localhost:" + this.httpPort + "/designer/index.html", "GET", null, null, "DCAE", null, null); + String response = httpConnectionManager.doHttpRequest("http://localhost:" + this.httpPort + "/swagger.html", + "GET", null, null, "DCAE", null, null); assertNotNull(response); // Should be a redirection so 302, so empty assertTrue(response.isEmpty()); @@ -118,8 +116,8 @@ public class HttpConnectionManagerItCase { @Test public void testHttpsGet() throws Exception { - String response = httpConnectionManager - .doHttpRequest("https://localhost:" + this.httpsPort + "/designer/index.html", "GET", null, null, "DCAE", null, null); + String response = httpConnectionManager.doHttpRequest("https://localhost:" + this.httpsPort + "/swagger.html", + "GET", null, null, "DCAE", null, null); assertNotNull(response); // Should contain something assertTrue(!response.isEmpty()); @@ -127,22 +125,22 @@ public class HttpConnectionManagerItCase { @Test(expected = BadRequestException.class) public void testHttpsGet404() throws IOException { - httpConnectionManager.doHttpRequest("https://localhost:" + this.httpsPort + "/designer/index1.html", "GET", - null, null, "DCAE", null, null); + httpConnectionManager.doHttpRequest("https://localhost:" + this.httpsPort + "/swaggerx.html", "GET", null, null, + "DCAE", null, null); fail("Should have raised an BadRequestException"); } @Test(expected = BadRequestException.class) public void testHttpsPost404() throws IOException { - httpConnectionManager.doHttpRequest("https://localhost:" + this.httpsPort + "/designer/index1.html", "POST", - "", "application/json", "DCAE", null, null); + httpConnectionManager.doHttpRequest("https://localhost:" + this.httpsPort + "/swaggerx.html", "POST", "", + "application/json", "DCAE", null, null); fail("Should have raised an BadRequestException"); } @Test(expected = BadRequestException.class) public void testHttpException() throws IOException { - httpConnectionManager.doHttpRequest("http://localhost:" + this.httpsPort + "/designer/index.html", "GET", - null, null, "DCAE", null, null); + httpConnectionManager.doHttpRequest("http://localhost:" + this.httpsPort + "/swagger.html", "GET", null, null, + "DCAE", null, null); fail("Should have raised an BadRequestException"); } } diff --git a/src/test/java/org/onap/clamp/clds/it/HttpsItCase.java b/src/test/java/org/onap/clamp/clds/it/HttpsItCase.java index 57dbcf7a4..510e32736 100644 --- a/src/test/java/org/onap/clamp/clds/it/HttpsItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/HttpsItCase.java @@ -76,12 +76,12 @@ public class HttpsItCase { @Override public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) - throws java.security.cert.CertificateException { + throws java.security.cert.CertificateException { } @Override public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) - throws java.security.cert.CertificateException { + throws java.security.cert.CertificateException { } @Override @@ -89,9 +89,7 @@ public class HttpsItCase { return null; } }; - ctx.init(null, new TrustManager[] { - tm - }, null); + ctx.init(null, new TrustManager[] { tm }, null); SSLContext.setDefault(ctx); } catch (Exception ex) { ex.printStackTrace(); @@ -109,13 +107,13 @@ public class HttpsItCase { } }); template.setRequestFactory(factory); - ResponseEntity<String> entity = template - .getForEntity("http://localhost:" + this.httpPort + "/designer/index.html", String.class); + ResponseEntity<String> entity = template.getForEntity("http://localhost:" + this.httpPort + "/swagger.html", + String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND); ResponseEntity<String> httpsEntity = template - .getForEntity("https://localhost:" + this.httpsPort + "/designer/index.html", String.class); + .getForEntity("https://localhost:" + this.httpsPort + "/swagger.html", String.class); assertThat(httpsEntity.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(httpsEntity.getBody()).contains("CLDS"); + assertThat(httpsEntity.getBody()).contains("Clamp Rest API"); } @Test @@ -130,11 +128,11 @@ public class HttpsItCase { }); template.setRequestFactory(factory); ResponseEntity<String> httpsEntity = template - .getForEntity("https://localhost:" + this.httpsPort + "/restservices/clds/api-doc", String.class); + .getForEntity("https://localhost:" + this.httpsPort + "/restservices/clds/api-doc", String.class); assertThat(httpsEntity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(httpsEntity.getBody()).contains("swagger"); - FileUtils.writeStringToFile( - new File("docs/swagger/swagger.json"), httpsEntity.getBody(), Charset.defaultCharset()); + FileUtils.writeStringToFile(new File("docs/swagger/swagger.json"), httpsEntity.getBody(), + Charset.defaultCharset()); } /** @@ -151,7 +149,7 @@ public class HttpsItCase { @Override protected void prepareConnection(final HttpURLConnection connection, final String httpMethod) - throws IOException { + throws IOException { if (connection instanceof HttpsURLConnection) { ((HttpsURLConnection) connection).setHostnameVerifier(this.verifier); } |