diff options
author | 2020-09-22 12:16:46 -0400 | |
---|---|---|
committer | 2020-09-22 13:49:05 -0400 | |
commit | 1072867dfac0df993cbd3e44bcc11a5cac7465fd (patch) | |
tree | 4a821659cf3b50cf946cbb535d528be8508e9fff /ms/blueprintsprocessor/modules/commons/rest-lib/src/test | |
parent | d97021cd756d63402545fdc2e14ac7611c3da118 (diff) |
Enabling Code Formatter
Code Formatter was turned off due to java 11 migation
Issue-ID: CCSDK-2852
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Change-Id: I3d02ed3cc7a93d7551fe25356512cfe8db1517d8
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/rest-lib/src/test')
2 files changed, 103 insertions, 86 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 53047d4a8..f45d1cd69 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 @@ -42,35 +42,38 @@ import kotlin.test.assertNotNull @RunWith(SpringRunner::class) @ContextConfiguration( - classes = [BluePrintRestLibConfiguration::class, BluePrintPropertyConfiguration::class, - BluePrintPropertiesService::class] + classes = [ + BluePrintRestLibConfiguration::class, BluePrintPropertyConfiguration::class, + BluePrintPropertiesService::class + ] ) @TestPropertySource( properties = - ["blueprintsprocessor.restclient.sample.type=basic-auth", - "blueprintsprocessor.restclient.sample.url=http://localhost:8080", - "blueprintsprocessor.restclient.sample.userId=sampleuser", - "blueprintsprocessor.restclient.sslbasic.type=ssl-basic-auth", - "blueprintsprocessor.restclient.sslbasic.url=https://localhost:8443", - "blueprintsprocessor.restclient.sslbasic.username=admin", - "blueprintsprocessor.restclient.sslbasic.password=cds", - "blueprintsprocessor.restclient.sslbasic.keyStoreInstance=PKCS12", - "blueprintsprocessor.restclient.sslbasic.sslTrust=src/test/resources/keystore.p12", - "blueprintsprocessor.restclient.sslbasic.sslTrustPassword=changeit", - "blueprintsprocessor.restclient.ssltoken.type=ssl-token-auth", - "blueprintsprocessor.restclient.ssltoken.url=https://localhost:8443", - "blueprintsprocessor.restclient.ssltoken.token=72178473kjshdkjgvbsdkjv903274908", - "blueprintsprocessor.restclient.ssltoken.keyStoreInstance=PKCS12", - "blueprintsprocessor.restclient.ssltoken.sslTrust=src/test/resources/keystore.p12", - "blueprintsprocessor.restclient.ssltoken.sslTrustPassword=changeit", - "blueprintsprocessor.restclient.ssl.type=ssl-no-auth", - "blueprintsprocessor.restclient.ssl.url=https://localhost:8443", - "blueprintsprocessor.restclient.ssl.keyStoreInstance=PKCS12", - "blueprintsprocessor.restclient.ssl.sslTrust=src/test/resources/keystore.p12", - "blueprintsprocessor.restclient.ssl.sslTrustPassword=changeit", - "blueprintsprocessor.restclient.ssl.sslKey=src/test/resources/keystore.p12", - "blueprintsprocessor.restclient.ssl.sslKeyPassword=changeit" - ] + [ + "blueprintsprocessor.restclient.sample.type=basic-auth", + "blueprintsprocessor.restclient.sample.url=http://localhost:8080", + "blueprintsprocessor.restclient.sample.userId=sampleuser", + "blueprintsprocessor.restclient.sslbasic.type=ssl-basic-auth", + "blueprintsprocessor.restclient.sslbasic.url=https://localhost:8443", + "blueprintsprocessor.restclient.sslbasic.username=admin", + "blueprintsprocessor.restclient.sslbasic.password=cds", + "blueprintsprocessor.restclient.sslbasic.keyStoreInstance=PKCS12", + "blueprintsprocessor.restclient.sslbasic.sslTrust=src/test/resources/keystore.p12", + "blueprintsprocessor.restclient.sslbasic.sslTrustPassword=changeit", + "blueprintsprocessor.restclient.ssltoken.type=ssl-token-auth", + "blueprintsprocessor.restclient.ssltoken.url=https://localhost:8443", + "blueprintsprocessor.restclient.ssltoken.token=72178473kjshdkjgvbsdkjv903274908", + "blueprintsprocessor.restclient.ssltoken.keyStoreInstance=PKCS12", + "blueprintsprocessor.restclient.ssltoken.sslTrust=src/test/resources/keystore.p12", + "blueprintsprocessor.restclient.ssltoken.sslTrustPassword=changeit", + "blueprintsprocessor.restclient.ssl.type=ssl-no-auth", + "blueprintsprocessor.restclient.ssl.url=https://localhost:8443", + "blueprintsprocessor.restclient.ssl.keyStoreInstance=PKCS12", + "blueprintsprocessor.restclient.ssl.sslTrust=src/test/resources/keystore.p12", + "blueprintsprocessor.restclient.ssl.sslTrustPassword=changeit", + "blueprintsprocessor.restclient.ssl.sslKey=src/test/resources/keystore.p12", + "blueprintsprocessor.restclient.ssl.sslKeyPassword=changeit" + ] ) class BluePrintRestLibPropertyServiceTest { @@ -84,8 +87,9 @@ class BluePrintRestLibPropertyServiceTest { ) assertNotNull(properties, "failed to create property bean") assertNotNull( - properties.url, "failed to get url property in" + - " property bean" + properties.url, + "failed to get url property in" + + " property bean" ) } @@ -424,6 +428,7 @@ class BluePrintRestLibPropertyServiceTest { } companion object BluePrintRestLibPropertyServiceTest { + val defaultMapper = ObjectMapper() val expectedTokenAuthDefaultHeaders = mapOf<String, String>( "Content-Type" to "application/json", @@ -435,7 +440,8 @@ class BluePrintRestLibPropertyServiceTest { """, "additionalHeaders" : { "authorization": "Basic aGF2ZTphbmljZWRheQo=" - }""".trimIndent() + } + """.trimIndent() ) private fun sslTokenAuthEndpointWithHeadersField(headers: String = ""): String = @@ -462,7 +468,8 @@ class BluePrintRestLibPropertyServiceTest { "username" : "admin", "password" : "cds" }$headers - }""".trimIndent() + } + """.trimIndent() private fun sslNoAuthEndpointWithHeadersField(headers: String = ""): String = """{ "type" : "ssl-no-auth", @@ -472,7 +479,8 @@ class BluePrintRestLibPropertyServiceTest { "sslTrustPassword" : "changeit", "sslKey" : "src/test/resources/keystore.p12", "sslKeyPassword" : "changeit"$headers - }""".trimIndent() + } + """.trimIndent() // Don't forget to supply "," as the first char to make valid JSON private fun basicAuthEndpointWithHeadersField(headers: String = ""): String = @@ -481,37 +489,44 @@ class BluePrintRestLibPropertyServiceTest { "url": "http://127.0.0.1:8000", "username": "user", "password": "pass"$headers - }""".trimIndent() + } + """.trimIndent() private val emptyAdditionalHeaders = """, "additionalHeaders" : { - }""".trimIndent() + } + """.trimIndent() private val oneAdditionalParameter = """, "additionalHeaders" : { "key1": "value1" - }""".trimIndent() + } + """.trimIndent() private val threeAdditionalHeaders = """, "additionalHeaders" : { "key1": "value1", "key2": "value2", "key3": "value3" - }""".trimIndent() + } + """.trimIndent() private val contentTypeAdditionalHeader = """, "additionalHeaders" : { "${HttpHeaders.CONTENT_TYPE}": "${MediaType.APPLICATION_XML}" - }""".trimIndent() + } + """.trimIndent() private val additionalHeadersWithAuth = """, "additionalHeaders" : { "Authorization": "Basic aGF2ZTphbmljZWRheQo=" - }""".trimIndent() + } + """.trimIndent() private val additionalHeadersWithAuthLowercased = """, "additionalHeaders" : { "authorization": "Basic aGF2ZTphbmljZWRheQo=" - }""".trimIndent() + } + """.trimIndent() } } diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt index ea202481e..74e3807f7 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt @@ -65,31 +65,33 @@ import kotlin.test.assertNotNull @EnableAutoConfiguration(exclude = [DataSourceAutoConfiguration::class]) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @ContextConfiguration( - classes = [BluePrintRestLibConfiguration::class, SampleController::class, + classes = [ + BluePrintRestLibConfiguration::class, SampleController::class, SecurityConfiguration::class, - BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class] + BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class + ] ) @TestPropertySource( properties = - [ - "server.port=8443", - "server.ssl.enabled=true", - "server.ssl.key-store=classpath:keystore.p12", - "server.ssl.key-store-password=changeit", - "server.ssl.keyStoreType=PKCS12", - "server.ssl.keyAlias=tomcat", - "blueprintsprocessor.restclient.sample.type=basic-auth", - "blueprintsprocessor.restclient.sample.url=http://127.0.0.1:9081", - "blueprintsprocessor.restclient.sample.username=admin", - "blueprintsprocessor.restclient.sample.password=jans", - "blueprintsprocessor.restclient.test.type=ssl-basic-auth", - "blueprintsprocessor.restclient.test.url=https://localhost:8443", - "blueprintsprocessor.restclient.test.username=admin", - "blueprintsprocessor.restclient.test.password=jans", - "blueprintsprocessor.restclient.test.keyStoreInstance=PKCS12", - "blueprintsprocessor.restclient.test.sslTrust=src/test/resources/keystore.p12", - "blueprintsprocessor.restclient.test.sslTrustPassword=changeit" - ] + [ + "server.port=8443", + "server.ssl.enabled=true", + "server.ssl.key-store=classpath:keystore.p12", + "server.ssl.key-store-password=changeit", + "server.ssl.keyStoreType=PKCS12", + "server.ssl.keyAlias=tomcat", + "blueprintsprocessor.restclient.sample.type=basic-auth", + "blueprintsprocessor.restclient.sample.url=http://127.0.0.1:9081", + "blueprintsprocessor.restclient.sample.username=admin", + "blueprintsprocessor.restclient.sample.password=jans", + "blueprintsprocessor.restclient.test.type=ssl-basic-auth", + "blueprintsprocessor.restclient.test.url=https://localhost:8443", + "blueprintsprocessor.restclient.test.username=admin", + "blueprintsprocessor.restclient.test.password=jans", + "blueprintsprocessor.restclient.test.keyStoreInstance=PKCS12", + "blueprintsprocessor.restclient.test.sslTrust=src/test/resources/keystore.p12", + "blueprintsprocessor.restclient.test.sslTrustPassword=changeit" + ] ) class RestClientServiceTest { @@ -119,26 +121,26 @@ class RestClientServiceTest { @Test fun testGetQueryParam() { val restClientService = bluePrintRestLibPropertyService - .blueprintWebClientService("sample") + .blueprintWebClientService("sample") val response = restClientService.exchangeResource( - HttpMethod.GET.name, "/sample/query?id=3", "" + HttpMethod.GET.name, "/sample/query?id=3", "" ) assertEquals( - "query with id:3", response.body, - "failed to get query param response" + "query with id:3", response.body, + "failed to get query param response" ) } @Test fun testGetPathParamWithWhitespace() { val restClientService = bluePrintRestLibPropertyService - .blueprintWebClientService("sample") + .blueprintWebClientService("sample") val response = restClientService.exchangeResource( - HttpMethod.GET.name, "/sample/path/id 3/get", "" + HttpMethod.GET.name, "/sample/path/id 3/get", "" ) assertEquals( - "path param id:id 3", response.body, - "failed to get query param response" + "path param id:id 3", response.body, + "failed to get query param response" ) } @@ -171,11 +173,11 @@ class RestClientServiceTest { @Test fun testSimpleBasicAuth() { val json: String = "{\n" + - " \"type\" : \"basic-auth\",\n" + - " \"url\" : \"http://localhost:9081\",\n" + - " \"username\" : \"admin\",\n" + - " \"password\" : \"jans\"\n" + - "}" + " \"type\" : \"basic-auth\",\n" + + " \"url\" : \"http://localhost:9081\",\n" + + " \"username\" : \"admin\",\n" + + " \"password\" : \"jans\"\n" + + "}" val mapper = ObjectMapper() val actualObj: JsonNode = mapper.readTree(json) val restClientService = bluePrintRestLibPropertyService @@ -203,13 +205,13 @@ class RestClientServiceTest { headers["X-TransactionId"] = "9999" headers["X-FromAppId"] = "AAI" val post1 = "{\n" + - " \"customer\": {\n" + - " \"global-customer-id\": \"ONSDEMOBJHKCustomer\",\n" + - " \"subscriber-name\": \"ONSDEMOBJHKCustomer\",\n" + - " \"subscriber-type\": \"CUST\",\n" + - " \"resource-version\": \"1552985011163\"\n" + - " }\n" + - "}" + " \"customer\": {\n" + + " \"global-customer-id\": \"ONSDEMOBJHKCustomer\",\n" + + " \"subscriber-name\": \"ONSDEMOBJHKCustomer\",\n" + + " \"subscriber-type\": \"CUST\",\n" + + " \"resource-version\": \"1552985011163\"\n" + + " }\n" + + "}" lateinit var res1: Customer lateinit var res2: Customer lateinit var res3: String @@ -307,11 +309,11 @@ open class SampleController { @GetMapping("/query") fun getQuery(@RequestParam("id") id: String): String = - "query with id:$id" + "query with id:$id" @GetMapping("/path/{id}/get") fun getPathParam(@PathVariable("id") id: String): String = - "path param id:$id" + "path param id:$id" @PatchMapping("/name") fun patchName(): String = "Patch request successful" @@ -330,11 +332,11 @@ open class SampleController { return "" } return "{\n" + - " \"id\": \"ONSDEMOBJHKCustomer\",\n" + - " \"name\": \"ONSDEMOBJHKCustomer\",\n" + - " \"type\": \"CUST\",\n" + - " \"resource\": \"1552985011163\"\n" + - "}" + " \"id\": \"ONSDEMOBJHKCustomer\",\n" + + " \"name\": \"ONSDEMOBJHKCustomer\",\n" + + " \"type\": \"CUST\",\n" + + " \"resource\": \"1552985011163\"\n" + + "}" } @PostMapping("/aai/v14/business/customers") |