summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2020-05-12 11:19:47 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-06-16 05:41:19 +0000
commit8b53d639026267aef71659fe292a75e47555265f (patch)
tree43f391246c42907a6de8e5ef20093274d34ce8f1 /openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test
parentc74aa44beabc303a5cf709625ee802dcd1bb9f5d (diff)
Manifest is optional in ETSI SOL004 manifest
SOL004MetaDirectoryValidtor enforces all files contained in an ETSI SOL004 CSAR are included in the manifest file, however the manifest itself is not mandatory to include in the manifest Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-3057 Change-Id: I460071ecbd21578edb0603f600da0ac1ea877539
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java
index d64faa051b..d6ff7022c3 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java
@@ -340,6 +340,61 @@ public class SOL004MetaDirectoryValidatorTest {
final Map<String, List<ErrorMessage>> errors = sol004MetaDirectoryValidator.validateContent(handler);
assertExpectedErrors("Manifest referenced import file missing", errors, 1);
}
+
+ @Test
+ public void testGivenDefinitionFile_whenFileInPackageNotInManifest_thenErrorIsReturned() {
+ final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder();
+
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8));
+ manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME);
+
+ handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
+ manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
+
+ handler.addFile(SAMPLE_SOURCE, "".getBytes());
+
+ final byte [] sampleDefinitionFile =
+ getResourceBytesOrFail("validation.files/definition/sampleDefinitionFile2.yaml");
+ handler.addFile("Definitions/etsi_nfv_sol001_pnfd_2_5_2_types.yaml", sampleDefinitionFile);
+ manifestBuilder.withSource("Definitions/etsi_nfv_sol001_pnfd_2_5_2_types.yaml");
+
+ manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
+ handler.addFile(TOSCA_DEFINITION_FILEPATH,
+ getResourceBytesOrFail("validation.files/definition/sampleDefinitionFile2.yaml"));
+
+ handler.addFile(TOSCA_MANIFEST_FILEPATH, manifestBuilder.build().getBytes(StandardCharsets.UTF_8));
+
+ final Map<String, List<ErrorMessage>> errors = sol004MetaDirectoryValidator.validateContent(handler);
+ assertExpectedErrors("Artifact is not being referenced in manifest file", errors, 1);
+ }
+
+ @Test
+ public void testGivenDefinitionFile_whenManifestNotreferencedInManifest_thenNoErrorIsReturned() {
+ final ManifestBuilder manifestBuilder = getVnfManifestSampleBuilder();
+
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileBuilder.toString().getBytes(StandardCharsets.UTF_8));
+ manifestBuilder.withSource(TOSCA_META_PATH_FILE_NAME);
+
+ handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8));
+ manifestBuilder.withSource(TOSCA_CHANGELOG_FILEPATH);
+
+ handler.addFile(SAMPLE_SOURCE, "".getBytes());
+ manifestBuilder.withSource(SAMPLE_SOURCE);
+
+ final byte [] sampleDefinitionFile =
+ getResourceBytesOrFail("validation.files/definition/sampleDefinitionFile2.yaml");
+ handler.addFile("Definitions/etsi_nfv_sol001_pnfd_2_5_2_types.yaml", sampleDefinitionFile);
+ manifestBuilder.withSource("Definitions/etsi_nfv_sol001_pnfd_2_5_2_types.yaml");
+
+ manifestBuilder.withSource(TOSCA_DEFINITION_FILEPATH);
+ handler.addFile(TOSCA_DEFINITION_FILEPATH,
+ getResourceBytesOrFail("validation.files/definition/sampleDefinitionFile2.yaml"));
+
+ handler.addFile(TOSCA_MANIFEST_FILEPATH, manifestBuilder.build().getBytes(StandardCharsets.UTF_8));
+
+ final Map<String, List<ErrorMessage>> errors = sol004MetaDirectoryValidator.validateContent(handler);
+ assertEquals(0, errors.size());
+ }
/**
* Reference with invalid YAML format.