diff options
author | janani b <janani.b@huawei.com> | 2019-04-02 17:53:56 +0530 |
---|---|---|
committer | janani b <janani.b@huawei.com> | 2019-04-02 21:21:58 +0530 |
commit | fd2d0db7e2a0a2d27db0cfeac95959dcfb789910 (patch) | |
tree | 2fd59140a4af0346912a43e34c038fc9afd0a8d4 /ms/blueprintsprocessor/modules/commons/rest-lib/src/test | |
parent | cb74139eb31d5bdaa6eb390ae7eebaf49729b7e4 (diff) |
Updating Rest code for AAI resolution
This commit includes,
i) Updated the SSL based rest connection for different auth support
ii) Checked the co-routines based rest connection
Issue-ID: CCSDK-692
Change-Id: Ic2fe5e5292c9190670d2a573598d78e94f59efb0
Signed-off-by: janani b <janani.b@huawei.com>
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/rest-lib/src/test')
3 files changed, 459 insertions, 18 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 c57745713..280dd0d40 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 @@ -1,6 +1,7 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. + * Modifications Copyright © 2019 Huawei. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,24 +18,50 @@ package org.onap.ccsdk.cds.blueprintsprocessor.rest.service +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.ObjectMapper import org.junit.Test import org.junit.runner.RunWith import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.rest.BluePrintRestLibConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.rest.SSLBasicAuthRestClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.rest.SSLRestClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.rest.SSLTokenAuthRestClientProperties import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner +import kotlin.test.assertEquals import kotlin.test.assertNotNull - @RunWith(SpringRunner::class) @ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BlueprintPropertyConfiguration::class, BluePrintProperties::class]) @TestPropertySource(properties = ["blueprintsprocessor.restclient.sample.type=basic-auth", "blueprintsprocessor.restclient.sample.url=http://localhost:8080", - "blueprintsprocessor.restclient.sample.userId=sampleuser"]) + "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 { @@ -43,15 +70,148 @@ class BluePrintRestLibPropertyServiceTest { @Test fun testRestClientProperties() { - val properties = bluePrintRestLibPropertyService.restClientProperties("blueprintsprocessor.restclient.sample") + val properties = bluePrintRestLibPropertyService.restClientProperties( + "blueprintsprocessor.restclient.sample") + assertNotNull(properties, "failed to create property bean") + assertNotNull(properties.url, "failed to get url property in" + + " property bean") + } + + @Test + fun testSSLBasicProperties() { + val properties = bluePrintRestLibPropertyService.restClientProperties( + "blueprintsprocessor.restclient.sslbasic") + assertNotNull(properties, "failed to create property bean") + val p: SSLBasicAuthRestClientProperties = + properties as SSLBasicAuthRestClientProperties + + assertEquals(p.basicAuth!!.username, "admin") + assertEquals(p.basicAuth!!.password, "cds") + assertEquals(p.sslTrust, "src/test/resources/keystore.p12") + assertEquals(p.sslTrustPassword, "changeit") + assertEquals(p.keyStoreInstance, "PKCS12") + } + + @Test + fun testSSLTokenProperties() { + val properties = bluePrintRestLibPropertyService.restClientProperties( + "blueprintsprocessor.restclient.ssltoken") + assertNotNull(properties, "failed to create property bean") + + val p: SSLTokenAuthRestClientProperties = + properties as SSLTokenAuthRestClientProperties + + assertEquals(p.tokenAuth!!.token!!, "72178473kjshdkjgvbsdkjv903274908") + assertEquals(p.sslTrust, "src/test/resources/keystore.p12") + assertEquals(p.sslTrustPassword, "changeit") + assertEquals(p.keyStoreInstance, "PKCS12") + } + + @Test + fun testSSLNoAuthProperties() { + val properties = bluePrintRestLibPropertyService.restClientProperties( + "blueprintsprocessor.restclient.ssl") + assertNotNull(properties, "failed to create property bean") + + val p: SSLRestClientProperties = + properties as SSLRestClientProperties + + assertEquals(p.sslTrust, "src/test/resources/keystore.p12") + assertEquals(p.sslTrustPassword, "changeit") + assertEquals(p.keyStoreInstance, "PKCS12") + assertEquals(p.sslKey, "src/test/resources/keystore.p12") + assertEquals(p.sslKeyPassword, "changeit") + } + + + @Test + fun testSSLBasicPropertiesAsJson() { + val json: String = "{\n" + + " \"type\" : \"ssl-basic-auth\",\n" + + " \"url\" : \"https://localhost:8443\",\n" + + " \"keyStoreInstance\" : \"PKCS12\",\n" + + " \"sslTrust\" : \"src/test/resources/keystore.p12\",\n" + + " \"sslTrustPassword\" : \"changeit\",\n" + + " \"basicAuth\" : {\n" + + " \"username\" : \"admin\",\n" + + " \"password\" : \"cds\"\n" + + " }\n" + + "}" + val mapper = ObjectMapper() + val actualObj: JsonNode = mapper.readTree(json) + val properties = bluePrintRestLibPropertyService.restClientProperties( + actualObj) + assertNotNull(properties, "failed to create property bean") + val p: SSLBasicAuthRestClientProperties = + properties as SSLBasicAuthRestClientProperties + + assertEquals(p.basicAuth!!.username, "admin") + assertEquals(p.basicAuth!!.password, "cds") + assertEquals(p.sslTrust, "src/test/resources/keystore.p12") + assertEquals(p.sslTrustPassword, "changeit") + assertEquals(p.keyStoreInstance, "PKCS12") + } + + @Test + fun testSSLTokenPropertiesAsJson() { + val json: String = "{\n" + + " \"type\" : \"ssl-token-auth\",\n" + + " \"url\" : \"https://localhost:8443\",\n" + + " \"keyStoreInstance\" : \"PKCS12\",\n" + + " \"sslTrust\" : \"src/test/resources/keystore.p12\",\n" + + " \"sslTrustPassword\" : \"changeit\",\n" + + " \"tokenAuth\" : {\n" + + " \"token\" : \"72178473kjshdkjgvbsdkjv903274908\"\n" + + " }\n" + + "}" + val mapper = ObjectMapper() + val actualObj: JsonNode = mapper.readTree(json) + val properties = bluePrintRestLibPropertyService.restClientProperties( + actualObj) assertNotNull(properties, "failed to create property bean") - assertNotNull(properties.url, "failed to get url property in property bean") + + val p: SSLTokenAuthRestClientProperties = + properties as SSLTokenAuthRestClientProperties + + assertEquals(p.tokenAuth!!.token!!, "72178473kjshdkjgvbsdkjv903274908") + assertEquals(p.sslTrust, "src/test/resources/keystore.p12") + assertEquals(p.sslTrustPassword, "changeit") + assertEquals(p.keyStoreInstance, "PKCS12") + } + + @Test + fun testSSLNoAuthPropertiesAsJson() { + val json: String = "{\n" + + " \"type\" : \"ssl-basic-auth\",\n" + + " \"url\" : \"https://localhost:8443\",\n" + + " \"keyStoreInstance\" : \"PKCS12\",\n" + + " \"sslTrust\" : \"src/test/resources/keystore.p12\",\n" + + " \"sslTrustPassword\" : \"changeit\",\n" + + " \"sslKey\" : \"src/test/resources/keystore.p12\",\n" + + " \"sslKeyPassword\" : \"changeit\"\n" + + "}" + val mapper = ObjectMapper() + val actualObj: JsonNode = mapper.readTree(json) + val properties = bluePrintRestLibPropertyService.restClientProperties( + actualObj) + assertNotNull(properties, "failed to create property bean") + + val p: SSLRestClientProperties = + properties as SSLRestClientProperties + + assertEquals(p.sslTrust, "src/test/resources/keystore.p12") + assertEquals(p.sslTrustPassword, "changeit") + assertEquals(p.keyStoreInstance, "PKCS12") + assertEquals(p.sslKey, "src/test/resources/keystore.p12") + assertEquals(p.sslKeyPassword, "changeit") } @Test fun testBlueprintWebClientService() { - val blueprintWebClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample") - assertNotNull(blueprintWebClientService, "failed to create blueprintWebClientService") + val blueprintWebClientService = bluePrintRestLibPropertyService + .blueprintWebClientService("sample") + assertNotNull(blueprintWebClientService, "failed to create blu" + + "eprintWebClientService") } } 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 a02a8083b..98cdfc0f2 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 @@ -1,6 +1,7 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. * Copyright (C) 2019 Nordix Foundation + * Modifications Copyright © 2019 Huawei. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +18,13 @@ package org.onap.ccsdk.cds.blueprintsprocessor.rest.service +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.ObjectMapper +import kotlinx.coroutines.CoroutineStart +import kotlinx.coroutines.async +import kotlinx.coroutines.runBlocking +import org.apache.catalina.connector.Connector +import org.junit.Test import org.junit.runner.RunWith import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration @@ -25,57 +33,330 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration import org.springframework.boot.test.context.SpringBootTest +import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory +import org.springframework.boot.web.servlet.server.ServletWebServerFactory +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration import org.springframework.http.HttpMethod +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder +import org.springframework.security.config.annotation.web.builders.HttpSecurity +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder +import org.springframework.security.crypto.password.PasswordEncoder +import org.springframework.stereotype.Component import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner +import org.springframework.web.bind.annotation.DeleteMapping import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PatchMapping +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.PutMapping +import org.springframework.web.bind.annotation.RequestHeader import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController -import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull @RunWith(SpringRunner::class) @EnableAutoConfiguration(exclude = [DataSourceAutoConfiguration::class]) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) -@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BlueprintPropertyConfiguration::class, - SampleController::class, BluePrintProperties::class, BluePrintProperties::class]) +@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, + BlueprintPropertyConfiguration::class, + SampleController::class, BluePrintProperties::class, + BluePrintProperties::class]) @TestPropertySource(properties = -["blueprintsprocessor.restclient.sample.type=basic-auth", +[ + "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:8080", - "blueprintsprocessor.restclient.sample.username=sampleuser", - "blueprintsprocessor.restclient.sample.password=sampletoken"]) + "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 { @Autowired lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService @Test + fun testPatch() { + val restClientService = bluePrintRestLibPropertyService + .blueprintWebClientService("sample") + val response = restClientService.exchangeResource( + HttpMethod.PATCH.name, "/sample/name", "") + assertEquals("Patch request successful", response, + "failed to get patch response") + } + + @Test fun testBaseAuth() { - val restClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample") + val restClientService = bluePrintRestLibPropertyService + .blueprintWebClientService("sample") val headers = mutableMapOf<String, String>() headers["X-Transaction-Id"] = "1234" - val response = restClientService.exchangeResource(HttpMethod.GET.name, "/sample/name", "") + val response = restClientService.exchangeResource(HttpMethod.GET.name, + "/sample/name", "") assertNotNull(response, "failed to get response") } @Test - fun testPatch() { - val restClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample") - val response = restClientService.exchangeResource(HttpMethod.PATCH.name, "/sample/name", "") - assertEquals("Patch request successful", response, "failed to get patch response") + fun testSimpleBasicAuth() { + val json: String = "{\n" + + " \"type\" : \"basic-auth\",\n" + + " \"url\" : \"http://localhost:8080\",\n" + + " \"username\" : \"admin\",\n" + + " \"password\" : \"jans\"\n" + + "}" + val mapper = ObjectMapper() + val actualObj: JsonNode = mapper.readTree(json) + val restClientService = bluePrintRestLibPropertyService + .blueprintWebClientService(actualObj) + lateinit var res:String + runBlocking { + val get = async(start = CoroutineStart.LAZY) { + restClientService.exchangeNB(HttpMethod.GET.name, + "/sample/basic", "")} + get.start() + res = get.await() + } + assertNotNull(res, "failed to get response") + assertEquals(res, "Basic request arrived successfully") } + @Test + fun testSampleAaiReq() { + val restClientService = bluePrintRestLibPropertyService + .blueprintWebClientService("test") + val headers = mutableMapOf<String, String>() + 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" + + "}" + lateinit var res1: Customer + lateinit var res2: Customer + lateinit var res3: String + lateinit var res4: String + lateinit var res5: String + lateinit var res6: String + runBlocking { + val get1 = async(start = CoroutineStart.LAZY) { + restClientService.exchangeNB(HttpMethod.GET.name, + "/sample/aai/v14/business/customers", "", headers, + Customer::class.java)} + + val get2 = async(start = CoroutineStart.LAZY) { + restClientService.exchangeNB(HttpMethod.GET.name, + "/sample/aai/v14/business/customers", "", headers, + Customer::class.java)} + + val post = async(start = CoroutineStart.LAZY) { + restClientService.exchangeNB(HttpMethod.POST.name, + "/sample/aai/v14/business/customers", post1, headers, + String::class.java)} + + val put = async(start = CoroutineStart.LAZY) { + restClientService.exchangeNB(HttpMethod.PUT.name, + "/sample/aai/v14/business/customers", post1, headers, + String::class.java)} + + val patch = async(start = CoroutineStart.LAZY) { + restClientService.exchangeNB(HttpMethod.PATCH.name, + "/sample/aai/v14/business/customers", post1, headers, + String::class.java)} + + val delete = async(start = CoroutineStart.LAZY) { + restClientService.exchangeNB(HttpMethod.DELETE.name, + "/sample/aai/v14/business/customers", "", headers, + String::class.java)} + + get1.start() + get2.start() + post.start() + put.start() + patch.start() + delete.start() + res1 = get1.await() + res2 = get2.await() + res3 = post.await() + res4 = put.await() + res5 = patch.await() + res6 = delete.await() + } + assertNotNull(res1, "failed to get response") + assertNotNull(res2, "failed to get response") + assertEquals(res1.id, "ONSDEMOBJHKCustomer") + assertEquals(res1.name, "ONSDEMOBJHKCustomer") + assertEquals(res1.type, "CUST") + assertEquals(res1.resource, "1552985011163") + assertEquals(res2.id, "ONSDEMOBJHKCustomer") + assertEquals(res2.name, "ONSDEMOBJHKCustomer") + assertEquals(res2.type, "CUST") + assertEquals(res2.resource, "1552985011163") + assertEquals(res3, "The message is successfully posted") + assertEquals(res4, "The put request is success") + assertEquals(res5, "The patch request is success") + assertEquals(res6, "The message is successfully deleted") + } } +/** + * Sample controller code for testing both http and https requests. + */ @RestController @RequestMapping("/sample") open class SampleController { + @GetMapping("/name") fun getName(): String = "Sample Controller" + @PatchMapping("/name") fun patchName(): String = "Patch request successful" + + @GetMapping("/basic") + fun getBasic(): String = "Basic request arrived successfully" + + + @GetMapping("/aai/v14/business/customers") + fun getAaiCustomers( + @RequestHeader(name = "X-TransactionId", required = true) + transId: String, + @RequestHeader(name = "X-FromAppId", required = true) + appId: String) : String { + if (transId != "9999" || appId != "AAI") { + return "" + } + return "{\n" + + " \"id\": \"ONSDEMOBJHKCustomer\",\n" + + " \"name\": \"ONSDEMOBJHKCustomer\",\n" + + " \"type\": \"CUST\",\n" + + " \"resource\": \"1552985011163\"\n" + + "}" + } + + @PostMapping("/aai/v14/business/customers") + fun postAaiCustomers( + @RequestHeader(name = "X-TransactionId", required = true) + transId: String, + @RequestHeader(name = "X-FromAppId", required = true) + appId: String) : String { + if (transId != "9999" || appId != "AAI") { + return "" + } + return "The message is successfully posted" + } + + + @PutMapping("/aai/v14/business/customers") + fun putAaiCustomers( + @RequestHeader(name = "X-TransactionId", required = true) + transId: String, + @RequestHeader(name = "X-FromAppId", required = true) + appId: String) : String { + if (transId != "9999" || appId != "AAI") { + return "" + } + return "The put request is success" + } + + @PatchMapping("/aai/v14/business/customers") + fun patchAaiCustomers( + @RequestHeader(name = "X-TransactionId", required = true) + transId: String, + @RequestHeader(name = "X-FromAppId", required = true) + appId: String) : String { + if (transId != "9999" || appId != "AAI") { + return "" + } + return "The patch request is success" + } + + @DeleteMapping("/aai/v14/business/customers") + fun deleteAaiCustomers( + @RequestHeader(name = "X-TransactionId", required = true) + transId: String, + @RequestHeader(name = "X-FromAppId", required = true) + appId: String) : String { + if (transId != "9999" || appId != "AAI") { + return "" + } + return "The message is successfully deleted" + } } +/** + * Security configuration required for basic authentication with username and + * password for any request in the server. + */ +@Configuration +@EnableWebSecurity +open class SecurityConfig : WebSecurityConfigurerAdapter() { + + @Throws(Exception::class) + override fun configure(http: HttpSecurity) { + http + .csrf().disable() + .authorizeRequests().anyRequest().authenticated() + .and() + .httpBasic() + } + + @Autowired + @Throws(Exception::class) + open fun configureGlobal(auth: AuthenticationManagerBuilder) { + auth.inMemoryAuthentication() + .withUser("admin") + .password(passwordEncoder().encode("jans")) + .roles("USER") + } + + @Bean + open fun passwordEncoder(): PasswordEncoder { + return BCryptPasswordEncoder() + } +} + +/** + * Http server required for http request to be processed along with the https + * server. + */ +@Component +class HttpServer { + @Bean + fun servletContainer(): ServletWebServerFactory { + + val connector = Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL) + connector.setPort(8080) + + val tomcat = TomcatServletWebServerFactory() + tomcat.addAdditionalTomcatConnectors(connector) + return tomcat + } +} + +/** + * Data class required for response + */ +data class Customer( + val id: String, + val name: String, + val type: String, + val resource: String)
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/keystore.p12 b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/keystore.p12 Binary files differnew file mode 100644 index 000000000..96b0d3ac3 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/keystore.p12 |