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.message
19 import org.apache.kafka.streams.StreamsConfig
21 import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants
22 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.relationshipTypeConnectsTo
23 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate
24 import kotlin.test.assertEquals
25 import kotlin.test.assertNotNull
27 class MessagePropertiesDSLTest {
30 fun testScramSslMessageProducerDSL() {
31 val serviceTemplate = serviceTemplate("message-properties-test", "1.0.0", "xxx.@xx.com", "message") {
33 relationshipTemplateMessageProducer("sample-scram-ssl-auth", "Message Producer") {
35 bootstrapServers("sample-bootstrapServers")
36 clientId("sample-client-id")
39 reconnectBackOffMs(60 * 60 * 1000)
40 enableIdempotence(true)
42 truststore("/path/to/truststore.jks")
43 truststorePassword("secretpassword")
45 keystore("/path/to/keystore.jks")
46 keystorePassword("secretpassword")
48 sslEndpointIdentificationAlgorithm("")
49 saslMechanism("SCRAM-SHA-512")
50 scramUsername("sample-user")
51 scramPassword("secretpassword")
55 relationshipTypeConnectsToMessageProducer()
56 relationshipTypeConnectsTo()
59 // println(serviceTemplate.asJsonString(true))
60 assertNotNull(serviceTemplate, "failed to create service template")
61 val relationshipTemplates = serviceTemplate.topologyTemplate?.relationshipTemplates
62 assertNotNull(relationshipTemplates, "failed to get relationship templates")
63 assertEquals(1, relationshipTemplates.size, "relationshipTemplates doesn't match")
64 assertNotNull(relationshipTemplates["sample-scram-ssl-auth"], "failed to get sample-scram-ssl-auth")
66 val relationshipTypes = serviceTemplate.relationshipTypes
67 assertNotNull(relationshipTypes, "failed to get relationship types")
68 assertEquals(2, relationshipTypes.size, "relationshipTypes doesn't match")
70 relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO],
71 "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO}"
74 relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_MESSAGE_PRODUCER],
75 "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_MESSAGE_PRODUCER}"
80 fun testScramSslAuthMessageConsumerDSL() {
81 val serviceTemplate = serviceTemplate("message-properties-test", "1.0.0", "xxx.@xx.com", "message") {
83 relationshipTemplateMessageConsumer("sample-scram-ssl-auth", "Message Consumer") {
85 bootstrapServers("sample-bootstrapServers")
86 clientId("sample-client-id")
87 groupId("sample-group-id")
90 autoOffsetReset("latest")
93 truststore("/path/to/truststore.jks")
94 truststorePassword("secretpassword")
96 keystore("/path/to/keystore.jks")
97 keystorePassword("secretpassword")
99 sslEndpointIdentificationAlgorithm("")
100 saslMechanism("SCRAM-SHA-512")
101 scramUsername("sample-user")
102 scramPassword("secretpassword")
105 relationshipTemplateMessageConsumer("sample-stream-scram-ssl-auth", "Message Consumer") {
106 kafkaStreamsScramSslAuth {
107 bootstrapServers("sample-bootstrapServers")
108 applicationId("sample-application-id")
109 autoOffsetReset("latest")
110 processingGuarantee(StreamsConfig.EXACTLY_ONCE)
111 topic("sample-streaming-topic")
112 truststore("/path/to/truststore.jks")
113 truststorePassword("secretpassword")
114 truststoreType("JKS")
115 keystore("/path/to/keystore.jks")
116 keystorePassword("secretpassword")
118 sslEndpointIdentificationAlgorithm("")
119 saslMechanism("SCRAM-SHA-512")
120 scramUsername("sample-user")
121 scramPassword("secretpassword")
125 relationshipTypeConnectsToMessageConsumer()
126 relationshipTypeConnectsTo()
129 // println(serviceTemplate.asJsonString(true))
130 assertNotNull(serviceTemplate, "failed to create service template")
131 val relationshipTemplates = serviceTemplate.topologyTemplate?.relationshipTemplates
132 assertNotNull(relationshipTemplates, "failed to get relationship templates")
133 assertEquals(2, relationshipTemplates.size, "relationshipTemplates doesn't match")
134 assertNotNull(relationshipTemplates["sample-scram-ssl-auth"], "failed to get sample-scram-ssl-auth")
135 assertNotNull(relationshipTemplates["sample-stream-scram-ssl-auth"], "failed to get sample-stream-scram-ssl-auth")
137 val relationshipTypes = serviceTemplate.relationshipTypes
138 assertNotNull(relationshipTypes, "failed to get relationship types")
139 assertEquals(2, relationshipTypes.size, "relationshipTypes doesn't match")
141 relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO],
142 "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO}"
145 relationshipTypes[BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_MESSAGE_CONSUMER],
146 "failed to get ${BlueprintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO_MESSAGE_CONSUMER}"