summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatExecutor.kt16
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt18
2 files changed, 26 insertions, 8 deletions
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatExecutor.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatExecutor.kt
index 00e53c1a1..44f2e7d0d 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatExecutor.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/UatExecutor.kt
@@ -135,7 +135,7 @@ class UatExecutor(
log.info("Executing process '${process.name}'")
val responseNormalizer = JsonNormalizer.getNormalizer(mapper, process.responseNormalizerSpec)
val actualResponse = processBlueprint(
- client, process.request,
+ client, process,
process.expectedResponse, responseNormalizer
)
ProcessDefinition(
@@ -231,24 +231,24 @@ class UatExecutor(
@Throws(AssertionError::class)
private fun processBlueprint(
client: HttpClient,
- requestBody: JsonNode,
+ process: ProcessDefinition,
expectedResponse: JsonNode?,
responseNormalizer: (String) -> String
): JsonNode {
- val stringEntity = StringEntity(mapper.writeValueAsString(requestBody), ContentType.APPLICATION_JSON)
+ val stringEntity = StringEntity(mapper.writeValueAsString(process.request), ContentType.APPLICATION_JSON)
val request = HttpPost("$baseUrl/api/v1/execution-service/process").apply {
entity = stringEntity
}
val response = client.execute(request) { response ->
val statusLine = response.statusLine
- assertThat(statusLine.statusCode, equalTo(HttpStatus.SC_OK))
+ assertThat("${process.name}", statusLine.statusCode, equalTo(HttpStatus.SC_OK))
val entity = response.entity
- assertThat("Response contains no content", entity, notNullValue())
+ assertThat("${process.name} Response contains no content", entity, notNullValue())
entity.content.bufferedReader().use { it.readText() }
}
val actualResponse = responseNormalizer(response)
if (expectedResponse != null) {
- assertJsonEquals(expectedResponse, actualResponse)
+ assertJsonEquals(expectedResponse, actualResponse, process.name)
}
return mapper.readTree(actualResponse)!!
}
@@ -268,13 +268,13 @@ class UatExecutor(
}
@Throws(AssertionError::class)
- private fun assertJsonEquals(expected: JsonNode?, actual: String): Boolean {
+ private fun assertJsonEquals(expected: JsonNode?, actual: String, msg: String = ""): Boolean {
// special case
if ((expected == null) && actual.isBlank()) {
return true
}
// general case
- JSONAssert.assertEquals(expected?.toString(), actual, JSONCompareMode.LENIENT)
+ JSONAssert.assertEquals(msg, expected?.toString(), actual, JSONCompareMode.LENIENT)
// assertEquals throws an exception whenever match fails
return true
}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
index be9b849f6..5ab848893 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
@@ -16,8 +16,15 @@
package org.onap.ccsdk.cds.blueprintsprocessor.rest.service
+import org.apache.http.conn.ssl.NoopHostnameVerifier
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory
+import org.apache.http.conn.ssl.TrustAllStrategy
+import org.apache.http.impl.client.CloseableHttpClient
+import org.apache.http.impl.client.HttpClients
import org.apache.http.message.BasicHeader
+import org.apache.http.ssl.SSLContextBuilder
import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.utils.WebClientUtils
import org.springframework.http.HttpHeaders
import org.springframework.http.MediaType
import java.net.URI
@@ -48,6 +55,17 @@ class BasicAuthRestClientService(
return uri.resolve(uri).toString()
}
+ override fun httpClient(): CloseableHttpClient {
+ val sslContext = SSLContextBuilder.create()
+
+ sslContext.loadTrustMaterial(TrustAllStrategy.INSTANCE)
+ val csf = SSLConnectionSocketFactory(sslContext.build(), NoopHostnameVerifier())
+ return HttpClients.custom()
+ .addInterceptorFirst(WebClientUtils.logRequest())
+ .addInterceptorLast(WebClientUtils.logResponse())
+ .setSSLSocketFactory(csf).build()
+ }
+
override fun convertToBasicHeaders(headers: Map<String, String>):
Array<BasicHeader> {
val customHeaders: MutableMap<String, String> = headers.toMutableMap()