summaryrefslogtreecommitdiffstats
path: root/csarvalidation
diff options
context:
space:
mode:
Diffstat (limited to 'csarvalidation')
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206.java34
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206IntegrationTest.java8
-rw-r--r--csarvalidation/src/test/resources/pnf/r130206/csar-option1-valid.csarbin7324 -> 7530 bytes
3 files changed, 39 insertions, 3 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206.java
index 2d85e35..e36314a 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206.java
@@ -38,7 +38,9 @@ import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.NoSuchAlgorithmException;
+import java.util.Collection;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -102,6 +104,13 @@ public class VTPValidateCSARR130206 extends VTPValidateCSARBase {
}
}
+ public static class CSARErrorContentMismatch extends CSARArchive.CSARError {
+ CSARErrorContentMismatch() {
+ super("0x4008");
+ this.message = "Mismatch between contents of non-mano-artifact-sets and source files of the package";
+ }
+ }
+
@Override
protected void validateCSAR(CSARArchive csar) throws OnapCommandException {
@@ -126,12 +135,37 @@ public class VTPValidateCSARR130206 extends VTPValidateCSARBase {
validateSecurityStructure(csar, csarRootDirectory);
validateSources(csarRootDirectory, manifest);
+ final Map<String, Map<String, List<String>>> nonMano = manifest.getNonMano();
+ final List<SourcesParser.Source> sources = manifest.getSources();
+
+ validateNonManoCohesionWithSources(nonMano, sources);
+
final File manifestMfFile = csar.getManifestMfFile();
if (manifestMfFile != null) {
validateFileSignature(manifestMfFile);
}
}
+ private void validateNonManoCohesionWithSources(final Map<String, Map<String, List<String>>> nonMano, final List<SourcesParser.Source> sources) {
+
+ final Collection<Map<String, List<String>>> values = nonMano.values();
+ final List<String> nonManoSourcePaths = values.stream()
+ .map(Map::values)
+ .flatMap(Collection::stream)
+ .flatMap(List::stream)
+ .filter(it -> !it.isEmpty())
+ .collect(Collectors.toList());
+
+ final List<String> sourcePaths = sources.stream()
+ .map(SourcesParser.Source::getValue)
+ .collect(Collectors.toList());
+
+ if(!sourcePaths.containsAll(nonManoSourcePaths)){
+ this.errors.add(new CSARErrorContentMismatch());
+ }
+
+ }
+
private void validateFileSignature(File manifestMfFile) {
final boolean isValid = this.manifestFileSignatureValidator.isValid(manifestMfFile);
if (!isValid) {
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206IntegrationTest.java
index 90da946..036e169 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206IntegrationTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206IntegrationTest.java
@@ -73,9 +73,10 @@ public class VTPValidateCSARR130206IntegrationTest {
// then
List<CSARArchive.CSARError> errors = testCase.getErrors();
- assertThat(errors.size()).isEqualTo(1);
+ assertThat(errors.size()).isEqualTo(2);
assertThat(convertToMessagesList(errors)).contains(
- "File has invalid CMS signature!"
+ "File has invalid CMS signature!",
+ "Mismatch between contents of non-mano-artifact-sets and source files of the package"
);
}
@@ -90,12 +91,13 @@ public class VTPValidateCSARR130206IntegrationTest {
// then
List<CSARArchive.CSARError> errors = testCase.getErrors();
- assertThat(errors.size()).isEqualTo(5);
+ assertThat(errors.size()).isEqualTo(6);
assertThat(convertToMessagesList(errors)).contains(
"Unable to find CMS section in manifest!",
"Source 'Definitions/MainServiceTemplate.yaml' has wrong hash!",
"Source 'Artifacts/Other/my_script.csh' has hash, but unable to find algorithm tag!",
"Unable to calculate digest - file missing: Artifacts/NonExisting2.txt",
+ "Mismatch between contents of non-mano-artifact-sets and source files of the package",
"File has invalid CMS signature!"
);
}
diff --git a/csarvalidation/src/test/resources/pnf/r130206/csar-option1-valid.csar b/csarvalidation/src/test/resources/pnf/r130206/csar-option1-valid.csar
index 7cca18d..08c3605 100644
--- a/csarvalidation/src/test/resources/pnf/r130206/csar-option1-valid.csar
+++ b/csarvalidation/src/test/resources/pnf/r130206/csar-option1-valid.csar
Binary files differ