--- /dev/null
+{
+ "node0_hostname": "sdnc-host",
+ "node0_backup_router_address": "2001:1890:1253::192:168:100:1",
+ "servers": [
+ "Server1",
+ "Server2",
+ "Server3"
+ ],
+ "tacplus-servers": [
+ {
+ "tacplus-server-name": "tacplus-server-name1",
+ "tacplus-server-source-address": "enc-dsdsasa1"
+ },
+ {
+ "tacplus-server-name": "tacplus-server-name2",
+ "tacplus-server-source-address": "enc-dsdsasa2"
+ }
+ ],
+ "classes": [
+ {
+ "name": "superuser-class",
+ "idle-timeout": 5,
+ "permissions": "all"
+ },
+ {
+ "name": "tacacs-adv-class",
+ "idle-timeout": 5
+ },
+ {
+ "name": "tacacs-base-class",
+ "idle-timeout": 5
+ }
+ ],
+ "system-password": "teamops-system-password",
+ "root-password": "teamops-root-password"
+}
--- /dev/null
+<configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm"
+xmlns:a="http://xml.juniper.net/junos/15.1X49/junos">
+ <version>15.1X49-D50.3</version>
+ <groups>
+ <name>node0</name>
+ <system>
+ #foreach($server in ${servers})
+ <server-host-name>$StringUtils.upperCase("$server")</server-host-name>
+ #end
+ </system>
+ <system>
+ <host-name>${node0_hostname}</host-name>
+ <backup-router>
+ <address>${node0_backup_router_address}</address>
+ <destination>$node0_backup_router_address</destination>
+ </backup-router>
+ #foreach($tacplus-server in ${tacplus-servers})
+ <tacplus-server>
+ <name>$tacplus-server.tacplus-server-name</name>
+ <source-address>$tacplus-server.tacplus-server-source-address</source-address>
+ </tacplus-server>
+ #end
+ <login>
+ <message>ONAP information assets</message>
+ #foreach($class in ${classes})
+ <class>
+ <name>$class.name</name>
+ <idle-timeout>$class.idle-timeout</idle-timeout>
+ #if ($class.permissions)
+ <permissions>$class.permissions</permissions>
+ #end
+ </class>
+ #end
+ <user>
+ <name>readonly</name>
+ <full-name>Read Only Account Access</full-name>
+ <uid>1001</uid>
+ <class>tacacs-base-class</class>
+ </user>
+ <user>
+ <name>readwrite</name>
+ <full-name>Read - Write Account Access</full-name>
+ <uid>1002</uid>
+ <class>tacacs-adv-class</class>
+ <authentication>
+ <encrypted-password>${system-password}</encrypted-password>
+ </authentication>
+ </user>
+ <user>
+ <name>readwrite</name>
+ <full-name>Emergency Access Only</full-name>
+ <uid>1000</uid>
+ <class>superuser-class</class>
+ <authentication>
+ <encrypted-password>${root-password}</encrypted-password>
+ </authentication>
+ </user>
+ </login>
+ </system>
+ </groups>
+</configuration>
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - CCSDK\r
+ * ================================================================================\r
+ * Copyright (C) 2022 Tech Mahindra\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.ccsdk.cds.controllerblueprints.core.service\r
+\r
+import kotlinx.coroutines.runBlocking\r
+import org.junit.Test\r
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintVelocityTemplateService\r
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils\r
+import kotlin.test.BeforeTest\r
+import java.io.File\r
+import java.util.*\r
+import kotlin.test.assertEquals\r
+import kotlin.test.assertNotNull\r
+\r
+\r
+class BlueprintVelocityTemplateTest {\r
+ private val velocityHome = System.getenv("velocity_path")\r
+\r
+\r
+ @BeforeTest\r
+ fun setup() {\r
+ val properties = Properties()\r
+ properties["file.resource.loader.path"] = velocityHome\r
+ }\r
+ @Test\r
+ fun testVelocityGeneratedContent() {\r
+ runBlocking {\r
+ val template = JacksonUtils.getContent("Templates/base-config-velocity-template.vtl")\r
+ val json = JacksonUtils.getContent("Templates/base-config-data-velocity.json")\r
+ val content = BluePrintVelocityTemplateService.generateContent(template, json)\r
+ assertNotNull(content, "failed to generate content for velocity template")\r
+ }\r
+ }\r
+ @Test\r
+ fun `no value variable should evaluate to default value - standalone template mesh test`() {\r
+ runBlocking {\r
+ val template = JacksonUtils.getContent("Templates/default-variable-value-velocity-template.vtl")\r
+ val json = JacksonUtils.getContent("Templates/default-variable-value-data.json")\r
+ val content = BluePrintVelocityTemplateService.generateContent(template, json)\r
+ val expected = "sample-hostname\n\${node0_backup_router_address}"\r
+ assertEquals(expected, content, "No value variable should use default value")\r
+ }\r
+ }\r
+ @Test\r
+ fun `Expected value variable from file`() {\r
+ runBlocking {\r
+ val template = JacksonUtils.getContent("Templates/default-variable-value-velocity-template.vtl")\r
+ val json = JacksonUtils.getContent("Templates/default-variable-value-data.json")\r
+ val content = BluePrintVelocityTemplateService.generateContent(template, json)\r
+ val expected = File("Tests/kotlin/default-variable-value-data.txt").readText()\r
+ assertEquals(expected, content, "expected value variable from file")\r
+ }\r
+\r
+ }\r
+}
\ No newline at end of file