From 692a2d6c41f76c3d43e640af9c24269c5ac7f8f2 Mon Sep 17 00:00:00 2001 From: Bogumil Zebek Date: Thu, 13 Jun 2019 14:50:32 +0200 Subject: Non_mano_artifact Change-Id: I0a47aac7935f12e406998fcdc3ae1eba6c5a2adc Issue-ID: VNFSDK-418 Signed-off-by: Zebek Bogumil --- .../cvc/csar/cc/sol004/VTPValidateCSARR146092.java | 29 +++++++++++---------- .../java/org/onap/cvc/csar/PnfCSARArchiveTest.java | 10 ++++--- .../VTPValidateCSARR146092IntegrationTest.java | 6 ++--- csarvalidation/src/test/resources/pnf/README.txt | 6 +++++ .../src/test/resources/pnf/dummyPnfv2.csar | Bin 4037 -> 4038 bytes .../src/test/resources/pnf/noToscaMetaFile.csar | Bin 3621 -> 3622 bytes .../pnf/r10087/invalidChangeHistoryLog.csar | Bin 4110 -> 4111 bytes .../r10087/invalidEntryDefinitionsInToscaMeta.csar | Bin 4111 -> 4112 bytes .../resources/pnf/r10087/invalidManifestFile.csar | Bin 4117 -> 4118 bytes .../resources/pnf/r10087/invalidTestDirectory.csar | Bin 4110 -> 4111 bytes .../missingFieldsInNonManoArtifactManifest.csar | Bin 3965 -> 3964 bytes .../r146092/missingNonManoArtifactInManifest.csar | Bin 3950 -> 3949 bytes ...ourceElementInNonManoArtifactEntryManifest.csar | Bin 4078 -> 4076 bytes ...hUnknownFileInNonManoArtifactEntryManifest.csar | Bin 4086 -> 4086 bytes .../allMandatoryEntriesDefinedInTOSCAMeta.csar | Bin 4117 -> 4116 bytes .../pnf/r293901/noMandatoryEntriesInTOSCAMeta.csar | Bin 3943 -> 3942 bytes ...lMandatoryEntriesDefinedInMetadataManifest.csar | Bin 4099 -> 4100 bytes .../noMandatoryEntriesInMetadataManifest.csar | Bin 4039 -> 4040 bytes .../pnf/signed-package-valid-signature.zip | Bin 3777 -> 23227 bytes 19 files changed, 30 insertions(+), 21 deletions(-) create mode 100644 csarvalidation/src/test/resources/pnf/README.txt (limited to 'csarvalidation/src') diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java index 6150a04..b84dea7 100644 --- a/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java +++ b/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092.java @@ -31,13 +31,12 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; @OnapCommandSchema(schema = "vtp-validate-csar-r146092.yaml") public class VTPValidateCSARR146092 extends VTPValidateCSARBase { private static final int UNKNOWN_LINE_NUMBER = -1; - private static final String SOURCE_ELEMENT_TAG = "source"; + private static final String SOURCE_ELEMENT_TAG = "Source"; private static class MissingSourceElementUnderAttributeError extends PnfCSARError { private MissingSourceElementUnderAttributeError(String attributeName, String fileName) { @@ -96,7 +95,7 @@ public class VTPValidateCSARR146092 extends VTPValidateCSARBase { List attributeNames = Arrays.asList( "onap_ves_events", "onap_pm_dictionary", - "onap_yang_module", + "onap_yang_modules", "onap_others" ); @@ -123,21 +122,23 @@ public class VTPValidateCSARR146092 extends VTPValidateCSARBase { private void validateSourceElementsUnderAttribute(String attributeName) { Map> attributeElements = this.nonMano.get(attributeName); - List attributeElementNames = attributeElements.keySet().stream() - .map(String::toLowerCase) - .collect(Collectors.toList()); + Set attributeElementNames = attributeElements.keySet(); if (!attributeElementNames.contains(SOURCE_ELEMENT_TAG)) { this.errors.add(new MissingSourceElementUnderAttributeError(attributeName, this.fileName)); } else { - for (String pathToFile : attributeElements.get(SOURCE_ELEMENT_TAG)) { - File fileFromCsar = this.csar.getFileFromCsar(pathToFile); - if (!fileFromCsar.exists()) { - this.errors.add( - new InvalidPathToFileError(attributeName, - pathToFile, this.fileName) - ); - } + validateThatSourceFileExists(attributeName, attributeElements); + } + } + + private void validateThatSourceFileExists(String attributeName, Map> attributeElements) { + for (String pathToFile : attributeElements.get(SOURCE_ELEMENT_TAG)) { + File fileFromCsar = this.csar.getFileFromCsar(pathToFile); + if (!fileFromCsar.exists()) { + this.errors.add( + new InvalidPathToFileError(attributeName, + pathToFile, this.fileName) + ); } } } 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 ca85c7a..810ef0f 100644 --- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java +++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java @@ -26,6 +26,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class PnfCSARArchiveTest { + public static final String SOURCE_TAG = "Source"; + @Test public void shouldUseDataStoredInManifestMfFileToConfigurePnfCSARArchive() throws Exception { // given @@ -61,16 +63,16 @@ public class PnfCSARArchiveTest { private void verifyThatNonManoArtifactsWereSet(PnfCSARArchive.PnfManifest manifest) { Map>> nonManoArtifacts = manifest.getNonMano(); - assertThat(nonManoArtifacts.get("onap_ves_events").get("source")) + assertThat(nonManoArtifacts.get("onap_ves_events").get(SOURCE_TAG)) .isEqualTo(Lists.newArrayList("Artifacts/Events/VES_registration.yml") ); - assertThat(nonManoArtifacts.get("onap_pm_dictionary").get("source")) + assertThat(nonManoArtifacts.get("onap_pm_dictionary").get(SOURCE_TAG)) .isEqualTo(Lists.newArrayList("Artifacts/Measurements/PM_Dictionary.yaml") ); - assertThat(nonManoArtifacts.get("onap_yang_module").get("source")) + assertThat(nonManoArtifacts.get("onap_yang_modules").get(SOURCE_TAG)) .isEqualTo(Lists.newArrayList("Artifacts/Yang_module/Yang_module.yaml") ); - assertThat(nonManoArtifacts.get("onap_others").get("source")) + assertThat(nonManoArtifacts.get("onap_others").get(SOURCE_TAG)) .isEqualTo(Lists.newArrayList( "Artifacts/scripts/install.sh", "Artifacts/Informational/user_guide.txt", 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 ba51882..0e0f35d 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 @@ -69,7 +69,7 @@ public class VTPValidateCSARR146092IntegrationTest { assertThat(convertToMessagesList(errors)).contains( "Missing. Entry [onap_ves_events]", "Missing. Entry [onap_pm_dictionary]", - "Missing. Entry [onap_yang_module]", + "Missing. Entry [onap_yang_modules]", "Missing. Entry [onap_others]" ); } @@ -87,7 +87,7 @@ public class VTPValidateCSARR146092IntegrationTest { List 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 +104,7 @@ public class VTPValidateCSARR146092IntegrationTest { List 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]" ); } diff --git a/csarvalidation/src/test/resources/pnf/README.txt b/csarvalidation/src/test/resources/pnf/README.txt new file mode 100644 index 0000000..8984d6f --- /dev/null +++ b/csarvalidation/src/test/resources/pnf/README.txt @@ -0,0 +1,6 @@ +How to sign CSAR file +--------------------- +openssl req -new -nodes -x509 -keyout root-private-key.pem > root.cert +openssl req -new -nodes -keyout sample-pnf-private-key.pem > sample-pnf-request.pem +openssl x509 -req -CA root.cert -CAkey root-private-key.pem -CAcreateserial < sample-pnf-request.pem > sample-pnf.cert +openssl cms -sign -binary -nocerts -outform pem -signer sample-pnf.cert -inkey sample-pnf-private-key.pem < sample-pnf.csar > sample-pnf.cms \ No newline at end of file diff --git a/csarvalidation/src/test/resources/pnf/dummyPnfv2.csar b/csarvalidation/src/test/resources/pnf/dummyPnfv2.csar index dd45b66..bf2d912 100644 Binary files a/csarvalidation/src/test/resources/pnf/dummyPnfv2.csar and b/csarvalidation/src/test/resources/pnf/dummyPnfv2.csar differ diff --git a/csarvalidation/src/test/resources/pnf/noToscaMetaFile.csar b/csarvalidation/src/test/resources/pnf/noToscaMetaFile.csar index 331da92..f01cf20 100644 Binary files a/csarvalidation/src/test/resources/pnf/noToscaMetaFile.csar and b/csarvalidation/src/test/resources/pnf/noToscaMetaFile.csar differ diff --git a/csarvalidation/src/test/resources/pnf/r10087/invalidChangeHistoryLog.csar b/csarvalidation/src/test/resources/pnf/r10087/invalidChangeHistoryLog.csar index 56b145f..f1b8ab5 100644 Binary files a/csarvalidation/src/test/resources/pnf/r10087/invalidChangeHistoryLog.csar and b/csarvalidation/src/test/resources/pnf/r10087/invalidChangeHistoryLog.csar differ diff --git a/csarvalidation/src/test/resources/pnf/r10087/invalidEntryDefinitionsInToscaMeta.csar b/csarvalidation/src/test/resources/pnf/r10087/invalidEntryDefinitionsInToscaMeta.csar index d07dcbf..beb73d8 100644 Binary files a/csarvalidation/src/test/resources/pnf/r10087/invalidEntryDefinitionsInToscaMeta.csar and b/csarvalidation/src/test/resources/pnf/r10087/invalidEntryDefinitionsInToscaMeta.csar differ diff --git a/csarvalidation/src/test/resources/pnf/r10087/invalidManifestFile.csar b/csarvalidation/src/test/resources/pnf/r10087/invalidManifestFile.csar index 83a37cb..96f3916 100644 Binary files a/csarvalidation/src/test/resources/pnf/r10087/invalidManifestFile.csar and b/csarvalidation/src/test/resources/pnf/r10087/invalidManifestFile.csar differ diff --git a/csarvalidation/src/test/resources/pnf/r10087/invalidTestDirectory.csar b/csarvalidation/src/test/resources/pnf/r10087/invalidTestDirectory.csar index b31d8cf..65fb622 100644 Binary files a/csarvalidation/src/test/resources/pnf/r10087/invalidTestDirectory.csar and b/csarvalidation/src/test/resources/pnf/r10087/invalidTestDirectory.csar differ diff --git a/csarvalidation/src/test/resources/pnf/r146092/missingFieldsInNonManoArtifactManifest.csar b/csarvalidation/src/test/resources/pnf/r146092/missingFieldsInNonManoArtifactManifest.csar index 545dd16..5f48c14 100644 Binary files a/csarvalidation/src/test/resources/pnf/r146092/missingFieldsInNonManoArtifactManifest.csar and b/csarvalidation/src/test/resources/pnf/r146092/missingFieldsInNonManoArtifactManifest.csar differ diff --git a/csarvalidation/src/test/resources/pnf/r146092/missingNonManoArtifactInManifest.csar b/csarvalidation/src/test/resources/pnf/r146092/missingNonManoArtifactInManifest.csar index 0bb0e16..f1a5055 100644 Binary files a/csarvalidation/src/test/resources/pnf/r146092/missingNonManoArtifactInManifest.csar and b/csarvalidation/src/test/resources/pnf/r146092/missingNonManoArtifactInManifest.csar differ diff --git a/csarvalidation/src/test/resources/pnf/r146092/noSourceElementInNonManoArtifactEntryManifest.csar b/csarvalidation/src/test/resources/pnf/r146092/noSourceElementInNonManoArtifactEntryManifest.csar index edeaf9b..78360dc 100644 Binary files a/csarvalidation/src/test/resources/pnf/r146092/noSourceElementInNonManoArtifactEntryManifest.csar and b/csarvalidation/src/test/resources/pnf/r146092/noSourceElementInNonManoArtifactEntryManifest.csar differ diff --git a/csarvalidation/src/test/resources/pnf/r146092/sourceElementWithUnknownFileInNonManoArtifactEntryManifest.csar b/csarvalidation/src/test/resources/pnf/r146092/sourceElementWithUnknownFileInNonManoArtifactEntryManifest.csar index 434d614..d4c7993 100644 Binary files a/csarvalidation/src/test/resources/pnf/r146092/sourceElementWithUnknownFileInNonManoArtifactEntryManifest.csar and b/csarvalidation/src/test/resources/pnf/r146092/sourceElementWithUnknownFileInNonManoArtifactEntryManifest.csar differ diff --git a/csarvalidation/src/test/resources/pnf/r293901/allMandatoryEntriesDefinedInTOSCAMeta.csar b/csarvalidation/src/test/resources/pnf/r293901/allMandatoryEntriesDefinedInTOSCAMeta.csar index f22366a..1dd4dfd 100644 Binary files a/csarvalidation/src/test/resources/pnf/r293901/allMandatoryEntriesDefinedInTOSCAMeta.csar and b/csarvalidation/src/test/resources/pnf/r293901/allMandatoryEntriesDefinedInTOSCAMeta.csar differ diff --git a/csarvalidation/src/test/resources/pnf/r293901/noMandatoryEntriesInTOSCAMeta.csar b/csarvalidation/src/test/resources/pnf/r293901/noMandatoryEntriesInTOSCAMeta.csar index 9ef56cf..70a1939 100644 Binary files a/csarvalidation/src/test/resources/pnf/r293901/noMandatoryEntriesInTOSCAMeta.csar and b/csarvalidation/src/test/resources/pnf/r293901/noMandatoryEntriesInTOSCAMeta.csar differ diff --git a/csarvalidation/src/test/resources/pnf/r57019/allMandatoryEntriesDefinedInMetadataManifest.csar b/csarvalidation/src/test/resources/pnf/r57019/allMandatoryEntriesDefinedInMetadataManifest.csar index 3311713..b23a689 100644 Binary files a/csarvalidation/src/test/resources/pnf/r57019/allMandatoryEntriesDefinedInMetadataManifest.csar and b/csarvalidation/src/test/resources/pnf/r57019/allMandatoryEntriesDefinedInMetadataManifest.csar differ diff --git a/csarvalidation/src/test/resources/pnf/r57019/noMandatoryEntriesInMetadataManifest.csar b/csarvalidation/src/test/resources/pnf/r57019/noMandatoryEntriesInMetadataManifest.csar index 6b16ed5..570693d 100644 Binary files a/csarvalidation/src/test/resources/pnf/r57019/noMandatoryEntriesInMetadataManifest.csar and b/csarvalidation/src/test/resources/pnf/r57019/noMandatoryEntriesInMetadataManifest.csar differ diff --git a/csarvalidation/src/test/resources/pnf/signed-package-valid-signature.zip b/csarvalidation/src/test/resources/pnf/signed-package-valid-signature.zip index 15437d6..b946585 100644 Binary files a/csarvalidation/src/test/resources/pnf/signed-package-valid-signature.zip and b/csarvalidation/src/test/resources/pnf/signed-package-valid-signature.zip differ -- cgit 1.2.3-korg