summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/main/java
diff options
context:
space:
mode:
authorBogumil Zebek <bogumil.zebek@nokia.com>2019-09-17 10:24:53 +0200
committerZebek Bogumil <bogumil.zebek@nokia.com>2019-09-17 10:24:53 +0200
commit167aea9954cfe9e6528671dd37445d4fc3378a97 (patch)
treeee7e5cbe0ff5240b8df358fde11fdf0fad1fdc36 /csarvalidation/src/main/java
parent3e0efbc34176ad3ad2e6d731a699f5684c0a527d (diff)
Non mano artifacts
Change-Id: I4d7eefc999f9cd6cb5255b764da3c5ae7e84f0af Issue-ID: VNFSDK-476 Signed-off-by: Zebek Bogumil <bogumil.zebek@nokia.com>
Diffstat (limited to 'csarvalidation/src/main/java')
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206.java34
1 files changed, 34 insertions, 0 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) {