summaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2020-11-26 13:46:46 +0100
committerRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2020-11-26 13:49:09 +0100
commitf6fc229608f2692ae666767ff49699acb1a795bb (patch)
tree43da7756def65dcac8b92a413e5a64491cbe01ca /mod
parentb8cc85d062a52130c27cabf10658a033a7510626 (diff)
Update external certificates SANs delimiter
Fix formatting Issue-ID: DCAEGEN2-2508 Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com> Change-Id: I1fab49ed949923e7c2a2ca47182805f494c89093
Diffstat (limited to 'mod')
-rw-r--r--mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java2
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateParametersFactoryService.java15
-rw-r--r--mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/TlsInfoTest.java242
3 files changed, 134 insertions, 125 deletions
diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java
index 69a71e5..db12c37 100644
--- a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java
+++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java
@@ -86,7 +86,7 @@ public class Constants {
public static final String COMMON_NAME_FIELD = "common_name";
public static final String SANS_FIELD = "sans";
public static final String DEFAULT_COMMON_NAME = "sample.onap.org";
- public static final String DEFAULT_SANS = "sample.onap.org:component.sample.onap.org";
+ public static final String DEFAULT_SANS = "sample.onap.org,component.sample.onap.org";
public static final String FEED = "dcaegen2.nodes.Feed";
public static final String TOPIC = "dcaegen2.nodes.Topic";
public static final String PUBLISH_EVENTS = "dcaegen2.relationships.publish_events";
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateParametersFactoryService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateParametersFactoryService.java
index b739e4b..300aa5d 100644
--- a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateParametersFactoryService.java
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateParametersFactoryService.java
@@ -4,6 +4,7 @@
* * org.onap.dcae
* * ================================================================================
* * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * 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.
@@ -34,9 +35,8 @@ import java.util.Map;
/**
* @author : Ravi Mantena
- * @date 10/16/2020
- * Application: ONAP - Blueprint Generator
- * Common ONAP Service used by ONAP and DMAAP Blueprint to add External Certificate Parameters
+ * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service used by ONAP and DMAAP Blueprint to add
+ * External Certificate Parameters
*/
@@ -58,11 +58,14 @@ public class ExternalCertificateParametersFactoryService extends ExternalCertifi
public Map<String, LinkedHashMap<String, Object>> createInputList() {
Map<String, LinkedHashMap<String, Object>> retInputs = new LinkedHashMap<>();
- LinkedHashMap<String, Object> commonNameInputMap = blueprintHelperService.createStringInput("Common name which should be present in certificate.",Constants.DEFAULT_COMMON_NAME);
+ LinkedHashMap<String, Object> commonNameInputMap = blueprintHelperService
+ .createStringInput("Common name which should be present in certificate.", Constants.DEFAULT_COMMON_NAME);
retInputs.put(addPrefix(Constants.COMMON_NAME_FIELD), commonNameInputMap);
- LinkedHashMap<String, Object> sansInputMap = blueprintHelperService.createStringInput("\"List of Subject Alternative Names (SANs) which should be present in certificate. " +
- "Delimiter - : Should contain a common_name value and other FQDNs under which the given " +"component is accessible.\"",Constants.DEFAULT_SANS);
+ LinkedHashMap<String, Object> sansInputMap = blueprintHelperService
+ .createStringInput("\"List of Subject Alternative Names (SANs) which should be present in certificate. " +
+ "Delimiter - , Should contain a common_name value and other FQDNs under which the given "
+ + "component is accessible.\"", Constants.DEFAULT_SANS);
retInputs.put(addPrefix(Constants.SANS_FIELD), sansInputMap);
return retInputs;
diff --git a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/TlsInfoTest.java b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/TlsInfoTest.java
index f4bbe3e..9eb6899 100644
--- a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/TlsInfoTest.java
+++ b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/TlsInfoTest.java
@@ -42,127 +42,133 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-
//@RunWith(Parameterized.class)
-public class TlsInfoTest extends BlueprintGeneratorTests {
-
- @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(){
- //Input input = input.setComponentSpecPath(componentSpecPath + "testComponentSpec_withTlsTrueAndExternalTlsTrue.json");
- OnapBlueprint bp = createBlueprintFromFile(Paths.get("src", "test", "resources", "componentspecs", useTlsTrueAndUseExternalTlsTrueTest).toFile().getAbsolutePath());
-
- assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(bp, true);
- assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, true);
- }
-
- @Test
- public void useTlsFalseAndUseExternalTlsFalseTest(){
- OnapBlueprint bp = createBlueprintFromFile(Paths.get("src", "test", "resources", "componentspecs", useTlsFalseAndUseExternalTlsFalseTest).toFile().getAbsolutePath());
-
- assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(bp, false);
- assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, false);
- }
-
- @Test
- public void useTlsTrueAndNoExternalTlsFlagTest(){
- OnapBlueprint bp = createBlueprintFromFile(Paths.get("src", "test", "resources", "componentspecs", useTlsTrueAndNoExternalTlsFlagTest).toFile().getAbsolutePath());
-
- assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, true);
- assertBlueprintHasNoExternalTlsInfo(bp);
- }
-
- @Test
- public void noTlsInfo(){
- OnapBlueprint bp = createBlueprintFromFile(Paths.get("src", "test", "resources", "componentspecs", noTlsInfo).toFile().getAbsolutePath());
-
- assertBlueprintHasNoTlsInfo(bp);
- assertBlueprintHasNoExternalTlsInfo(bp);
- }
-
- private void assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(OnapBlueprint 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().getBpInputName());
- assertEquals("external_cert_cert_type", externalTlsInfo.getCertType().getBpInputName());
- assertEquals("external_cert_use_external_tls", externalTlsInfo.getUseExternalTls().getBpInputName());
- assertEquals("/opt/app/dcae-certificate/", externalTlsInfo.getExternalCertDirectory());
-
- ExternalCertificateParameters extCertParams = externalTlsInfo.getExternalCertificateParameters();
- assertNotNull(extCertParams);
-
- assertEquals("external_cert_common_name", extCertParams.getCommonName().getBpInputName());
- assertEquals("external_cert_sans", extCertParams.getSans().getBpInputName());
- }
-
- private void assertBlueprintContainsTlsInfoWithUseFlagDefault(OnapBlueprint 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().getBpInputName());
- assertEquals("/opt/app/dcae-certificate/", tlsInfo.getCertDirectory());
-
- }
-
- private void assertBlueprintHasNoExternalTlsInfo(OnapBlueprint 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(OnapBlueprint bp) {
- //should not create inputs for tls
- assertFalse(bp.getInputs().containsKey("use_tls"));
+public class TlsInfoTest extends BlueprintGeneratorTests {
+
+ @Parameterized.Parameter
+ public char bpType;
+
+ @Parameterized.Parameters(name = "Blueprint type: {0}")
+ public static List<Character> data() {
+ return Arrays.asList('o', 'd');
+ }
- Node node = bp.getNode_templates().get("test.component.spec");
- //should not create tlsInfo object in node properties
- assertNull(node.getProperties().getTls_info());
- }
+ @Test
+ public void useTlsTrueAndUseExternalTlsTrueTest() {
+ //Input input = input.setComponentSpecPath(componentSpecPath + "testComponentSpec_withTlsTrueAndExternalTlsTrue.json");
+ OnapBlueprint bp = createBlueprintFromFile(
+ Paths.get("src", "test", "resources", "componentspecs", useTlsTrueAndUseExternalTlsTrueTest).toFile()
+ .getAbsolutePath());
- private void assertContainsInputWithDefault(OnapBlueprint bp, String inputName, Object defaultValue) {
- LinkedHashMap<String, Object> input = bp.getInputs().get(inputName);
- assertNotNull(input);
- assertEquals(defaultValue, input.get("default"));
- }
+ assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(bp, true);
+ assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, true);
+ }
- private OnapBlueprint createBlueprintFromFile(String path) {
- onapComponentSpec = onapComponentSpecService.createComponentSpecFromFile(path);
- Input input = onapTestUtils.getInput(path, "", "", "", "o", "");
- OnapBlueprint onapBlueprint = onapBlueprintService.createBlueprint(onapComponentSpec, input);
- return onapBlueprint;
- }
+ @Test
+ public void useTlsFalseAndUseExternalTlsFalseTest() {
+ OnapBlueprint bp = createBlueprintFromFile(
+ Paths.get("src", "test", "resources", "componentspecs", useTlsFalseAndUseExternalTlsFalseTest).toFile()
+ .getAbsolutePath());
+
+ assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(bp, false);
+ assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, false);
+ }
+
+ @Test
+ public void useTlsTrueAndNoExternalTlsFlagTest() {
+ OnapBlueprint bp = createBlueprintFromFile(
+ Paths.get("src", "test", "resources", "componentspecs", useTlsTrueAndNoExternalTlsFlagTest).toFile()
+ .getAbsolutePath());
+
+ assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, true);
+ assertBlueprintHasNoExternalTlsInfo(bp);
+ }
+
+ @Test
+ public void noTlsInfo() {
+ OnapBlueprint bp = createBlueprintFromFile(
+ Paths.get("src", "test", "resources", "componentspecs", noTlsInfo).toFile().getAbsolutePath());
+
+ assertBlueprintHasNoTlsInfo(bp);
+ assertBlueprintHasNoExternalTlsInfo(bp);
+ }
+
+ private void assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(OnapBlueprint 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().getBpInputName());
+ assertEquals("external_cert_cert_type", externalTlsInfo.getCertType().getBpInputName());
+ assertEquals("external_cert_use_external_tls", externalTlsInfo.getUseExternalTls().getBpInputName());
+ assertEquals("/opt/app/dcae-certificate/", externalTlsInfo.getExternalCertDirectory());
+
+ ExternalCertificateParameters extCertParams = externalTlsInfo.getExternalCertificateParameters();
+ assertNotNull(extCertParams);
+
+ assertEquals("external_cert_common_name", extCertParams.getCommonName().getBpInputName());
+ assertEquals("external_cert_sans", extCertParams.getSans().getBpInputName());
+ }
+
+ private void assertBlueprintContainsTlsInfoWithUseFlagDefault(OnapBlueprint 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().getBpInputName());
+ assertEquals("/opt/app/dcae-certificate/", tlsInfo.getCertDirectory());
+
+ }
+
+ private void assertBlueprintHasNoExternalTlsInfo(OnapBlueprint 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(OnapBlueprint 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(OnapBlueprint bp, String inputName, Object defaultValue) {
+ LinkedHashMap<String, Object> input = bp.getInputs().get(inputName);
+ assertNotNull(input);
+ assertEquals(defaultValue, input.get("default"));
+ }
+
+ private OnapBlueprint createBlueprintFromFile(String path) {
+ onapComponentSpec = onapComponentSpecService.createComponentSpecFromFile(path);
+ Input input = onapTestUtils.getInput(path, "", "", "", "o", "");
+ OnapBlueprint onapBlueprint = onapBlueprintService.createBlueprint(onapComponentSpec, input);
+ return onapBlueprint;
+ }
}