summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons/rest-lib
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/rest-lib')
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt1
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/RestClientPropertiesDSL.kt137
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt59
4 files changed, 199 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
index 25d1de881..b68627fec 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
@@ -51,6 +51,7 @@ fun BluePrintDependencyService.restClientService(jsonNode: JsonNode): BlueprintW
class RestLibConstants {
companion object {
const val SERVICE_BLUEPRINT_REST_LIB_PROPERTY = "blueprint-rest-lib-property-service"
+ const val PROPERTY_TYPE = "type"
const val TYPE_TOKEN_AUTH = "token-auth"
const val TYPE_BASIC_AUTH = "basic-auth"
const val TYPE_SSL_BASIC_AUTH = "ssl-basic-auth"
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt
index 70ec9501a..75a9409fd 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt
@@ -30,10 +30,12 @@ open class SSLRestClientProperties : RestClientProperties() {
var sslKeyPassword: String? = null
}
+// FIXME("Define basic auth userName and password properties")
open class SSLBasicAuthRestClientProperties : SSLRestClientProperties() {
var basicAuth: BasicAuthRestClientProperties? = null
}
+// FIXME("Define token properties")
open class SSLTokenAuthRestClientProperties : SSLRestClientProperties() {
var tokenAuth: TokenAuthRestClientProperties? = null
}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/RestClientPropertiesDSL.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/RestClientPropertiesDSL.kt
new file mode 100644
index 000000000..a3da44f61
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/RestClientPropertiesDSL.kt
@@ -0,0 +1,137 @@
+/*
+ * Copyright © 2019 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.rest
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.PropertiesAssignmentBuilder
+
+fun BluePrintTypes.dslBasicAuthRestClientProperties(block: BasicAuthRestClientPropertiesBuilder.() -> Unit): JsonNode {
+ val assignments = BasicAuthRestClientPropertiesBuilder().apply(block).build()
+ assignments[RestLibConstants.PROPERTY_TYPE] = RestLibConstants.TYPE_BASIC_AUTH.asJsonPrimitive()
+ return assignments.asJsonType()
+}
+
+fun BluePrintTypes.dslTokenAuthRestClientProperties(block: TokenAuthRestClientPropertiesBuilder.() -> Unit): JsonNode {
+ val assignments = TokenAuthRestClientPropertiesBuilder().apply(block).build()
+ assignments[RestLibConstants.PROPERTY_TYPE] = RestLibConstants.TYPE_TOKEN_AUTH.asJsonPrimitive()
+ return assignments.asJsonType()
+}
+
+fun BluePrintTypes.dslSSLRestClientProperties(block: SSLRestClientPropertiesBuilder.() -> Unit): JsonNode {
+ val assignments = SSLRestClientPropertiesBuilder().apply(block).build()
+ assignments[RestLibConstants.PROPERTY_TYPE] = RestLibConstants.TYPE_SSL_NO_AUTH.asJsonPrimitive()
+ return assignments.asJsonType()
+}
+
+open class RestClientPropertiesBuilder : PropertiesAssignmentBuilder() {
+ fun type(type: String) {
+ type(type.asJsonPrimitive())
+ }
+
+ fun type(type: JsonNode) {
+ property(RestLibConstants.PROPERTY_TYPE, type)
+ }
+
+ open fun url(url: String) {
+ url(url.asJsonPrimitive())
+ }
+
+ open fun url(url: JsonNode) {
+ property("url", url)
+ }
+}
+
+open class BasicAuthRestClientPropertiesBuilder : RestClientPropertiesBuilder() {
+ open fun password(password: String) {
+ password(password.asJsonPrimitive())
+ }
+
+ open fun password(password: JsonNode) {
+ property("password", password)
+ }
+
+ open fun username(username: String) {
+ username(username.asJsonPrimitive())
+ }
+
+ open fun username(username: JsonNode) {
+ property("username", username)
+ }
+}
+
+open class TokenAuthRestClientPropertiesBuilder : RestClientPropertiesBuilder() {
+ open fun token(token: String) {
+ token(token.asJsonPrimitive())
+ }
+
+ open fun token(token: JsonNode) {
+ property("token", token)
+ }
+}
+
+open class SSLRestClientPropertiesBuilder : RestClientPropertiesBuilder() {
+ open fun keyStoreInstance(keyStoreInstance: String) {
+ keyStoreInstance(keyStoreInstance.asJsonPrimitive())
+ }
+
+ open fun keyStoreInstance(keyStoreInstance: JsonNode) {
+ property("keyStoreInstance", keyStoreInstance)
+ }
+
+ open fun sslTrust(sslTrust: String) {
+ sslTrust(sslTrust.asJsonPrimitive())
+ }
+
+ open fun sslTrust(sslTrust: JsonNode) {
+ property("sslTrust", sslTrust)
+ }
+
+ open fun sslTrustPassword(sslTrustPassword: String) {
+ sslTrustPassword(sslTrustPassword.asJsonPrimitive())
+ }
+
+ open fun sslTrustPassword(sslTrustPassword: JsonNode) {
+ property("sslTrustPassword", sslTrustPassword)
+ }
+
+ open fun sslKey(sslKey: String) {
+ sslKey(sslKey.asJsonPrimitive())
+ }
+
+ open fun sslKey(sslKey: JsonNode) {
+ property("sslKey", sslKey)
+ }
+
+ open fun sslKeyPassword(sslKeyPassword: String) {
+ sslKeyPassword(sslKeyPassword.asJsonPrimitive())
+ }
+
+ open fun sslKeyPassword(sslKeyPassword: JsonNode) {
+ property("sslKeyPassword", sslKeyPassword)
+ }
+}
+
+open class SSLBasicAuthRestClientPropertiesBuilder : SSLRestClientPropertiesBuilder() {
+ //TODO()
+}
+
+open class SSLTokenAuthRestClientPropertiesBuilder : SSLRestClientPropertiesBuilder() {
+ //TODO()
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt
new file mode 100644
index 000000000..15133fa8a
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientPropertiesDSLTest.kt
@@ -0,0 +1,59 @@
+/*
+ * Copyright © 2019 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.rest.service
+
+import org.junit.Test
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.dslBasicAuthRestClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.dslSSLRestClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.dslTokenAuthRestClientProperties
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import kotlin.test.assertNotNull
+
+class RestClientPropertiesDSLTest {
+
+ @Test
+ fun testBasicAuthRestClientProperties() {
+ val properties = BluePrintTypes.dslBasicAuthRestClientProperties {
+ url("http://localhost:8080")
+ username("xxxxx")
+ password("******")
+ }
+ assertNotNull(properties, "failed to get dslBasicAuthRestClientProperties")
+ }
+
+ @Test
+ fun testBasicTokenAuthRestClientProperties() {
+ val properties = BluePrintTypes.dslTokenAuthRestClientProperties {
+ url("http://localhost:8080")
+ token("sdfgfsadgsgf")
+ }
+ assertNotNull(properties, "failed to get dslTokenAuthRestClientProperties")
+ }
+
+ @Test
+ fun testDslSSLRestClientProperties() {
+ val properties = BluePrintTypes.dslSSLRestClientProperties {
+ url("http://localhost:8080")
+ keyStoreInstance("instance")
+ sslTrust("sample-trust")
+ sslTrustPassword("sample-trust-password")
+ sslKey("sample-sslkey")
+ sslKeyPassword("sample-key-password")
+ }
+ assertNotNull(properties, "failed to get dslSSLRestClientProperties")
+ }
+} \ No newline at end of file