summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog.md4
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java16
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206IntegrationTest.java38
-rw-r--r--csarvalidation/src/test/resources/pnf/r130206/csar-cert-in-root.csarbin0 -> 7473 bytes
-rw-r--r--csarvalidation/src/test/resources/pnf/r130206/csar-no-cert-no-tosca-dir.csarbin0 -> 6276 bytes
5 files changed, 56 insertions, 2 deletions
diff --git a/Changelog.md b/Changelog.md
index cc04a01..f55bc84 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -95,3 +95,7 @@ All notable changes to this project will be documented in this file.
- https://jira.onap.org/browse/VNFSDK-596
## [1.2.14]
+
+## Fixed
+- Fixed rule R130206 handling of CSARs with no TOSCA meta and no Certificate in root directory
+ - https://jira.onap.org/browse/VNFSDK-481
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java b/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
index 70cd8f3..05f2070 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
@@ -531,6 +531,13 @@ public class CSARArchive implements AutoCloseable {
}
}
+ public static class CSARErrorNoManifestsFound extends CSARError {
+ public CSARErrorNoManifestsFound() {
+ super("0x0016");
+ this.message = "No manifest file found in CSAR!";
+ }
+ }
+
/**
* Holds the CSAR meta data values in both Modes
*
@@ -1091,7 +1098,10 @@ public class CSARArchive implements AutoCloseable {
//manifest
files = this.tempDir.toFile().listFiles((dir, name) -> name.endsWith(MF));
- if (files.length > 1) {
+ if (files.length == 0) {
+ errors.add(new CSARErrorNoManifestsFound());
+ this.toscaMeta.setEntryManifestMf(null);
+ } else if (files.length > 1) {
List<String> fileNames = new ArrayList<>();
for (File f: files) {
fileNames.add(f.getName());
@@ -1118,7 +1128,9 @@ public class CSARArchive implements AutoCloseable {
//certificate
files = this.tempDir.toFile().listFiles((dir, name) -> name.endsWith(CERT));
- if (files.length > 1) {
+ if (files.length == 0) {
+ this.toscaMeta.setEntryCertificate(null);
+ } else if (files.length > 1) {
List<String> fileNames = new ArrayList<>();
for (File f: files) {
fileNames.add(f.getName());
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 443a61a..2d6d058 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
@@ -428,4 +428,42 @@ public class VTPValidateCSARR130206IntegrationTest {
"Unable to find cms signature!"
);
}
+
+ @Test
+ public void shouldReturnNoCertificationErrorWhenCertIsOnlyInRoot() throws Exception {
+
+ // given
+ configureTestCase(testCase, "pnf/r130206/csar-cert-in-root.csar", "vtp-validate-csar-r130206.yaml", IS_PNF);
+
+ // when
+ testCase.execute();
+
+ // then
+ List<CSARArchive.CSARError> errors = testCase.getErrors();
+
+ // This test returns other errors that are connected with missing tosca entry,
+ // in order to simplify testing, assertion only checks if certificate in root was found and used to validate CMS
+ assertThat(convertToMessagesList(errors)).contains(
+ "File has invalid signature!"
+ );
+ }
+
+ @Test
+ public void shouldReturnCertificateNotFoundErrorWhenCertIsNotPresentInCmsInRootAndTocsaDirectoryIsMissing() throws Exception {
+
+ // given
+ configureTestCase(testCase, "pnf/r130206/csar-no-cert-no-tosca-dir.csar", "vtp-validate-csar-r130206.yaml", IS_PNF);
+
+ // when
+ testCase.execute();
+
+ // then
+ List<CSARArchive.CSARError> errors = testCase.getErrors();
+
+ // This test returns other errors that are connected with missing tosca entry,
+ // in order to simplify testing, assertion only checks if "certificate not found" error was reported
+ assertThat(convertToMessagesList(errors)).contains(
+ "Unable to find cert file!"
+ );
+ }
}
diff --git a/csarvalidation/src/test/resources/pnf/r130206/csar-cert-in-root.csar b/csarvalidation/src/test/resources/pnf/r130206/csar-cert-in-root.csar
new file mode 100644
index 0000000..66c1a71
--- /dev/null
+++ b/csarvalidation/src/test/resources/pnf/r130206/csar-cert-in-root.csar
Binary files differ
diff --git a/csarvalidation/src/test/resources/pnf/r130206/csar-no-cert-no-tosca-dir.csar b/csarvalidation/src/test/resources/pnf/r130206/csar-no-cert-no-tosca-dir.csar
new file mode 100644
index 0000000..0b00af1
--- /dev/null
+++ b/csarvalidation/src/test/resources/pnf/r130206/csar-no-cert-no-tosca-dir.csar
Binary files differ