diff options
author | Bogumil Zebek <bogumil.zebek@nokia.com> | 2020-07-07 07:37:39 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-07-07 07:37:39 +0000 |
commit | acc4f065bea5608a4e812f6126c102abe8206748 (patch) | |
tree | d4d49d1550f8bb7e403376a2920417b685a0a277 /csarvalidation/src | |
parent | a31e3acd014ae0f2cb7304bf25c9a7d50ae92eca (diff) | |
parent | 1e579c2910080e9e7b22e57d6fcfe3a4e443bffa (diff) |
Merge "Extend R01123 to support ZIP files"
Diffstat (limited to 'csarvalidation/src')
5 files changed, 52 insertions, 24 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123.java index 8b17e25..69563b0 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123.java @@ -59,8 +59,7 @@ public class VTPValidateCSARR01123 extends VTPValidateCSARBase { csar.getVersion() == null) { errors.add(new CSARErrorEntryVNFProviderDetailsNotFound()); } - - Path rootFolder = csar.getWorkspace().getRootFolder() + Path rootFolder = csar.getWorkspace().getPathToCsarFolder() .orElseThrow(() -> new IOException("Couldn't find CSAR root catalog")); List<String> filesInCsar = getAllFilesInDirectory(rootFolder); List<String> sourcesInManifest = getAllFilesFromManifestSources(csar.getManifest()); diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/CsarValidatorTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/CsarValidatorTest.java index ecdd6fe..d742ca6 100644 --- a/csarvalidation/src/test/java/org/onap/cvc/csar/CsarValidatorTest.java +++ b/csarvalidation/src/test/java/org/onap/cvc/csar/CsarValidatorTest.java @@ -34,18 +34,17 @@ import static org.onap.cvc.csar.cc.sol004.IntegrationTestUtils.absoluteFilePath; public class CsarValidatorTest { - public static final String NO_CERTIFICATE_RULE = "r130206"; - public static final String NO_ALL_FILES_LISTED_IN_MANIFEST = "r01123"; - public static final String OPERATION_STATUS_FAILED = "FAILED"; + private static final String NO_CERTIFICATE_RULE = "r130206"; + private static final String OPERATION_STATUS_FAILED = "FAILED"; @Test public void shouldReportThanVnfValidationFailed() throws URISyntaxException { // given OnapCliWrapper cli = new OnapCliWrapper(new String[]{ - "--product", "onap-dublin", - "csar-validate", - "--format", "json", - "--csar", absoluteFilePath("VoLTE.csar")}); + "--product", "onap-dublin", + "csar-validate", + "--format", "json", + "--csar", absoluteFilePath("VoLTE.csar")}); // when cli.handle(); @@ -62,11 +61,11 @@ public class CsarValidatorTest { public void shouldReportThatPnfValidationFailedWhenCsarDoNotHaveCertificate_allOtherRulesShouldPass() throws URISyntaxException { // given OnapCliWrapper cli = new OnapCliWrapper(new String[]{ - "--product", "onap-dublin", - "csar-validate", - "--format", "json", - "--pnf", - "--csar", absoluteFilePath("pnf/r972082/validFile.csar")}); + "--product", "onap-dublin", + "csar-validate", + "--format", "json", + "--pnf", + "--csar", absoluteFilePath("pnf/r972082/validFile.csar")}); // when cli.handle(); @@ -82,11 +81,11 @@ public class CsarValidatorTest { public void shouldReportThatPnfValidationFailedWhenZipDoNotHaveCertificate_allOtherRulesShouldPass() throws URISyntaxException { // given OnapCliWrapper cli = new OnapCliWrapper(new String[]{ - "--product", "onap-dublin", - "csar-validate", - "--format", "json", - "--pnf", - "--csar", absoluteFilePath("pnf/signed-package-valid-signature.zip")}); + "--product", "onap-dublin", + "csar-validate", + "--format", "json", + "--pnf", + "--csar", absoluteFilePath("pnf/signed-package-valid-signature.zip")}); // when cli.handle(); @@ -94,9 +93,8 @@ public class CsarValidatorTest { // then final OnapCommandResult onapCommandResult = cli.getCommandResult(); verifyThatOperation(onapCommandResult, OPERATION_STATUS_FAILED); - verifyThatXRulesFails(onapCommandResult, 2); + verifyThatXRulesFails(onapCommandResult, 1); verifyThatRuleFails(onapCommandResult, NO_CERTIFICATE_RULE); - verifyThatRuleFails(onapCommandResult, NO_ALL_FILES_LISTED_IN_MANIFEST); verifyThatOperationFinishedWithoutAnyError(cli); } @@ -136,11 +134,11 @@ public class CsarValidatorTest { assertEquals(0, cli.getExitCode()); } - class OnapCliWrapper extends OnapCli { + static class OnapCliWrapper extends OnapCli { private OnapCommandResult commandResult; - public OnapCliWrapper(String[] args) { + OnapCliWrapper(String[] args) { super(args); } @@ -150,7 +148,7 @@ public class CsarValidatorTest { this.commandResult = cmd.getResult(); } - public OnapCommandResult getCommandResult() { + OnapCommandResult getCommandResult() { return this.commandResult; } } diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123IntegrationTest.java index 8f6ebbe..d08e00c 100644 --- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123IntegrationTest.java +++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR01123IntegrationTest.java @@ -123,4 +123,35 @@ public class VTPValidateCSARR01123IntegrationTest { assertThat(errors.size()).isEqualTo(0); } + @Test + public void shouldNotReportAnyErrorWhenValidCsarIsZippedWithCmsFile() throws Exception { + // given + configureTestCase(testCase, TEST_CSAR_DIRECTORY + "csar-option2-valid-with-cms.zip", "vtp-validate-csar-r01123.yaml", IS_PNF); + + // when + testCase.execute(); + + // then + List<CSARArchive.CSARError> errors = testCase.getErrors(); + assertThat(errors.size()).isEqualTo(0); + } + + @Test + public void shouldReportThatFileIsNotPresentInSourcesWhenInvalidCsarFileIsZippedWithCmsFile() throws Exception { + // given + configureTestCase(testCase, TEST_CSAR_DIRECTORY + "csar-option2-invalid-with-cms.zip", "vtp-validate-csar-r01123.yaml", IS_PNF); + + // when + testCase.execute(); + + Condition<String> containingMissingFiles = new HamcrestCondition<>( + containsString("Artifacts/Informational/user_guide.txt") + ); + + // then + List<CSARArchive.CSARError> errors = testCase.getErrors(); + assertThat(errors.size()).isEqualTo(1); + assertThat(convertToMessagesList(errors)).haveExactly(1, containingMissingFiles); + } + } diff --git a/csarvalidation/src/test/resources/pnf/r01123/csar-option2-invalid-with-cms.zip b/csarvalidation/src/test/resources/pnf/r01123/csar-option2-invalid-with-cms.zip Binary files differnew file mode 100644 index 0000000..8c30c68 --- /dev/null +++ b/csarvalidation/src/test/resources/pnf/r01123/csar-option2-invalid-with-cms.zip diff --git a/csarvalidation/src/test/resources/pnf/r01123/csar-option2-valid-with-cms.zip b/csarvalidation/src/test/resources/pnf/r01123/csar-option2-valid-with-cms.zip Binary files differnew file mode 100644 index 0000000..6965b95 --- /dev/null +++ b/csarvalidation/src/test/resources/pnf/r01123/csar-option2-valid-with-cms.zip |