2 * Copyright © 2018-2019 AT&T Intellectual Property.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.cds.blueprintsprocessor.grpc
20 import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants
21 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.relationshipTypeConnectsTo
22 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate
23 import kotlin.test.assertEquals
24 import kotlin.test.assertNotNull
26 class GrpcPropertiesDSLTest {
29 fun testGrpcServerPropertiesDSL() {
30 val serviceTemplate = serviceTemplate("grpc-properties-test", "1.0.0", "xxx.@xx.com", "grpc") {
32 relationshipTemplateGrpcServer("sample-tls-auth", "Grpc Server") {
35 certChain("sample-cert-chains")
36 privateKey("sample-private-key")
37 trustCertCollection("sample-trust-cert-collection")
40 relationshipTemplateGrpcServer("sample-token-auth", "Grpc Server") {
47 relationshipTypeConnectsToGrpcServer()
48 relationshipTypeConnectsTo()
51 // println(serviceTemplate.asJsonString(true))
52 assertNotNull(serviceTemplate, "failed to create service template")
53 val relationshipTemplates = serviceTemplate.topologyTemplate?.relationshipTemplates
54 assertNotNull(relationshipTemplates, "failed to get relationship templates")
55 assertEquals(2, relationshipTemplates.size, "relationshipTemplates doesn't match")
56 assertNotNull(relationshipTemplates["sample-tls-auth"], "failed to get sample-tls-auth")
57 assertNotNull(relationshipTemplates["sample-token-auth"], "failed to get sample-token-auth")
59 val relationshipTypes = serviceTemplate.relationshipTypes
60 assertNotNull(relationshipTypes, "failed to get relationship types")
61 assertEquals(2, relationshipTypes.size, "relationshipTypes doesn't match")
63 relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO],
64 "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO}"
67 relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_GRPC_SERVER],
68 "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_GRPC_SERVER}"
73 fun testGrpcClientPropertiesDSL() {
74 val serviceTemplate = serviceTemplate("grpc-properties-test", "1.0.0", "xxx.@xx.com", "grpc") {
76 relationshipTemplateGrpcClient("sample-tls-auth", "Grpc Server") {
80 clientCertChain("sample-certchains")
81 clientPrivateKey("sample-private-key")
82 trustCertCollection("sample-trust-cert-collection")
85 relationshipTemplateGrpcClient("sample-basic-auth", "Grpc Server") {
89 username("sample-user")
90 password("credential")
93 relationshipTemplateGrpcClient("sample-token-auth", "Grpc Server") {
101 relationshipTypeConnectsToGrpcClient()
102 relationshipTypeConnectsTo()
105 // println(serviceTemplate.asJsonString(true))
106 assertNotNull(serviceTemplate, "failed to create service template")
107 val relationshipTemplates = serviceTemplate.topologyTemplate?.relationshipTemplates
108 assertNotNull(relationshipTemplates, "failed to get relationship templates")
109 assertEquals(3, relationshipTemplates.size, "relationshipTemplates doesn't match")
110 assertNotNull(relationshipTemplates["sample-tls-auth"], "failed to get sample-tls-auth")
111 assertNotNull(relationshipTemplates["sample-basic-auth"], "failed to get sample-basic-auth")
112 assertNotNull(relationshipTemplates["sample-token-auth"], "failed to get sample-token-auth")
114 val relationshipTypes = serviceTemplate.relationshipTypes
115 assertNotNull(relationshipTypes, "failed to get relationship types")
116 assertEquals(2, relationshipTypes.size, "relationshipTypes doesn't match")
118 relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO],
119 "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO}"
122 relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_GRPC_CLIENT],
123 "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_GRPC_CLIENT}"