aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java6
-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
2 files changed, 60 insertions, 1 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
index 1d1ffdba91..f41b44fd79 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
@@ -467,12 +467,16 @@ class SOL004MetaDirectoryValidator implements Validator {
*/
private void verifyFilesBeingReferred(final Set<String> referredFileSet, final Set<String> packageFileSet) {
packageFileSet.forEach(filePath -> {
- if (!referredFileSet.contains(filePath)) {
+ if (!isManifestFile(filePath) && !referredFileSet.contains(filePath)) {
reportError(ErrorLevel.ERROR,
String.format(Messages.MISSING_MANIFEST_REFERENCE.getErrorMessage(), filePath));
}
});
}
+
+ private boolean isManifestFile(final String filePath) {
+ return filePath.equals(toscaMetadata.getMetaEntries().get(ETSI_ENTRY_MANIFEST.getName()));
+ }
private List<String> filterSources(final List<String> source) {
return source.stream()
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.