aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java25
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java33
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/MANIFEST.json22
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/first.env0
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/first.yaml25
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/firstVol.yaml19
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/MANIFEST.json27
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/first.yaml37
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/firstVol.yaml19
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/second.yaml14
10 files changed, 206 insertions, 15 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java
index 569f2bb760..2dad766c45 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java
@@ -1,6 +1,7 @@
package org.openecomp.sdc.validation.impl.validators;
import org.apache.commons.collections4.MapUtils;
+import org.openecomp.core.validation.ErrorMessageCode;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
@@ -29,6 +30,9 @@ import java.util.Set;
public class ForbiddenResourceGuideLineValidator implements Validator {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private static Set<String> forbiddenResources = new HashSet<>();
+ private static final ErrorMessageCode ERROR_CODE_FRG_1 = new ErrorMessageCode("FRG1");
+ private static final ErrorMessageCode ERROR_CODE_FRG_2 = new ErrorMessageCode("FRG2");
+ private static final ErrorMessageCode ERROR_CODE_FRG_3 = new ErrorMessageCode("FRG3");
private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
@@ -40,10 +44,6 @@ public class ForbiddenResourceGuideLineValidator implements Validator {
forbiddenResourcesMap.entrySet().stream()
.filter(entry -> isResourceEnabled(entry.getValue().get("enable")))
.forEach(entry -> forbiddenResources.add(entry.getKey()));
-
-
-
-
}
private boolean isResourceEnabled(Object enableValue){
@@ -78,8 +78,10 @@ public class ForbiddenResourceGuideLineValidator implements Validator {
}
private void validate(String fileName, GlobalValidationContext globalContext) {
+ globalContext.setMessageCode(ERROR_CODE_FRG_3);
HeatOrchestrationTemplate
- heatOrchestrationTemplate = ValidationUtil.checkHeatOrchestrationPreCondition(fileName, globalContext);
+ heatOrchestrationTemplate = ValidationUtil.checkHeatOrchestrationPreCondition(
+ fileName, globalContext);
if (heatOrchestrationTemplate == null) {
return;
}
@@ -103,18 +105,19 @@ public class ForbiddenResourceGuideLineValidator implements Validator {
String resourceType = resourceEntry.getValue().getType();
if (Objects.isNull(resourceType)) {
globalContext.addMessage(fileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder
- .getErrorWithParameters(Messages.INVALID_RESOURCE_TYPE.getErrorMessage(), "null",
+ .getErrorWithParameters(ERROR_CODE_FRG_1,
+ Messages.INVALID_RESOURCE_TYPE.getErrorMessage(),"null",
resourceEntry.getKey()), LoggerTragetServiceName.VALIDATE_RESOURCE_TYPE,
LoggerErrorDescription.INVALID_RESOURCE_TYPE);
} else {
- if(isResourceForbidden(resourceType)){
- globalContext.addMessage(
+ if (isResourceForbidden(resourceType)){
+ globalContext.addMessage(
fileName,
ErrorLevel.WARNING,
ErrorMessagesFormatBuilder
- .getErrorWithParameters(Messages.FORBIDDEN_RESOURCE_IN_USE.getErrorMessage(),
- resourceType,
- resourceEntry.getKey()),
+ .getErrorWithParameters(ERROR_CODE_FRG_2, Messages.FORBIDDEN_RESOURCE_IN_USE
+ .getErrorMessage(),
+ resourceType, resourceEntry.getKey()),
LoggerTragetServiceName.VALIDATE_FORBIDDEN_RESOURCE,
LoggerErrorDescription.FLOATING_IP_IN_USE);
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java
index 90f9a759a6..e5240a3147 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidatorTest.java
@@ -14,6 +14,8 @@ import java.util.Map;
*/
public class ForbiddenResourceGuideLineValidatorTest {
+ private static final String RESOURCE_PATH = "/org/openecomp/validation/validators" +
+ "/guideLineValidator/heatFloatingIpResourceType";
private static String mockConfigFileName =
"/org/openecomp/validation/configuration/mock_resource_validator_configuration.json";
@@ -36,18 +38,41 @@ public class ForbiddenResourceGuideLineValidatorTest {
@Test
public void testFloatingIpResourceType() {
- Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(forbiddenResourceGuideLineValidator,
- "/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/positive");
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(
+ forbiddenResourceGuideLineValidator, RESOURCE_PATH + "/positive");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 0);
messages = ValidationTestUtil.testValidator(forbiddenResourceGuideLineValidator,
- "/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/negative");
+ RESOURCE_PATH + "/negative");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
- "WARNING: OS::Neutron::FloatingIP is in use, Resource ID [FSB2]");
+ "WARNING: [FRG2]: OS::Neutron::FloatingIP is in use, Resource ID [FSB2]");
+ }
+ @Test
+ public void testParseException(){
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(
+ forbiddenResourceGuideLineValidator, RESOURCE_PATH + "/parseException");
+ Assert.assertEquals(messages.size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: [FRG3]: Invalid HEAT format problem - [while scanning for the next token\n" +
+ "found character '\\t(TAB)' that cannot start any token. (Do not use \\t(TAB) " +
+ "for indentation)\n" + " in 'reader', line 5, column 1:\n" +
+ " \t\t\tresources:\n" +
+ " ^\n" +
+ "]");
+ }
+
+ @Test
+ public void testInvalidResourceType(){
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(
+ forbiddenResourceGuideLineValidator, RESOURCE_PATH + "/TestInvalidResourceType");
+ Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: [FRG1]: A resource has an invalid or unsupported type - null, " +
+ "Resource ID [FSB2]");
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/MANIFEST.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/MANIFEST.json
new file mode 100644
index 0000000000..c541783b06
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/MANIFEST.json
@@ -0,0 +1,22 @@
+{
+ "name": "validTest",
+ "description": "Valid Test",
+ "version": "1610",
+ "data": [
+ {
+ "file": "first.yaml",
+ "type": "HEAT",
+ "isBase": true,
+ "data": [
+ {
+ "file": "first.env",
+ "type": "HEAT_ENV"
+ },
+ {
+ "file": "firstVol.yaml",
+ "type": "HEAT_VOL"
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/first.env b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/first.env
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/first.env
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/first.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/first.yaml
new file mode 100644
index 0000000000..1244955e01
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/first.yaml
@@ -0,0 +1,25 @@
+heat_template_version: 2013-05-23
+
+description: heat expose volume resource
+
+resources:
+ FSB2:
+ type:
+ properties:
+ name: { get_param: fsb_name_2 }
+ block_device_mapping: [{device_name: "vda", volume_id : {get_param: VMME_FSB2_boot_volume }, delete_on_termination: "false" }]
+ flavor: { get_param: fsb2-flavor }
+ availability_zone: { get_param: availability_zone_0 }
+ metadata:
+ VNF_id: { get_param: vnfvfVF_id }
+ vf_module_id: { get_param: vf_module_id }
+ networks:
+ - port: { get_resource: FSB2_Internal1 }
+ - port: { get_resource: FSB2_Internal2 }
+ - port: { get_resource: FSB2_OAM }
+outputs:
+ expose_resource_nove_output:
+ description: the pcrf_server
+ value: { get_resource: FSB2 }
+
+
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/firstVol.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/firstVol.yaml
new file mode 100644
index 0000000000..7e82b2a7e6
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/TestInvalidResourceType/firstVol.yaml
@@ -0,0 +1,19 @@
+
+heat_template_version: 2013-05-23
+
+parameters:
+ not_null:
+ type: number
+ label: not_number
+
+
+resources:
+ volume_expose:
+ type: OS::Cinder::Volume
+ properties:
+ not_null: not_null
+outputs:
+ not_expose_resource_network_output:
+ description: the pcrf_server
+ value: { get_resource: volume_expose }
+
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/MANIFEST.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/MANIFEST.json
new file mode 100644
index 0000000000..76ce6de6e6
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/MANIFEST.json
@@ -0,0 +1,27 @@
+{
+ "name": "validTest",
+ "description": "Valid Test",
+ "version": "1610",
+ "data": [
+ {
+ "file": "first.yaml",
+ "type": "HEAT",
+ "isBase": true,
+ "data": [
+ {
+ "file": "first.env",
+ "type": "HEAT_ENV"
+ },
+ {
+ "file": "firstVol.yaml",
+ "type": "HEAT_VOL"
+ }
+ ]
+ },
+ {
+ "file": "second.yaml",
+ "type": "HEAT",
+ "isBase": false
+ }
+ ]
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/first.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/first.yaml
new file mode 100644
index 0000000000..2590f238df
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/first.yaml
@@ -0,0 +1,37 @@
+heat_template_version: 2013-05-23
+
+description: heat expose volume resource
+
+ resources:
+ FSB2_Internal1:
+ type: OS::Neutron::Port
+ properties:
+ network_id: { get_param: Internal1_net_id }
+ FSB2_Internal2:
+ type: OS::Neutron::Port
+ properties:
+ network_id: { get_param: Internal2_net_name }
+ FSB2_OAM:
+ type: OS::Neutron::Port
+ properties:
+ network_id: { get_param: Internal3_net_id }
+ FSB2:
+ type: OS::Nova::Server
+ properties:
+ name: { get_param: fsb2_name_2 }
+ block_device_mapping: [{device_name: "vda", volume_id : {get_param: VMME_FSB2_boot_volume }, delete_on_termination: "false" }]
+ flavor: { get_param: fsb2_flavor_name }
+ availability_zone: { get_param: availability_zone_0 }
+ metadata:
+ VNF_id: { get_param: vnfvfVF_id }
+ vf_module_id: { get_param: vf_module_id }
+ networks:
+ - port: { get_resource: FSB2_Internal1 }
+ - port: { get_resource: FSB2_Internal2 }
+ - port: { get_resource: FSB2_OAM }
+outputs:
+ expose_resource_nove_output:
+ description: the pcrf_server
+ value: { get_resource: FSB2 }
+
+
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/firstVol.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/firstVol.yaml
new file mode 100644
index 0000000000..7e82b2a7e6
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/firstVol.yaml
@@ -0,0 +1,19 @@
+
+heat_template_version: 2013-05-23
+
+parameters:
+ not_null:
+ type: number
+ label: not_number
+
+
+resources:
+ volume_expose:
+ type: OS::Cinder::Volume
+ properties:
+ not_null: not_null
+outputs:
+ not_expose_resource_network_output:
+ description: the pcrf_server
+ value: { get_resource: volume_expose }
+
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/second.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/second.yaml
new file mode 100644
index 0000000000..bb06b9d60a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/heatFloatingIpResourceType/parseException/second.yaml
@@ -0,0 +1,14 @@
+heat_template_version: 2013-05-23
+
+description: heat second
+
+resources:
+ network_expose:
+ type: OS::Neutron::Net
+
+outputs:
+ expose_resource_network_output:
+ description: the pcrf_server
+ value: { get_resource: network_expose }
+
+