diff options
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt')
-rw-r--r-- | ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt index 0d187fbc2..64f3f10ac 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt @@ -39,6 +39,7 @@ import org.springframework.test.context.junit4.SpringRunner import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertNotNull +import kotlin.test.assertTrue @RunWith(SpringRunner::class) @ContextConfiguration( @@ -198,6 +199,40 @@ class BluePrintRestLibPropertyServiceTest { } @Test + fun testSSLNoDefHeadersPropertiesAsJson() { + val actualObj: JsonNode = defaultMapper.readTree(sslNoDefHeadersField()) + val properties = bluePrintRestLibPropertyService.restClientProperties( + actualObj + ) + assertNotNull(properties, "failed to create property bean") + + val p: SSLRestClientProperties = + properties as SSLRestClientProperties + + assertEquals("src/test/resources/keystore.p12", p.sslTrust) + assertEquals("changeit", p.sslTrustPassword) + assertEquals("PKCS12", p.keyStoreInstance) + assertEquals("src/test/resources/keystore.p12", p.sslKey) + assertEquals("changeit", p.sslKeyPassword) + assertEquals("ssl-no-def-headers", p.type) + assertEquals("https://localhost:8443", p.url) + assertTrue(p.values.containsKey("type")) + } + + @Test + fun testNoDefHeadersPropertiesAsJson() { + val actualObj: JsonNode = defaultMapper.readTree(noDefaultHeadersField()) + val p = bluePrintRestLibPropertyService.restClientProperties( + actualObj + ) + assertNotNull(p, "failed to create property bean") + + assertEquals("no-def-headers", p.type) + assertEquals("http://127.0.0.1:8000", p.url) + assertTrue(p.values.containsKey("type")) + } + + @Test fun testBlueprintWebClientService() { val blueprintWebClientService = bluePrintRestLibPropertyService .blueprintWebClientService("sample") @@ -215,6 +250,22 @@ class BluePrintRestLibPropertyServiceTest { assertNotNull(blueprintWebClientService, "failed to create blueprintWebClientService") } + @Test + fun testNoHeadersForNoDefaultHeaderService() { + val actualObj: JsonNode = defaultMapper.readTree(noDefaultHeadersField()) + val blueprintWebClientService = bluePrintRestLibPropertyService + .blueprintWebClientService(actualObj) + assertEquals(0, blueprintWebClientService.defaultHeaders().size) + } + + @Test + fun testNoHeadersForSSLNoDefaultHeaderService() { + val actualObj: JsonNode = defaultMapper.readTree(sslNoDefHeadersField()) + val blueprintWebClientService = bluePrintRestLibPropertyService + .blueprintWebClientService(actualObj) + assertEquals(0, blueprintWebClientService.defaultHeaders().size) + } + // pass the result of $typeEndpointWithHeadersField() output with and without headers to compare. private fun validateHeadersDidNotChangeWithEmptyAdditionalHeaders(noHeaders: String, withHeaders: String) { val parsedObj: JsonNode = defaultMapper.readTree(noHeaders) @@ -480,6 +531,17 @@ class BluePrintRestLibPropertyServiceTest { } """.trimIndent() + private fun sslNoDefHeadersField(): String = """{ + "type" : "ssl-no-def-headers", + "url" : "https://localhost:8443", + "keyStoreInstance" : "PKCS12", + "sslTrust" : "src/test/resources/keystore.p12", + "sslTrustPassword" : "changeit", + "sslKey" : "src/test/resources/keystore.p12", + "sslKeyPassword" : "changeit" + } + """.trimIndent() + // Don't forget to supply "," as the first char to make valid JSON private fun basicAuthEndpointWithHeadersField(headers: String = ""): String = """{ @@ -490,6 +552,13 @@ class BluePrintRestLibPropertyServiceTest { } """.trimIndent() + private fun noDefaultHeadersField(): String = + """{ + "type": "no-def-headers", + "url": "http://127.0.0.1:8000" + } + """.trimIndent() + private val emptyAdditionalHeaders = """, "additionalHeaders" : { } |