From e66d2541cf7ee1836784681331b6909421a86d63 Mon Sep 17 00:00:00 2001 From: Bogumil Zebek Date: Fri, 26 Jul 2019 10:25:09 +0200 Subject: Option 1 - vnf only Change-Id: I281dddab930328f24b9267aa6afc6ae08fd9ed01 Issue-ID: VNFSDK-396 Signed-off-by: Zebek Bogumil --- .../java/org/onap/cvc/csar/PnfCSARArchiveTest.java | 10 +-- .../org/onap/cvc/csar/VnfManifestParserTest.java | 84 ++++++++++++++++++++++ .../cvc/csar/cc/sol004/IntegrationTestUtils.java | 20 ++++-- .../VTPValidateCSARR10087IntegrationTest.java | 11 +-- .../VTPValidateCSARR146092IntegrationTest.java | 11 +-- .../VTPValidateCSARR293901IntegrationTest.java | 9 +-- .../VTPValidateCSARR57019IntegrationTest.java | 7 +- .../VTPValidateCSARR787965IntegrationTest.java | 9 +-- .../VTPValidateCSARR787966IntegrationTest.java | 29 ++++++-- .../VTPValidateCSARR87234IntegrationTest.java | 3 +- 10 files changed, 158 insertions(+), 35 deletions(-) create mode 100644 csarvalidation/src/test/java/org/onap/cvc/csar/VnfManifestParserTest.java (limited to 'csarvalidation/src/test/java/org/onap/cvc/csar') diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java index bc27ed1..cf24e53 100644 --- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java +++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java @@ -40,7 +40,7 @@ public class PnfCSARArchiveTest { pnfCSARArchive.init(fileName); pnfCSARArchive.parse(); // then - PnfCSARArchive.PnfManifest manifest = (PnfCSARArchive.PnfManifest) pnfCSARArchive.getManifest(); + CSARArchive.Manifest manifest = pnfCSARArchive.getManifest(); verifyThatMetadataWasSet(manifest); verifyThatCmsSectionWasSet(manifest); verifyThatSourcesSectionWasSet(manifest); @@ -50,7 +50,7 @@ public class PnfCSARArchiveTest { } - private void verifyThatMetadataWasSet(PnfCSARArchive.PnfManifest manifest) { + private void verifyThatMetadataWasSet(CSARArchive.Manifest manifest) { CSARArchive.Manifest.Metadata metadata = manifest.getMetadata(); assertThat(metadata.getProductName()).isEqualTo("RadioNode"); assertThat(metadata.getProviderId()).isEqualTo("Ericsson"); @@ -58,7 +58,7 @@ public class PnfCSARArchiveTest { assertThat(metadata.getReleaseDateTime()).isEqualTo("2019-01-14T11:25:00+00:00"); } - private void verifyThatSourcesSectionWasSet(PnfCSARArchive.PnfManifest manifest) { + private void verifyThatSourcesSectionWasSet(CSARArchive.Manifest manifest) { List sources = manifest.getSources(); assertThat(sources).contains( @@ -68,13 +68,13 @@ public class PnfCSARArchiveTest { ); } - private void verifyThatCmsSectionWasSet(PnfCSARArchive.PnfManifest manifest) { + private void verifyThatCmsSectionWasSet(CSARArchive.Manifest manifest) { String cms = manifest.getCms(); assertThat(cms).isEqualTo("MIGDBgsqhkiG9w0BCRABCaB0MHICAQAwDQYLKoZIhvcNAQkQAwgwXgYJKoZIhvcNAQcBoFEET3icc87PK0nNK9ENqSxItVIoSa0o0S/ISczMs1ZIzkgsKk4tsQ0N1nUMdvb05OXi5XLPLEtViMwvLVLwSE0sKlFIVHAqSk3MBkkBAJv0Fx0="); } - private void verifyThatNonManoArtifactsWereSet(PnfCSARArchive.PnfManifest manifest) { + private void verifyThatNonManoArtifactsWereSet(CSARArchive.Manifest manifest) { Map>> nonManoArtifacts = manifest.getNonMano(); assertThat(nonManoArtifacts.get("onap_ves_events").get(SOURCE_TAG)) .isEqualTo(Lists.newArrayList("Artifacts/Events/VES_registration.yml") diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/VnfManifestParserTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/VnfManifestParserTest.java new file mode 100644 index 0000000..91bb6b1 --- /dev/null +++ b/csarvalidation/src/test/java/org/onap/cvc/csar/VnfManifestParserTest.java @@ -0,0 +1,84 @@ +/* + * Copyright 2019 Nokia + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.onap.cvc.csar; + +import org.apache.commons.lang3.tuple.Pair; +import org.junit.Before; +import org.junit.Test; +import org.onap.cvc.csar.parser.SourcesParser; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class VnfManifestParserTest { + + private VnfManifestParser vnfManifestParser; + + @Before + public void setUp() throws IOException { + vnfManifestParser = VnfManifestParser.getInstance(new File("./src/test/resources/vnf/MainServiceTemplate.mf")); + } + + @Test + public void shouldFetchMetadataFromFile() { + Pair> metadataListPair = vnfManifestParser.fetchMetadata(); + CSARArchive.Manifest.Metadata metadata = metadataListPair.getKey(); + List errors = metadataListPair.getValue(); + + assertThat(errors.size()).isEqualTo(0); + assertThat(metadata.getProductName()).isEqualTo(" vCSCF"); + assertThat(metadata.getProviderId()).isEqualTo(" ZTE"); + assertThat(metadata.getPackageVersion()).isEqualTo(" 1.0"); + assertThat(metadata.getReleaseDateTime()).isEqualTo(" 2017.01.01T10"); + } + + @Test + public void shouldFetchSourcesSectionFromFile() { + + Pair, List> sourcesPair = vnfManifestParser.fetchSourcesSection(); + List sources = sourcesPair.getKey(); + List errors = sourcesPair.getValue(); + + assertThat(sources).contains( + new SourcesParser.Source("MainServiceTemplate.yaml", "", ""), + new SourcesParser.Source("Definitions/openonfv__tosca.capabilities.nfv.ext.LocalAttachment.yaml", "", ""), + new SourcesParser.Source("MRF.yaml", "SHA-256", "09e5a788acb180162c51679ae4c998039fa6644505db2415e35107d1ee213943"), + new SourcesParser.Source("scripts/install.sh", "SHA-256", "d0e7828293355a07c2dccaaa765c80b507e60e6167067c950dc2e6b0da0dbd8b"), + new SourcesParser.Source("https://www.vendor_org.com/MRF/v4.1/scripts/scale/scale.sh", "SHA-256", "36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165") + ); + assertThat(errors.size()).isEqualTo(0); + } + + @Test + public void shouldFetchCMS() { + + Pair> sourcesPair = vnfManifestParser.fetchCMS(); + String cms = sourcesPair.getKey(); + List errors = sourcesPair.getValue(); + + assertThat(cms).isEqualTo( + "MIGDBgsqhkiG9w0BCRABCaB0MHICAQAwDQYLKoZIhvcNAQkQAwgwXgYJKoZIhvcN" + + "AQcBoFEET3icc87PK0nNK9ENqSxItVIoSa0o0S/ISczMs1ZIzkgsKk4tsQ0N1nUM" + + "dvb05OXi5XLPLEtViMwvLVLwSE0sKlFIVHAqSk3MBkkBAJv0Fx0=" + ); + assertThat(errors.size()).isEqualTo(0); + } +} diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/IntegrationTestUtils.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/IntegrationTestUtils.java index bed3a90..a0bb25d 100644 --- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/IntegrationTestUtils.java +++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/IntegrationTestUtils.java @@ -28,6 +28,7 @@ import org.onap.cvc.csar.cc.VTPValidateCSARBase; import java.net.URISyntaxException; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -42,14 +43,23 @@ public class IntegrationTestUtils { .toURI().getPath(); } - static void configureTestCase(VTPValidateCSARBase testCase, String fileName) throws OnapCommandException, URISyntaxException { + static void configureTestCase(VTPValidateCSARBase testCase, String fileName, String schema, boolean isPnf) throws OnapCommandException, URISyntaxException { configureCommandAttributes(testCase); - testCase.initializeSchema("vtp-validate-csar-r146092.yaml"); + testCase.initializeSchema(schema); + + configureCommandParameters(testCase, isPnf); configurePathToCsar(testCase, fileName); } + private static void configureCommandParameters(VTPValidateCSARBase testCase, boolean isPnf) throws OnapCommandInvalidParameterValue { + Set parameters = testCase.getParameters(); + final Optional pnf = parameters.stream().filter(it -> it.getName().equals("pnf")).findFirst(); + if(pnf.isPresent()){ + pnf.get().setValue(isPnf); + } + } private static void configureCommandAttributes(VTPValidateCSARBase testCase) { OnapCommandResult onapCommandResult = new OnapCommandResult(); OnapCommandResultAttribute onapCommandResultAttributeCode = new OnapCommandResultAttribute(); @@ -68,8 +78,10 @@ public class IntegrationTestUtils { private static void configurePathToCsar(VTPValidateCSARBase testCase, String fileName) throws URISyntaxException, OnapCommandInvalidParameterValue { String pathToFile = absoluteFilePath(fileName); Set parameters = testCase.getParameters(); - OnapCommandParameter csar = parameters.stream().filter(op -> op.getName().equals("csar")).findFirst().get(); - csar.setValue(pathToFile); + Optional csar = parameters.stream().filter(op -> op.getName().equals("csar")).findFirst(); + if(csar.isPresent()) { + csar.get().setValue(pathToFile); + } } static List convertToMessagesList(List errors) { diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR10087IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR10087IntegrationTest.java index 7016a92..921e903 100644 --- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR10087IntegrationTest.java +++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR10087IntegrationTest.java @@ -30,6 +30,7 @@ import static org.onap.cvc.csar.cc.sol004.IntegrationTestUtils.convertToMessages public class VTPValidateCSARR10087IntegrationTest { + private static final boolean IS_PNF = true; private VTPValidateCSARR10087 testCase; @Before @@ -45,7 +46,7 @@ public class VTPValidateCSARR10087IntegrationTest { @Test public void shouldReportThatDefinitionYAMLIsNotAvailable() throws Exception { // given - configureTestCase(testCase, "pnf/noToscaMetaFile.csar"); + configureTestCase(testCase, "pnf/noToscaMetaFile.csar", "vtp-validate-csar-r10087.yaml", IS_PNF); // when testCase.execute(); @@ -64,7 +65,7 @@ public class VTPValidateCSARR10087IntegrationTest { @Test public void shouldReportThatDefinitionYAMLDoesNotExist() throws Exception { // given - configureTestCase(testCase, "pnf/r10087/invalidEntryDefinitionsInToscaMeta.csar"); + configureTestCase(testCase, "pnf/r10087/invalidEntryDefinitionsInToscaMeta.csar", "vtp-validate-csar-r10087.yaml", IS_PNF); // when testCase.execute(); @@ -81,7 +82,7 @@ public class VTPValidateCSARR10087IntegrationTest { @Test public void shouldReportThatManifestFileDoesNotExist() throws Exception { // given - configureTestCase(testCase, "pnf/r10087/invalidManifestFile.csar"); + configureTestCase(testCase, "pnf/r10087/invalidManifestFile.csar", "vtp-validate-csar-r10087.yaml", IS_PNF); // when testCase.execute(); @@ -98,7 +99,7 @@ public class VTPValidateCSARR10087IntegrationTest { @Test public void shouldReportThatChangeHistoryLogFileDoesNotExist() throws Exception { // given - configureTestCase(testCase, "pnf/r10087/invalidChangeHistoryLog.csar"); + configureTestCase(testCase, "pnf/r10087/invalidChangeHistoryLog.csar", "vtp-validate-csar-r10087.yaml", IS_PNF); // when testCase.execute(); @@ -114,7 +115,7 @@ public class VTPValidateCSARR10087IntegrationTest { @Test public void shouldReportThatTestDirectoryDoesNotExist() throws Exception { // given - configureTestCase(testCase, "pnf/r10087/invalidTestDirectory.csar"); + configureTestCase(testCase, "pnf/r10087/invalidTestDirectory.csar", "vtp-validate-csar-r10087.yaml", IS_PNF); // when testCase.execute(); diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092IntegrationTest.java index 0e0f35d..4e6daba 100644 --- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092IntegrationTest.java +++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092IntegrationTest.java @@ -30,6 +30,7 @@ import static org.onap.cvc.csar.cc.sol004.IntegrationTestUtils.convertToMessages public class VTPValidateCSARR146092IntegrationTest { + private static final boolean IS_PNF = true; private VTPValidateCSARR146092 testCase; @Before @@ -45,7 +46,7 @@ public class VTPValidateCSARR146092IntegrationTest { @Test public void shouldDoNotReportErrorWhenNonManoArtifactIsNotAvailable() throws Exception { // given - configureTestCase(testCase, "pnf/r146092/missingNonManoArtifactInManifest.csar"); + configureTestCase(testCase, "pnf/r146092/missingNonManoArtifactInManifest.csar", "vtp-validate-csar-r146092.yaml", IS_PNF); // when testCase.execute(); @@ -58,7 +59,7 @@ public class VTPValidateCSARR146092IntegrationTest { @Test public void shouldReportThatMandatoryNonManoArtifactSetEntryHasNotAllFields() throws Exception { // given - configureTestCase(testCase, "pnf/r146092/missingFieldsInNonManoArtifactManifest.csar"); + configureTestCase(testCase, "pnf/r146092/missingFieldsInNonManoArtifactManifest.csar", "vtp-validate-csar-r146092.yaml", IS_PNF); // when testCase.execute(); @@ -78,7 +79,7 @@ public class VTPValidateCSARR146092IntegrationTest { @Test public void shouldReportThatNonManoArtifactEntryHasAnySource() throws Exception { // given - configureTestCase(testCase, "pnf/r146092/noSourceElementInNonManoArtifactEntryManifest.csar"); + configureTestCase(testCase, "pnf/r146092/noSourceElementInNonManoArtifactEntryManifest.csar", "vtp-validate-csar-r146092.yaml", IS_PNF); // when testCase.execute(); @@ -95,7 +96,7 @@ public class VTPValidateCSARR146092IntegrationTest { @Test public void shouldReportThatNonManoArtifactEntryHasSourceWithUnknownFile() throws Exception { // given - configureTestCase(testCase, "pnf/r146092/sourceElementWithUnknownFileInNonManoArtifactEntryManifest.csar"); + configureTestCase(testCase, "pnf/r146092/sourceElementWithUnknownFileInNonManoArtifactEntryManifest.csar", "vtp-validate-csar-r146092.yaml", IS_PNF); // when testCase.execute(); @@ -111,7 +112,7 @@ public class VTPValidateCSARR146092IntegrationTest { @Test public void shouldReportThatDefinitionYAMLIsNotAvailableWhenToscaMetaFileIsNotPresent() throws Exception { // given - configureTestCase(testCase, "pnf/noToscaMetaFile.csar"); + configureTestCase(testCase, "pnf/noToscaMetaFile.csar", "vtp-validate-csar-r146092.yaml", IS_PNF); // when testCase.execute(); diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901IntegrationTest.java index cd1dc06..2835772 100644 --- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901IntegrationTest.java +++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901IntegrationTest.java @@ -30,6 +30,7 @@ import static org.onap.cvc.csar.cc.sol004.IntegrationTestUtils.convertToMessages public class VTPValidateCSARR293901IntegrationTest { + private static final boolean IS_PNF = true; private VTPValidateCSARR293901 testCase; @Before @@ -45,7 +46,7 @@ public class VTPValidateCSARR293901IntegrationTest { @Test public void shouldReportThatMandatoryEntriesAreNotAvailable() throws Exception { // given - configureTestCase(testCase, "pnf/r293901/noMandatoryEntriesInTOSCAMeta.csar"); + configureTestCase(testCase, "pnf/r293901/noMandatoryEntriesInTOSCAMeta.csar", "vtp-validate-csar-r293901.yaml", IS_PNF); // when testCase.execute(); @@ -63,7 +64,7 @@ public class VTPValidateCSARR293901IntegrationTest { @Test public void shouldDoNotReportAnyErrorWhenAllMandatoryEntriesWereDefined() throws Exception { // given - configureTestCase(testCase, "pnf/r293901/allMandatoryEntriesDefinedInTOSCAMeta.csar"); + configureTestCase(testCase, "pnf/r293901/allMandatoryEntriesDefinedInTOSCAMeta.csar", "vtp-validate-csar-r293901.yaml", IS_PNF); // when testCase.execute(); @@ -74,9 +75,9 @@ public class VTPValidateCSARR293901IntegrationTest { } @Test - public void shouldReportAnyErrorWhneThereIsNoTOSCAMetaFileInTOSCADirectory() throws Exception { + public void shouldReportAnyErrorWhenThereIsNoTOSCAMetaFileInTOSCADirectory() throws Exception { // given - configureTestCase(testCase, "pnf/r293901/noTOSCAMetaInTOSCADirectory.csar"); + configureTestCase(testCase, "pnf/r293901/noTOSCAMetaInTOSCADirectory.csar", "vtp-validate-csar-r293901.yaml", IS_PNF); // when testCase.execute(); diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019IntegrationTest.java index 2328f2c..088eab7 100644 --- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019IntegrationTest.java +++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019IntegrationTest.java @@ -30,6 +30,7 @@ import static org.onap.cvc.csar.cc.sol004.IntegrationTestUtils.convertToMessages public class VTPValidateCSARR57019IntegrationTest { + private static final boolean IS_PNF = true; private VTPValidateCSARR57019 testCase; @Before @@ -45,7 +46,7 @@ public class VTPValidateCSARR57019IntegrationTest { @Test public void shouldReportThatMandatoryEntriesInMetadataAreNotAvailable() throws Exception { // given - configureTestCase(testCase, "pnf/r57019/noMandatoryEntriesInMetadataManifest.csar"); + configureTestCase(testCase, "pnf/r57019/noMandatoryEntriesInMetadataManifest.csar", "vtp-validate-csar-r57019.yaml", IS_PNF); // when testCase.execute(); @@ -65,7 +66,7 @@ public class VTPValidateCSARR57019IntegrationTest { @Test public void shouldDoNotReportAnyErrorWhenAllMandatoryEntriesInMetadataWereDefined() throws Exception { // given - configureTestCase(testCase, "pnf/r57019/allMandatoryEntriesDefinedInMetadataManifest.csar"); + configureTestCase(testCase, "pnf/r57019/allMandatoryEntriesDefinedInMetadataManifest.csar", "vtp-validate-csar-r57019.yaml", IS_PNF); // when testCase.execute(); @@ -78,7 +79,7 @@ public class VTPValidateCSARR57019IntegrationTest { @Test public void shouldReportThatDefinitionYAMLIsNotAvailableWhenToscaMetaFileIsNotPresent() throws Exception { // given - configureTestCase(testCase, "pnf/noToscaMetaFile.csar"); + configureTestCase(testCase, "pnf/noToscaMetaFile.csar", "vtp-validate-csar-r57019.yaml", IS_PNF); // when testCase.execute(); diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965IntegrationTest.java index ffbf87e..eb41d6a 100644 --- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965IntegrationTest.java +++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965IntegrationTest.java @@ -30,6 +30,7 @@ import static org.onap.cvc.csar.cc.sol004.IntegrationTestUtils.convertToMessages public class VTPValidateCSARR787965IntegrationTest { + private static final boolean IS_PNF = true; private VTPValidateCSARR787965 testCase; @Before @@ -46,7 +47,7 @@ public class VTPValidateCSARR787965IntegrationTest { public void shouldReportThatCsarHasInvalidSignature() throws Exception { // given - configureTestCase(testCase, "pnf/signed-package-invalid-signature.zip"); + configureTestCase(testCase, "pnf/signed-package-invalid-signature.zip", "vtp-validate-csar-r787965.yaml", IS_PNF); // when testCase.execute(); @@ -63,7 +64,7 @@ public class VTPValidateCSARR787965IntegrationTest { public void shouldReportThatZipContainsSignatureWithCertificationFileAndPackageIsProbableValid() throws Exception { // given - configureTestCase(testCase, "pnf/r787965/signature-and-certificate.zip"); + configureTestCase(testCase, "pnf/r787965/signature-and-certificate.zip", "vtp-validate-csar-r787965.yaml", IS_PNF); // when testCase.execute(); @@ -82,7 +83,7 @@ public class VTPValidateCSARR787965IntegrationTest { public void shouldReportThatZipPackageIsBroken() throws Exception { // given - configureTestCase(testCase, "pnf/r787965/broken.zip"); + configureTestCase(testCase, "pnf/r787965/broken.zip", "vtp-validate-csar-r787965.yaml", IS_PNF); // when testCase.execute(); @@ -99,7 +100,7 @@ public class VTPValidateCSARR787965IntegrationTest { public void shouldDoNotReportAnyErrorWhenPackageHasValidSignature() throws Exception { // given - configureTestCase(testCase, "pnf/signed-package-valid-signature.zip"); + configureTestCase(testCase, "pnf/signed-package-valid-signature.zip", "vtp-validate-csar-r787965.yaml", IS_PNF); // when testCase.execute(); diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787966IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787966IntegrationTest.java index eccfe4b..d48869a 100644 --- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787966IntegrationTest.java +++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787966IntegrationTest.java @@ -30,6 +30,7 @@ import static org.onap.cvc.csar.cc.sol004.IntegrationTestUtils.convertToMessages public class VTPValidateCSARR787966IntegrationTest { + private static final boolean IS_PNF = true; private VTPValidateCSARR787966 testCase; @Before @@ -46,7 +47,7 @@ public class VTPValidateCSARR787966IntegrationTest { public void shouldValidateProperCsar() throws Exception { // given - configureTestCase(testCase, "pnf/r787966/csar-option1-valid.csar"); + configureTestCase(testCase, "pnf/r787966/csar-option1-valid.csar", "vtp-validate-csar-r787966.yaml", IS_PNF); // when testCase.execute(); @@ -60,20 +61,40 @@ public class VTPValidateCSARR787966IntegrationTest { public void shouldReportErrorsForInvalidCsar() throws Exception { // given - configureTestCase(testCase, "pnf/r787966/csar-option1-invalid.csar"); + configureTestCase(testCase, "pnf/r787966/csar-option1-invalid.csar", "vtp-validate-csar-r787966.yaml", IS_PNF); // when testCase.execute(); // then List errors = testCase.getErrors(); - assertThat(errors.size()).isEqualTo(3); + assertThat(errors.size()).isEqualTo(4); assertThat(convertToMessagesList(errors)).contains( "Unable to find CMS section in manifest!", "Source 'Definitions/MainServiceTemplate.yaml' has wrong hash!", - "Source 'Artifacts/Other/my_script.csh' has hash, but unable to find algorithm tag!" + "Source 'Artifacts/Other/my_script.csh' has hash, but unable to find algorithm tag!", + "Source 'Artifacts/NonExisting.txt' does not exist!" ); } + @Test + public void shouldReportThanInVnfPackageCertFileWasNotDefined() throws Exception { + + // given + configureTestCase(testCase, "sample2.csar", "vtp-validate-csar-r787966.yaml", false); + + // when + testCase.execute(); + + // then + List errors = testCase.getErrors(); + assertThat(convertToMessagesList(errors)).contains( + "Unable to find cert file defined by Entry-Certificate!", + "Missing. Entry [tosca_definitions_version]" + ); + } + + + } \ No newline at end of file diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR87234IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR87234IntegrationTest.java index 55ec14c..56b86b7 100644 --- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR87234IntegrationTest.java +++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR87234IntegrationTest.java @@ -30,6 +30,7 @@ import static org.onap.cvc.csar.cc.sol004.IntegrationTestUtils.convertToMessages public class VTPValidateCSARR87234IntegrationTest { + private static final boolean IS_PNF = true; private VTPValidateCSARR87234 testCase; @Before @@ -46,7 +47,7 @@ public class VTPValidateCSARR87234IntegrationTest { @Test public void shouldReportThatToscaMetadataDirectoryIsNotPresent() throws Exception { // given - configureTestCase(testCase, "pnf/noToscaMetaFile.csar"); + configureTestCase(testCase, "pnf/noToscaMetaFile.csar", "vtp-validate-csar-r87234.yaml", IS_PNF); // when testCase.execute(); -- cgit 1.2.3-korg