diff options
author | Kajur, Harish (vk250x) <vk250x@att.com> | 2019-04-10 13:46:17 -0400 |
---|---|---|
committer | Kajur, Harish (vk250x) <vk250x@att.com> | 2019-04-10 14:46:50 -0400 |
commit | 3501e74711a2e91ce84d0b4cbc989738f96e0891 (patch) | |
tree | cd99b4bbd91a775bec46a4a6a686e191bcfe6d0c /aai-schema-service/src/test | |
parent | d52076b0c1cb20eae678cfcf534988d3d0618c34 (diff) |
Add additional logging statements1.0.2
Fix the metaspace issue
Respond to an invalid content-type appropriately
Add getTool.sh to the scripts
Issue-ID: AAI-2326
Change-Id: Ib4764ba71be78816e549f59ccbdab8ccb14dc4c0
Signed-off-by: Kajur, Harish (vk250x) <vk250x@att.com>
Diffstat (limited to 'aai-schema-service/src/test')
3 files changed, 84 insertions, 19 deletions
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java index 53a3e14..231fecc 100644 --- a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java +++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java @@ -47,6 +47,7 @@ import static org.junit.Assert.assertThat; @TestPropertySource(locations = "classpath:application-test.properties") @ContextConfiguration(initializers = PropertyPasswordConfiguration.class) @Import(SchemaServiceTestConfiguration.class) + @RunWith(SpringRunner.class) public class SchemaServiceTest { @@ -86,7 +87,7 @@ public class SchemaServiceTest { headers.add("X-TransactionId", "JUNIT"); headers.add("Authorization", "Basic " + authorization); httpEntity = new HttpEntity(headers); - baseUrl = "https://localhost:" + randomPort; + baseUrl = "http://localhost:" + randomPort; } @Test @@ -126,6 +127,59 @@ public class SchemaServiceTest { } @Test + public void testInvalidSchemaAndEdges(){ + + headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_XML)); + headers.setContentType(MediaType.APPLICATION_XML); + headers.add("Real-Time", "true"); + headers.add("X-FromAppId", "JUNIT"); + headers.add("X-TransactionId", "JUNIT"); + headers.add("Authorization", "Basic " + authorization); + httpEntity = new HttpEntity(headers); + + ResponseEntity responseEntity; + + responseEntity = restTemplate.exchange( + baseUrl + "/aai/schema-service/v1/nodes?version=blah", + HttpMethod.GET, + httpEntity, + String.class + ); + System.out.println(" "+responseEntity.getBody()); + assertThat(responseEntity.getStatusCodeValue(), is(400)); + + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.setContentType(MediaType.APPLICATION_JSON); + httpEntity = new HttpEntity(headers); + + responseEntity = restTemplate.exchange( + baseUrl + "/aai/schema-service/v1/edgerules?version=blah", + HttpMethod.GET, + httpEntity, + String.class + ); + + assertThat(responseEntity.getStatusCodeValue(), is(400)); + } + + @Test + public void testVersions(){ + + ResponseEntity responseEntity; + + responseEntity = restTemplate.exchange( + baseUrl + "/aai/schema-service/v1/versions", + HttpMethod.GET, + httpEntity, + String.class + ); + assertThat(responseEntity.getStatusCodeValue(), is(200)); + + + } + + @Test public void testGetStoredQueriesSuccess(){ ResponseEntity responseEntity; diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java index 5d4c187..1e2de5e 100644 --- a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java +++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java @@ -58,30 +58,38 @@ public class SchemaServiceTestConfiguration { @Bean RestTemplate restTemplate(RestTemplateBuilder builder) throws Exception { - char[] trustStorePassword = env.getProperty("server.ssl.trust-store-password").toCharArray(); - char[] keyStorePassword = env.getProperty("server.ssl.key-store-password").toCharArray(); - String keyStore = env.getProperty("server.ssl.key-store"); - String trustStore = env.getProperty("server.ssl.trust-store"); - SSLContextBuilder sslContextBuilder = SSLContextBuilder.create(); + RestTemplate restTemplate = null; - if(env.acceptsProfiles("two-way-ssl")){ - sslContextBuilder = sslContextBuilder.loadKeyMaterial(loadPfx(keyStore, keyStorePassword), keyStorePassword); - } + if(env.acceptsProfiles("one-way-ssl", "two-way-ssl")) { + char[] trustStorePassword = env.getProperty("server.ssl.trust-store-password").toCharArray(); + char[] keyStorePassword = env.getProperty("server.ssl.key-store-password").toCharArray(); + + String keyStore = env.getProperty("server.ssl.key-store"); + String trustStore = env.getProperty("server.ssl.trust-store"); + SSLContextBuilder sslContextBuilder = SSLContextBuilder.create(); + + if (env.acceptsProfiles("two-way-ssl")) { + sslContextBuilder = sslContextBuilder.loadKeyMaterial(loadPfx(keyStore, keyStorePassword), keyStorePassword); + } - SSLContext sslContext = sslContextBuilder + SSLContext sslContext = sslContextBuilder .loadTrustMaterial(ResourceUtils.getFile(trustStore), trustStorePassword) .build(); - HttpClient client = HttpClients.custom() + HttpClient client = HttpClients.custom() .setSSLContext(sslContext) .setSSLHostnameVerifier((s, sslSession) -> true) .build(); - RestTemplate restTemplate = builder + restTemplate = builder .requestFactory(new HttpComponentsClientHttpRequestFactory(client)) .build(); + }else { + restTemplate = builder.build(); + } + restTemplate.setErrorHandler(new ResponseErrorHandler() { @Override diff --git a/aai-schema-service/src/test/resources/application-test.properties b/aai-schema-service/src/test/resources/application-test.properties index 2e0cda1..5f57a30 100644 --- a/aai-schema-service/src/test/resources/application-test.properties +++ b/aai-schema-service/src/test/resources/application-test.properties @@ -12,20 +12,23 @@ jetty.threadPool.maxThreads=200 jetty.threadPool.minThreads=8 #The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads server.tomcat.max-idle-time=60000 + # If you get an application startup failure that the port is already taken # If thats not it, please check if the key-store file path makes sense server.local.startpath=src/main/resources/ server.basic.auth.location=${server.local.startpath}etc/auth/realm.properties server.port=8452 +security.require-ssl=false +server.ssl.enabled=false # Server SSL Related Attributes -server.ssl.enabled-protocols=TLSv1.1,TLSv1.2 -server.ssl.key-store=${server.local.startpath}etc/auth/aai_keystore -server.ssl.key-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0) -server.ssl.trust-store=${server.local.startpath}etc/auth/aai_keystore -server.ssl.trust-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0) -server.ssl.client-auth=want -server.ssl.key-store-type=JKS +#server.ssl.enabled-protocols=TLSv1.1,TLSv1.2 +#server.ssl.key-store=${server.local.startpath}etc/auth/aai_keystore +#server.ssl.key-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0) +#server.ssl.trust-store=${server.local.startpath}etc/auth/aai_keystore +#server.ssl.trust-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0) +#server.ssl.client-auth=want +#server.ssl.key-store-type=JKS # Schema related attributes for the oxm and edges # Any additional schema related attributes should start with prefix schema |