summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/FileArchive.java5
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206.java2
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/FileArchiveTest.java35
-rw-r--r--csarvalidation/src/test/resources/vnf/noDirectoryEntry.csarbin0 -> 3154 bytes
4 files changed, 40 insertions, 2 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/FileArchive.java b/csarvalidation/src/main/java/org/onap/cvc/csar/FileArchive.java
index 86904b1..e2aa06b 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/FileArchive.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/FileArchive.java
@@ -122,6 +122,11 @@ public class FileArchive {
if(entry.isDirectory()){
filePath.mkdirs();
} else {
+ //create directories for sub directories in zip
+ File parentPathFile = filePath.getParentFile();
+ if (parentPathFile != null) {
+ parentPathFile.mkdirs();
+ }
extract(zipInputStream, filePath);
}
}
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 e36314a..16b6942 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
@@ -124,7 +124,7 @@ public class VTPValidateCSARR130206 extends VTPValidateCSARBase {
}
} catch (Exception e) {
LOG.error("Internal VTPValidateCSARR130206 command error", e);
- throw new OnapCommandException("0x3000", "Internal VTPValidateCSARR787966 command error. See logs.");
+ throw new OnapCommandException("0x3000", "Internal VTPValidateCSARR130206 command error. See logs.");
}
}
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/FileArchiveTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/FileArchiveTest.java
index 738b4f6..1c66bbe 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/FileArchiveTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/FileArchiveTest.java
@@ -66,4 +66,37 @@ public class FileArchiveTest {
assertTrue(workspace.getPathToCmsFile().isPresent());
}
-} \ No newline at end of file
+ @Test
+ public void shouldUnpackCsarNoDirectoryEntry() throws URISyntaxException, IOException {
+ /*
+ * We should be able to unpack the csar with the following simlary zip entries:
+ * $ unzip -l /tmp/output1.csar
+ * Archive: /tmp/output1.csar
+ * Length Date Time Name
+ * --------- ---------- ----- ----
+ * 0 2019-11-01 14:29 ChangeLog.txt
+ * 1143 2019-11-01 14:29 test.crt
+ * 782 2019-11-01 14:29 test_entry.yaml
+ * 0 2019-11-01 14:29 Tests/test
+ * 1516 2019-11-12 09:52 test_entry.mf
+ * 237 2019-11-12 09:52 TOSCA-Metadata/TOSCA.meta
+ * --------- -------
+ * 3678 7 files
+ */
+
+ // given
+ String absolutePath = folder.getRoot().getAbsolutePath();
+
+ // when
+ FileArchive.Workspace workspace = new FileArchive(absolutePath).unpack(absoluteFilePath("vnf/noDirectoryEntry.csar"));
+
+ // then
+ assertFalse(workspace.isZip());
+ assertTrue(workspace.getRootFolder().isPresent());
+ assertTrue(workspace.getPathToCsarFolder().isPresent());
+ assertFalse(workspace.getPathToCertFile().isPresent());
+ assertFalse(workspace.getPathToCmsFile().isPresent());
+ }
+
+
+}
diff --git a/csarvalidation/src/test/resources/vnf/noDirectoryEntry.csar b/csarvalidation/src/test/resources/vnf/noDirectoryEntry.csar
new file mode 100644
index 0000000..1868264
--- /dev/null
+++ b/csarvalidation/src/test/resources/vnf/noDirectoryEntry.csar
Binary files differ