From 1e579c2910080e9e7b22e57d6fcfe3a4e443bffa Mon Sep 17 00:00:00 2001 From: Bartosz Gardziejewski Date: Tue, 7 Jul 2020 07:43:03 +0200 Subject: Extend R01123 to support ZIP files Issue-ID: VNFSDK-583 Signed-off-by: Bartosz Gardziejewski Change-Id: Ie63d1ff3f38d10643bd895b5ed720997c189920a --- .../java/org/onap/cvc/csar/CsarValidatorTest.java | 42 +++++++++++----------- .../VTPValidateCSARR01123IntegrationTest.java | 31 ++++++++++++++++ 2 files changed, 51 insertions(+), 22 deletions(-) (limited to 'csarvalidation/src/test/java') 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 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 containingMissingFiles = new HamcrestCondition<>( + containsString("Artifacts/Informational/user_guide.txt") + ); + + // then + List errors = testCase.getErrors(); + assertThat(errors.size()).isEqualTo(1); + assertThat(convertToMessagesList(errors)).haveExactly(1, containingMissingFiles); + } + } -- cgit 1.2.3-korg