diff options
author | edyta <edyta.krukowska@nokia.com> | 2020-05-12 17:24:28 +0200 |
---|---|---|
committer | edyta <edyta.krukowska@nokia.com> | 2020-05-13 08:14:40 +0200 |
commit | 09b19ef7c96df88d8b9de9e5e803643f8fb47201 (patch) | |
tree | ef86bfff91957fd1b217efab1fcd3c26f1907a93 /csarvalidation/src | |
parent | 8913e624e48ea3ca7a938e03dc0dc8a5d9dbd6cc (diff) |
Fix package integrity issue with non mano arifacts
Issue-ID: VNFSDK-581
Signed-off-by: Edyta Krukowska <edyta.krukowska@nokia.com>
Change-Id: Ia07e5ed9b188a689381e95485dd8f32d13b77258
Diffstat (limited to 'csarvalidation/src')
4 files changed, 33 insertions, 12 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/parser/ManifestLine.java b/csarvalidation/src/main/java/org/onap/cvc/csar/parser/ManifestLine.java index 390c534..eefc771 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/parser/ManifestLine.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/parser/ManifestLine.java @@ -54,4 +54,8 @@ public class ManifestLine { return line.trim().isEmpty(); } + boolean contains(String word) { + return line.contains(word); + } + } diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/parser/NonManoArtifactsParser.java b/csarvalidation/src/main/java/org/onap/cvc/csar/parser/NonManoArtifactsParser.java index d27ef68..22e8978 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/parser/NonManoArtifactsParser.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/parser/NonManoArtifactsParser.java @@ -26,10 +26,12 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import static org.onap.cvc.csar.parser.ManifestConsts.BEGIN_CMS_SECTION; import static org.onap.cvc.csar.parser.ManifestConsts.NON_MANO_ARTIFACT_SETS_TAG_SECTION; public class NonManoArtifactsParser { + public Optional<Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>>> parse(List<String> lines) { Map<String, Map<String, List<String>>> nonManoArtifacts = new HashMap<>(); List<CSARArchive.CSARError> errors = new ArrayList<>(); @@ -41,6 +43,8 @@ public class NonManoArtifactsParser { ManifestLine manifestLine = ManifestLine.of(line); if (manifestLine.startsWith(NON_MANO_ARTIFACT_SETS_TAG_SECTION)) { isNonManoArtifactsSectionAvailable = true; + } else if (manifestLine.contains(BEGIN_CMS_SECTION)) { + break; } else if (isNonManoArtifactsSectionAvailable) { Pair<String, String> data = manifestLine.parse(); 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 bf9b094..d2a7b8a 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 @@ -19,10 +19,9 @@ package org.onap.cvc.csar.cc.sol004; import org.junit.Before; import org.junit.Test; -import org.onap.cvc.csar.CSARArchive; +import org.onap.cvc.csar.CSARArchive.CSARError; import java.util.List; -import org.onap.cvc.csar.CSARArchive.CSARError; import static org.assertj.core.api.Assertions.assertThat; import static org.onap.cvc.csar.cc.sol004.IntegrationTestUtils.configureTestCase; @@ -45,10 +44,24 @@ public class VTPValidateCSARR146092IntegrationTest { } @Test - public void shouldDoNotReportErrorWhenNonManoArtifactIsNotAvailable() throws Exception { + public void shouldNotReportErrorWhenCSARValid() throws Exception { + //given + configureTestCase(testCase, "pnf/r146092/validFile.csar", + "vtp-validate-csar-r146092.yaml", IS_PNF); + + // when + testCase.execute(); + + // then + final List<CSARError> errors = testCase.getErrors(); + assertThat(errors.size()).isEqualTo(0); + } + + @Test + public void shouldNotReportErrorWhenNonManoArtifactIsNotAvailable() throws Exception { // given configureTestCase(testCase, "pnf/r146092/missingNonManoArtifactInManifest.csar", - "vtp-validate-csar-r146092.yaml", IS_PNF); + "vtp-validate-csar-r146092.yaml", IS_PNF); // when testCase.execute(); @@ -62,7 +75,7 @@ public class VTPValidateCSARR146092IntegrationTest { public void shouldReportThatMandatoryNonManoArtifactSetEntryHasNotAllFields() throws Exception { // given configureTestCase(testCase, "pnf/r146092/missingFieldsInNonManoArtifactManifest.csar", - "vtp-validate-csar-r146092.yaml", IS_PNF); + "vtp-validate-csar-r146092.yaml", IS_PNF); // when testCase.execute(); @@ -71,7 +84,7 @@ public class VTPValidateCSARR146092IntegrationTest { final List<CSARError> errors = testCase.getErrors(); assertThat(errors.size()).isEqualTo(1); assertThat(convertToMessagesList(errors)).contains( - "Missing. Entry [[onap_ansible_playbooks, onap_others, onap_pm_dictionary, onap_pnf_sw_information, onap_scripts, onap_ves_events, onap_yang_modules]]" + "Missing. Entry [[onap_ansible_playbooks, onap_others, onap_pm_dictionary, onap_pnf_sw_information, onap_scripts, onap_ves_events, onap_yang_modules]]" ); } @@ -79,7 +92,7 @@ public class VTPValidateCSARR146092IntegrationTest { public void shouldReportThatNonManoArtifactEntryHasAnySource() throws Exception { // given configureTestCase(testCase, "pnf/r146092/noSourceElementInNonManoArtifactEntryManifest.csar", - "vtp-validate-csar-r146092.yaml", IS_PNF); + "vtp-validate-csar-r146092.yaml", IS_PNF); // when testCase.execute(); @@ -88,7 +101,7 @@ public class VTPValidateCSARR146092IntegrationTest { final List<CSARError> errors = testCase.getErrors(); assertThat(errors.size()).isEqualTo(1); assertThat(convertToMessagesList(errors)).contains( - "Missing. Entry [Source under onap_ves_events]" + "Missing. Entry [Source under onap_ves_events]" ); } @@ -104,7 +117,7 @@ public class VTPValidateCSARR146092IntegrationTest { final List<CSARError> errors = testCase.getErrors(); assertThat(errors.size()).isEqualTo(1); assertThat(convertToMessagesList(errors)).contains( - "Invalid. Entry [Source under onap_ves_events has invalid 'Artifacts/Deployment/Events/RadioNode.yml' path]" + "Invalid. Entry [Source under onap_ves_events has invalid 'Artifacts/Deployment/Events/RadioNode.yml' path]" ); } @@ -120,7 +133,7 @@ public class VTPValidateCSARR146092IntegrationTest { final List<CSARError> errors = testCase.getErrors(); assertThat(errors.size()).isEqualTo(4); assertThat(convertToMessagesList(errors)).contains( - "Missing. Entry [Definition YAML]" + "Missing. Entry [Definition YAML]" ); } @@ -128,7 +141,7 @@ public class VTPValidateCSARR146092IntegrationTest { public void shouldReportThatEntryHasInvalidPathWhenYamlFileIsNotPresent() throws Exception { // given configureTestCase(testCase, "pnf/r146092/missingYamlFileReferedInSourceSessionOfManifest.csar", "vtp-validate-csar-r146092.yaml", - IS_PNF); + IS_PNF); // when testCase.execute(); @@ -137,7 +150,7 @@ public class VTPValidateCSARR146092IntegrationTest { final List<CSARError> errors = testCase.getErrors(); assertThat(errors.size()).isEqualTo(1); assertThat(convertToMessagesList(errors)).contains( - "Invalid. Entry [Source under onap_pnf_sw_information has invalid 'Files/pnf-sw-information/pnf-sw-information.yaml' path]" + "Invalid. Entry [Source under onap_pnf_sw_information has invalid 'Files/pnf-sw-information/pnf-sw-information.yaml' path]" ); } diff --git a/csarvalidation/src/test/resources/pnf/r146092/validFile.csar b/csarvalidation/src/test/resources/pnf/r146092/validFile.csar Binary files differnew file mode 100644 index 0000000..e805765 --- /dev/null +++ b/csarvalidation/src/test/resources/pnf/r146092/validFile.csar |