X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Frestclient%2Frest%2FRestClientBuilderTest.java;h=7155f9a3804413253ffdbae6838be2e37038f918;hb=ef858ed661134e651082675c091db056f8add98d;hp=013f8173cddbde4fdf8aa3e29dbcfd985bd6a4ba;hpb=9b97b575d3ebbd3df83fa6a6770e418bbcb546d0;p=aai%2Frest-client.git diff --git a/src/test/java/org/onap/aai/restclient/rest/RestClientBuilderTest.java b/src/test/java/org/onap/aai/restclient/rest/RestClientBuilderTest.java index 013f817..7155f9a 100644 --- a/src/test/java/org/onap/aai/restclient/rest/RestClientBuilderTest.java +++ b/src/test/java/org/onap/aai/restclient/rest/RestClientBuilderTest.java @@ -141,6 +141,7 @@ public class RestClientBuilderTest { restClientBuilder.setReadTimeoutInMs(54321); restClientBuilder.setBasicAuthUsername("username"); restClientBuilder.setBasicAuthPassword("password"); + restClientBuilder.setTruststoreFilename("truststore"); Client client = restClientBuilder.getClient(); @@ -155,7 +156,7 @@ public class RestClientBuilderTest { } - @Test + @Test (expected=IllegalArgumentException.class) public void validateSslCertClient_noHostOrCertChainValidation() throws Exception { RestClientBuilder restClientBuilder = new RestClientBuilder(); @@ -166,18 +167,10 @@ public class RestClientBuilderTest { restClientBuilder.setValidateServerCertChain(false); restClientBuilder.setValidateServerHostname(false); - Client client = restClientBuilder.getClient(); - - Object sslPropertiesObj = client.getProperties().get(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES); - HTTPSProperties sslProps = null; - if ( sslPropertiesObj instanceof HTTPSProperties ) { - sslProps = (HTTPSProperties)sslPropertiesObj; - assertNotNull(sslProps.getHostnameVerifier()); - } else { - fail("Unexpected value for https properties object"); - } } + Client client = restClientBuilder.getClient(); + } - @Test + @Test (expected=IllegalArgumentException.class) public void validateSslCertClient_hostOnlyValidation() throws Exception { RestClientBuilder restClientBuilder = new RestClientBuilder(); @@ -190,15 +183,7 @@ public class RestClientBuilderTest { Client client = restClientBuilder.getClient(); - Object sslPropertiesObj = client.getProperties().get(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES); - HTTPSProperties sslProps = null; - if ( sslPropertiesObj instanceof HTTPSProperties ) { - sslProps = (HTTPSProperties)sslPropertiesObj; - assertNull(sslProps.getHostnameVerifier()); - } else { - fail("Unexpected value for https properties object"); - } - } + } @Test public void validateSslCertClient_certChainOnlyValidation() throws Exception { @@ -269,5 +254,15 @@ public class RestClientBuilderTest { } + @Test + public void validateSslProtocolConfiguration() throws Exception { + + RestClientBuilder restClientBuilder = new RestClientBuilder(); + assertEquals(RestClientBuilder.DEFAULT_SSL_PROTOCOL, restClientBuilder.getSslProtocol()); + + restClientBuilder.setSslProtocol("TLSv1.2"); + assertEquals("TLSv1.2", restClientBuilder.getSslProtocol()); + + } }