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.BluePrintTypes
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") {
49 BluePrintTypes.relationshipTypeConnectsToGrpcServer(),
50 BluePrintTypes.relationshipTypeConnectsTo()
54 assertNotNull(serviceTemplate, "failed to create service template")
55 val relationshipTemplates = serviceTemplate.topologyTemplate?.relationshipTemplates
56 assertNotNull(relationshipTemplates, "failed to get relationship templates")
57 assertEquals(2, relationshipTemplates.size, "relationshipTemplates doesn't match")
58 assertNotNull(relationshipTemplates["sample-tls-auth"], "failed to get sample-tls-auth")
59 assertNotNull(relationshipTemplates["sample-token-auth"], "failed to get sample-token-auth")
60 // println(serviceTemplate.asJsonString(true))
64 fun testGrpcClientPropertiesDSL() {
65 val serviceTemplate = serviceTemplate("grpc-properties-test", "1.0.0", "xxx.@xx.com", "grpc") {
67 relationshipTemplateGrpcClient("sample-tls-auth", "Grpc Server") {
71 clientCertChain("sample-certchains")
72 clientPrivateKey("sample-private-key")
73 trustCertCollection("sample-trust-cert-collection")
76 relationshipTemplateGrpcClient("sample-basic-auth", "Grpc Server") {
80 username("sample-user")
81 password("credential")
84 relationshipTemplateGrpcClient("sample-token-auth", "Grpc Server") {
94 BluePrintTypes.relationshipTypeConnectsToGrpcClient(),
95 BluePrintTypes.relationshipTypeConnectsTo()
99 assertNotNull(serviceTemplate, "failed to create service template")
100 val relationshipTemplates = serviceTemplate.topologyTemplate?.relationshipTemplates
101 assertNotNull(relationshipTemplates, "failed to get relationship templates")
102 assertEquals(3, relationshipTemplates.size, "relationshipTemplates doesn't match")
103 assertNotNull(relationshipTemplates["sample-tls-auth"], "failed to get sample-tls-auth")
104 assertNotNull(relationshipTemplates["sample-basic-auth"], "failed to get sample-basic-auth")
105 assertNotNull(relationshipTemplates["sample-token-auth"], "failed to get sample-token-auth")
106 // println(serviceTemplate.asJsonString(true))