summaryrefslogtreecommitdiffstats
path: root/mod/bpgenerator/src
diff options
context:
space:
mode:
authorRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2020-06-17 17:52:56 +0200
committerRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2020-07-16 11:41:49 +0200
commit69644638aa0e93c9c2c2ccea590fa02213d24a7a (patch)
tree2b9bed117552520851ec4d846eb38a84759fe042 /mod/bpgenerator/src
parent7e4e7939f698f593bf4019f3a4a1813206b77463 (diff)
Add external tls info to bpgenerator and component spec schema
Also: - Fix issue where local run without import file caused exception instead of use of default imports. - Update blueprint generator version from 1.3.2 to 1.4.0 Issue-ID: DCAEGEN2-2251 Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com> Change-Id: I2f976ccc3e0b271bf9ae1357f02bd86fe0903459
Diffstat (limited to 'mod/bpgenerator/src')
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ExternalTlsInfo.java153
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java42
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java7
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java96
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java4
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java4
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java4
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java8
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java5
-rw-r--r--mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java2
-rw-r--r--mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/TlsInfoTest.java162
11 files changed, 415 insertions, 72 deletions
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ExternalTlsInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ExternalTlsInfo.java
new file mode 100644
index 0000000..cf97dec
--- /dev/null
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ExternalTlsInfo.java
@@ -0,0 +1,153 @@
+/**============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
+ 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.
+ ============LICENSE_END=========================================================
+ */
+
+package org.onap.blueprintgenerator.models.blueprint;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+@Getter
+@Setter
+@NoArgsConstructor
+public class ExternalTlsInfo {
+
+ static final String USE_EXTERNAL_TLS_FIELD = "use_external_tls";
+
+ private static final String DEFAULT_CA = "RA";
+ private static final Object DEFAULT_CERT_TYPE = "P12";
+
+ private static final String INPUT_PREFIX = "external_cert_";
+ private static final String EXTERNAL_CERT_DIRECTORY_FIELD = "external_cert_directory";
+ private static final String CA_NAME_FIELD = "ca_name";
+ private static final String CERT_TYPE_FIELD = "cert_type";
+ private static final String EXTERNAL_CERTIFICATE_PARAMETERS_FIELD = "external_certificate_parameters";
+
+ @JsonProperty(EXTERNAL_CERT_DIRECTORY_FIELD)
+ private String externalCertDirectory;
+
+ @JsonProperty(USE_EXTERNAL_TLS_FIELD)
+ private GetInput useExternalTls;
+
+ @JsonProperty(CA_NAME_FIELD)
+ private GetInput caName;
+
+ @JsonProperty(CERT_TYPE_FIELD)
+ private GetInput certType;
+
+ @JsonProperty(EXTERNAL_CERTIFICATE_PARAMETERS_FIELD)
+ private ExternalCertificateParameters externalCertificateParameters;
+
+ static ExternalTlsInfo createFromComponentSpec(ComponentSpec cs) {
+ ExternalTlsInfo externalTlsInfoBp = new ExternalTlsInfo();
+ TreeMap<String, Object> tlsInfoCs = cs.getAuxilary().getTls_info();
+
+ externalTlsInfoBp.setExternalCertDirectory((String) tlsInfoCs.get("cert_directory"));
+ externalTlsInfoBp.setUseExternalTls(createGetInput(USE_EXTERNAL_TLS_FIELD));
+ externalTlsInfoBp.setCaName(createGetInput(CA_NAME_FIELD));
+ externalTlsInfoBp.setCertType(createGetInput(CERT_TYPE_FIELD));
+
+ ExternalCertificateParameters externalCertificateParameters =
+ ExternalCertificateParameters.create();
+ externalTlsInfoBp.setExternalCertificateParameters(externalCertificateParameters);
+
+ return externalTlsInfoBp;
+ }
+
+ static Map<String, LinkedHashMap<String, Object>> createInputMapFromComponentSpec(ComponentSpec cs){
+ Map<String, LinkedHashMap<String, Object>> retInputs = new HashMap<>();
+
+ Map<String, Object> tlsInfoCs = cs.getAuxilary().getTls_info();
+ LinkedHashMap<String, Object> useTlsFlagInput = Properties.makeInput("boolean",
+ "Flag to indicate external tls enable/disable.",
+ tlsInfoCs.get(USE_EXTERNAL_TLS_FIELD));
+ retInputs.put(addPrefix(USE_EXTERNAL_TLS_FIELD), useTlsFlagInput);
+
+ LinkedHashMap<String, Object> caNameInputMap = Properties.makeInput("string",
+ "Name of Certificate Authority configured on CertService side.",
+ DEFAULT_CA);
+ retInputs.put(addPrefix(CA_NAME_FIELD), caNameInputMap);
+
+ LinkedHashMap<String, Object> certTypeInputMap = Properties.makeInput("string",
+ "Format of provided certificates",
+ DEFAULT_CERT_TYPE);
+ retInputs.put(addPrefix(CERT_TYPE_FIELD), certTypeInputMap);
+
+ retInputs.putAll(ExternalCertificateParameters.createInputMap());
+ return retInputs;
+ }
+
+ private static GetInput createGetInput(String fieldName) {
+ return new GetInput(addPrefix(fieldName));
+ }
+
+ private static String addPrefix(String fieldName) {
+ return INPUT_PREFIX + fieldName;
+ }
+
+ @Getter
+ @Setter
+ @NoArgsConstructor
+ public static class ExternalCertificateParameters {
+
+ private static final String DEFAULT_COMMON_NAME = "sample.onap.org";
+ private static final String DEFAULT_SANS = "sample.onap.org:component.sample.onap.org";
+
+ private static final String COMMON_NAME_FIELD = "common_name";
+ private static final String SANS_FIELD = "sans";
+
+ @JsonProperty(COMMON_NAME_FIELD)
+ private GetInput commonName;
+
+ @JsonProperty(SANS_FIELD)
+ private GetInput sans;
+
+
+ private static ExternalCertificateParameters create() {
+ ExternalCertificateParameters externalCertificateParameters = new ExternalCertificateParameters();
+ externalCertificateParameters.setCommonName(createGetInput(COMMON_NAME_FIELD));
+ externalCertificateParameters.setSans(createGetInput(SANS_FIELD));
+ return externalCertificateParameters;
+ }
+
+ private static Map<String, LinkedHashMap<String, Object>> createInputMap(){
+ Map<String, LinkedHashMap<String, Object>> retInputs = new LinkedHashMap<>();
+
+ LinkedHashMap<String, Object> commonNameInputMap = Properties.makeInput("string",
+ "Common name which should be present in certificate.",
+ DEFAULT_COMMON_NAME);
+ retInputs.put(addPrefix(COMMON_NAME_FIELD), commonNameInputMap);
+
+ LinkedHashMap<String, Object> sansInputMap = Properties.makeInput("string",
+ "\"List of Subject Alternative Names (SANs) which should be present in certificate. " +
+ "Delimiter - : Should contain common_name value and other FQDNs under which given " +
+ "component is accessible.\"",
+ DEFAULT_SANS);
+ retInputs.put(addPrefix(SANS_FIELD), sansInputMap);
+ return retInputs;
+ }
+ }
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java
index e7980c8..351c2b2 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java
@@ -1,28 +1,36 @@
-/**============LICENSE_START=======================================================
- org.onap.dcae
- ================================================================================
- Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- 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
+/**============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Modifications Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
+ 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
+ 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.
- ============LICENSE_END=========================================================
+ 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.
+ ============LICENSE_END=========================================================
*/
package org.onap.blueprintgenerator.models.blueprint;
-import lombok.Getter; import lombok.Setter;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
-@Getter @Setter
+@Getter
+@Setter
+@NoArgsConstructor
+@AllArgsConstructor
public class GetInput {
private Object get_input;
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java
index bac795f..ee75ce0 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java
@@ -22,7 +22,14 @@ package org.onap.blueprintgenerator.models.blueprint;
import lombok.Getter; import lombok.Setter;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.TreeMap;
+
@Getter @Setter
public class Node {
private String type;
+ private TreeMap<String, Interfaces> interfaces;
+ private Properties properties;
+ private ArrayList<LinkedHashMap<String, String>> relationships;
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java
index 382964b..d7947f8 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java
@@ -1,8 +1,10 @@
-/**============LICENSE_START=======================================================
- org.onap.dcae
- ================================================================================
+/**============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
+ ================================================================================
+ Modifications Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
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
@@ -15,13 +17,13 @@
See the License for the specific language governing permissions and
limitations under the License.
============LICENSE_END=========================================================
-
*/
package org.onap.blueprintgenerator.models.blueprint;
import java.util.ArrayList;
import java.util.LinkedHashMap;
+import java.util.Map;
import java.util.TreeMap;
import org.onap.blueprintgenerator.models.componentspec.Auxilary;
@@ -33,10 +35,12 @@ import org.onap.blueprintgenerator.models.dmaapbp.DmaapStreams;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import lombok.Getter; import lombok.Setter;
+import lombok.Getter;
+import lombok.Setter;
-@Getter @Setter
-@JsonInclude(value=Include.NON_NULL)
+@Getter
+@Setter
+@JsonInclude(value = Include.NON_NULL)
public class Properties {
private Appconfig application_config;
private Auxilary docker_config;
@@ -52,6 +56,7 @@ public class Properties {
ArrayList<DmaapStreams> streams_publishes;
ArrayList<DmaapStreams> streams_subscribes;
private TlsInfo tls_info;
+ private ExternalTlsInfo external_cert;
private ResourceConfig resource_config;
private GetInput always_pull_image;
//private boolean useExisting;
@@ -85,10 +90,7 @@ public class Properties {
GetInput replica = new GetInput();
replica.setGet_input("replicas");
this.setReplicas(replica);
- LinkedHashMap<String, Object> rep = new LinkedHashMap<String, Object>();
- rep.put("type", "integer");
- rep.put("description", "number of instances");
- rep.put("default", 1);
+ LinkedHashMap<String, Object> rep = makeInput("integer", "number of instances", 1);
retInputs.put("replicas", rep);
//set the dns name
@@ -112,10 +114,9 @@ public class Properties {
// set always_pull_image
this.always_pull_image = new GetInput();
this.always_pull_image.setGet_input("always_pull_image");
- LinkedHashMap<String, Object> inputAlwaysPullImage = new LinkedHashMap<String, Object>();
- inputAlwaysPullImage.put("type", "boolean");
- inputAlwaysPullImage.put("description", "Set to true if the image should always be pulled");
- inputAlwaysPullImage.put("default", true);
+ LinkedHashMap<String, Object> inputAlwaysPullImage = makeInput("boolean",
+ "Set to true if the image should always be pulled",
+ true);
retInputs.put("always_pull_image", inputAlwaysPullImage);
@@ -124,9 +125,10 @@ public class Properties {
sType = sType.replace('.', '-');
this.setService_component_type(sType);
- //set the tls info
- if(cs.getAuxilary().getTls_info() != null){
- addTlsInfo(cs,retInputs);
+ //set the tls info for internal and external communication
+ if (cs.getAuxilary().getTls_info() != null) {
+ addTlsInfo(cs, retInputs);
+ addExternalTlsInfo(cs, retInputs);
}
//set the reource config
@@ -168,19 +170,17 @@ public class Properties {
sType = sType.replace('.', '-');
this.setService_component_type(sType);
- //set the tls info
- if(cs.getAuxilary().getTls_info() != null){
- addTlsInfo(cs,retInputs);
+ //set the tls info for internal and external communication
+ if (cs.getAuxilary().getTls_info() != null) {
+ addTlsInfo(cs, retInputs);
+ addExternalTlsInfo(cs, retInputs);
}
//set the replicas
GetInput replica = new GetInput();
replica.setGet_input("replicas");
this.setReplicas(replica);
- LinkedHashMap<String, Object> rep = new LinkedHashMap<String, Object>();
- rep.put("type", "integer");
- rep.put("description", "number of instances");
- rep.put("default", 1);
+ LinkedHashMap<String, Object> rep = makeInput("integer", "number of instances", 1);
retInputs.put("replicas", rep);
// //set the dns name
@@ -203,15 +203,14 @@ public class Properties {
//set the stream publishes
ArrayList<DmaapStreams> pubStreams = new ArrayList();
- if(cs.getStreams().getPublishes() != null) {
- for(Publishes p: cs.getStreams().getPublishes()) {
- if(p.getType().equals("message_router") || p.getType().equals("message router")) {
+ if (cs.getStreams().getPublishes() != null) {
+ for (Publishes p : cs.getStreams().getPublishes()) {
+ if (p.getType().equals("message_router") || p.getType().equals("message router")) {
String topic = p.getConfig_key() + "_topic";
DmaapStreams mrStreams = new DmaapStreams();
retInputs = mrStreams.createStreams(inps, cs, topic, p.getType(), p.getConfig_key(), p.getRoute(), 'p');
pubStreams.add(mrStreams);
- }
- else if(p.getType().equals("data_router") || p.getType().equals("data router")){
+ } else if (p.getType().equals("data_router") || p.getType().equals("data router")) {
String feed = p.getConfig_key() + "_feed";
DmaapStreams drStreams = new DmaapStreams();
retInputs = drStreams.createStreams(inps, cs, feed, p.getType(), p.getConfig_key(), p.getRoute(), 'p');
@@ -222,15 +221,14 @@ public class Properties {
//set the stream subscribes
ArrayList<DmaapStreams> subStreams = new ArrayList();
- if(cs.getStreams().getSubscribes() != null) {
- for(Subscribes s: cs.getStreams().getSubscribes()) {
- if(s.getType().equals("message_router") || s.getType().equals("message router")) {
+ if (cs.getStreams().getSubscribes() != null) {
+ for (Subscribes s : cs.getStreams().getSubscribes()) {
+ if (s.getType().equals("message_router") || s.getType().equals("message router")) {
String topic = s.getConfig_key() + "_topic";
DmaapStreams mrStreams = new DmaapStreams();
retInputs = mrStreams.createStreams(inps, cs, topic, s.getType(), s.getConfig_key(), s.getRoute(), 's');
subStreams.add(mrStreams);
- }
- else if(s.getType().equals("data_router") || s.getType().equals("data router")){
+ } else if (s.getType().equals("data_router") || s.getType().equals("data router")) {
String feed = s.getConfig_key() + "_feed";
DmaapStreams drStreams = new DmaapStreams();
retInputs = drStreams.createStreams(inps, cs, feed, s.getType(), s.getConfig_key(), s.getRoute(), 's');
@@ -239,10 +237,10 @@ public class Properties {
}
}
- if(pubStreams.size() != 0) {
+ if (pubStreams.size() != 0) {
this.setStreams_publishes(pubStreams);
}
- if(subStreams.size() != 0) {
+ if (subStreams.size() != 0) {
this.setStreams_subscribes(subStreams);
}
@@ -262,10 +260,24 @@ public class Properties {
useTLSFlag.setGet_input("use_tls");
tlsInfo.setUseTls(useTLSFlag);
this.setTls_info(tlsInfo);
- LinkedHashMap<String, Object> useTlsFlagInput = new LinkedHashMap<String, Object>();
- useTlsFlagInput.put("type", "boolean");
- useTlsFlagInput.put("description", "flag to indicate tls enable/disable");
- useTlsFlagInput.put("default", cs.getAuxilary().getTls_info().get("use_tls"));
+ LinkedHashMap<String, Object> useTlsFlagInput = makeInput("boolean",
+ "flag to indicate tls enable/disable",
+ cs.getAuxilary().getTls_info().get("use_tls"));
retInputs.put("use_tls", useTlsFlagInput);
}
+
+ private void addExternalTlsInfo(ComponentSpec cs, Map<String, LinkedHashMap<String, Object>> retInputs) {
+ if(cs.getAuxilary().getTls_info().get(ExternalTlsInfo.USE_EXTERNAL_TLS_FIELD) == null)
+ return;
+ this.setExternal_cert(ExternalTlsInfo.createFromComponentSpec(cs));
+ retInputs.putAll(ExternalTlsInfo.createInputMapFromComponentSpec(cs));
+ }
+
+ static LinkedHashMap<String, Object> makeInput(String type, String description, Object defaultValue) {
+ LinkedHashMap<String, Object> inputMap = new LinkedHashMap<>();
+ inputMap.put("type", type);
+ inputMap.put("description", description);
+ inputMap.put("default", defaultValue);
+ return inputMap;
+ }
}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java
index 73acda8..a36deb5 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java
@@ -3,6 +3,8 @@
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
================================================================================
+ Modifications Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
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
@@ -125,4 +127,4 @@ public class Auxilary {
// this.setPorts(ports);
// return retInputs;
// }
-} \ No newline at end of file
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java
index 21eabf0..c4cc663 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java
@@ -3,6 +3,8 @@
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
================================================================================
+ Modifications Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
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
@@ -114,4 +116,4 @@ public class DmaapBlueprint extends Blueprint{
bp.setInputs(inps);
return bp;
}
-} \ No newline at end of file
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java
index 6c74347..e84901c 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java
@@ -52,10 +52,6 @@ import lombok.Setter;
public class DmaapNode extends Node{
- private TreeMap<String, Interfaces> interfaces;
- private Properties properties;
- private ArrayList<LinkedHashMap<String, String>> relationships;
-
public TreeMap<String, LinkedHashMap<String, Object>> createDmaapNode(ComponentSpec cs, TreeMap<String, LinkedHashMap<String, Object>> inps, String override) {
TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java
index c0ef8b3..9f6f560 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java
@@ -2,7 +2,9 @@
org.onap.dcae
================================================================================
Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
- ================================================================================
+ ================================================================================
+ Modifications Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
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
@@ -52,7 +54,7 @@ public class OnapBlueprint extends Blueprint{
this.setTosca_definitions_version("cloudify_dsl_1_3");
//set the imports
- if(importPath != "") {
+ if(!"".equals(importPath)) {
Imports imps = new Imports();
this.setImports(imps.createImportsFromFile(importPath));
}
@@ -94,4 +96,4 @@ public class OnapBlueprint extends Blueprint{
return bp;
}
-} \ No newline at end of file
+}
diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java
index dbff78c..b0d1302 100644
--- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java
+++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java
@@ -48,9 +48,6 @@ import lombok.NoArgsConstructor;
@JsonInclude(value=Include.NON_NULL)
public class OnapNode extends Node{
- private TreeMap<String, Interfaces> interfaces;
- private Properties properties;
- private ArrayList<LinkedHashMap<String, String>> relationships;
public TreeMap<String, LinkedHashMap<String, Object>> createOnapNode(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
@@ -90,4 +87,4 @@ public class OnapNode extends Node{
return retInputs;
}
-} \ No newline at end of file
+}
diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java
index 9c581cf..4ebd23c 100644
--- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java
+++ b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java
@@ -392,6 +392,8 @@ public class BlueprintGeneratorTest {
assertEquals(true, test);
}
+
+
@Test
public void dmaapPluginTest() {
ComponentSpec cs = new ComponentSpec();
diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/TlsInfoTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/TlsInfoTest.java
new file mode 100644
index 0000000..6bd7b40
--- /dev/null
+++ b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/TlsInfoTest.java
@@ -0,0 +1,162 @@
+/**============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2020 Nokia. All rights reserved.
+ ================================================================================
+ 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.
+ ============LICENSE_END=========================================================
+ */
+
+package org.onap.blueprintgenerator.core;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.onap.blueprintgenerator.models.blueprint.Blueprint;
+import org.onap.blueprintgenerator.models.blueprint.ExternalTlsInfo;
+import org.onap.blueprintgenerator.models.blueprint.Node;
+import org.onap.blueprintgenerator.models.blueprint.TlsInfo;
+import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
+
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+@RunWith(Parameterized.class)
+public class TlsInfoTest {
+
+ @Parameterized.Parameter
+ public char bpType;
+
+ @Parameterized.Parameters(name = "Blueprint type: {0}")
+ public static List<Character> data() {
+ return Arrays.asList('o', 'd');
+ }
+
+ @Test
+ public void useTlsTrueAndUseExternalTlsTrueTest(){
+ Blueprint bp = createBlueprintFromFile("TestCases/TlsInfo/testComponentSpec_withTlsTrueAndExternalTlsTrue.json");
+
+ assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(bp, true);
+ assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, true);
+ }
+
+ @Test
+ public void useTlsFalseAndUseExternalTlsFalseTest(){
+ Blueprint bp = createBlueprintFromFile("TestCases/TlsInfo/testComponentSpec_withTlsFalseAndExternalTlsFalse.json");
+
+ assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(bp, false);
+ assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, false);
+ }
+
+ @Test
+ public void useTlsTrueAndNoExternalTlsFlagTest(){
+ Blueprint bp = createBlueprintFromFile("TestCases/TlsInfo/testComponentSpec_withTlsTrueAndNoExternalTls.json");
+
+ assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, true);
+ assertBlueprintHasNoExternalTlsInfo(bp);
+ }
+
+ @Test
+ public void noTlsInfo(){
+ Blueprint bp = createBlueprintFromFile("TestCases/TlsInfo/testComponentSpec_withoutTlsInfo.json");
+
+ assertBlueprintHasNoTlsInfo(bp);
+ assertBlueprintHasNoExternalTlsInfo(bp);
+ }
+
+ private void assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(Blueprint bp, boolean useFlagDefault) {
+ //should create proper inputs
+ assertContainsInputWithDefault(bp, "external_cert_use_external_tls", useFlagDefault);
+ assertContainsInputWithDefault(bp, "external_cert_ca_name", "\"RA\"");
+ assertContainsInputWithDefault(bp, "external_cert_cert_type", "\"P12\"");
+ assertContainsInputWithDefault(bp, "external_cert_common_name", "\"sample.onap.org\"");
+ assertContainsInputWithDefault(bp, "external_cert_sans",
+ "\"sample.onap.org:component.sample.onap.org\"");
+
+ Node node = bp.getNode_templates().get("test.component.spec");
+
+ //should create proper externalTlsInfo object in node properties
+ ExternalTlsInfo externalTlsInfo = node.getProperties().getExternal_cert();
+ assertNotNull(externalTlsInfo);
+
+ assertEquals("external_cert_ca_name", externalTlsInfo.getCaName().getGet_input());
+ assertEquals("external_cert_cert_type", externalTlsInfo.getCertType().getGet_input());
+ assertEquals("external_cert_use_external_tls", externalTlsInfo.getUseExternalTls().getGet_input());
+ assertEquals("/opt/app/dcae-certificate/", externalTlsInfo.getExternalCertDirectory());
+
+ ExternalTlsInfo.ExternalCertificateParameters extCertParams = externalTlsInfo.getExternalCertificateParameters();
+ assertNotNull(extCertParams);
+
+ assertEquals("external_cert_common_name", extCertParams.getCommonName().getGet_input());
+ assertEquals("external_cert_sans", extCertParams.getSans().getGet_input());
+ }
+
+ private void assertBlueprintContainsTlsInfoWithUseFlagDefault(Blueprint bp, boolean useFlagDefault) {
+ //shold create proper inputs
+ assertContainsInputWithDefault(bp, "use_tls", useFlagDefault);
+
+ Node node = bp.getNode_templates().get("test.component.spec");
+
+ //should create proper tlsInfo object in node properties
+ TlsInfo tlsInfo = node.getProperties().getTls_info();
+ assertEquals("use_tls", tlsInfo.getUseTls().getGet_input());
+ assertEquals("/opt/app/dcae-certificate/", tlsInfo.getCertDirectory());
+
+ }
+
+ private void assertBlueprintHasNoExternalTlsInfo(Blueprint bp) {
+ //should not create inputs for external tls
+ assertFalse(bp.getInputs().containsKey("external_cert_use_external_tls"));
+ assertFalse(bp.getInputs().containsKey("external_cert_common_name"));
+ assertFalse(bp.getInputs().containsKey("external_cert_ca_name"));
+ assertFalse(bp.getInputs().containsKey("external_cert_sans"));
+
+ Node node = bp.getNode_templates().get("test.component.spec");
+
+ //should not create externalTlsInfo object in node properties
+ ExternalTlsInfo externalTlsInfo = node.getProperties().getExternal_cert();
+ assertNull(externalTlsInfo);
+ }
+
+
+ private void assertBlueprintHasNoTlsInfo(Blueprint bp) {
+ //should not create inputs for tls
+ assertFalse(bp.getInputs().containsKey("use_tls"));
+
+ Node node = bp.getNode_templates().get("test.component.spec");
+
+ //should not create tlsInfo object in node properties
+ assertNull(node.getProperties().getTls_info());
+ }
+
+ private void assertContainsInputWithDefault(Blueprint bp, String inputName, Object defaultValue) {
+ LinkedHashMap<String, Object> input = bp.getInputs().get(inputName);
+ assertNotNull(input);
+ assertEquals(defaultValue, input.get("default"));
+ }
+
+ private Blueprint createBlueprintFromFile(String path) {
+ ComponentSpec cs = new ComponentSpec();
+ cs.createComponentSpecFromFile(path);
+
+ Blueprint bp = new Blueprint();
+ bp = bp.createBlueprint(cs, "", this.bpType, "", "");
+ return bp;
+ }
+}