diff options
author | Gao Weitao <victor.gao@huawei.com> | 2019-07-03 06:15:53 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-07-03 06:15:53 +0000 |
commit | d0c919b17b851d54f0588e18bad071643f95e4e8 (patch) | |
tree | 27bbfdf76b657aeed6e7be161f7e6a6d479f0245 /csarvalidation/src | |
parent | 98d90539d4cbbb9482012ce540fdec3b22c0fc45 (diff) | |
parent | 692a2d6c41f76c3d43e640af9c24269c5ac7f8f2 (diff) |
Merge "Non_mano_artifact"
Diffstat (limited to 'csarvalidation/src')
19 files changed, 30 insertions, 21 deletions
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<String> 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<String, List<String>> attributeElements = this.nonMano.get(attributeName); - List<String> attributeElementNames = attributeElements.keySet().stream() - .map(String::toLowerCase) - .collect(Collectors.toList()); + Set<String> 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<String, List<String>> 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<String, Map<String, List<String>>> 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<CSARArchive.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 +104,7 @@ public class VTPValidateCSARR146092IntegrationTest { List<CSARArchive.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]" ); } 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 Binary files differindex dd45b66..bf2d912 100644 --- a/csarvalidation/src/test/resources/pnf/dummyPnfv2.csar +++ b/csarvalidation/src/test/resources/pnf/dummyPnfv2.csar diff --git a/csarvalidation/src/test/resources/pnf/noToscaMetaFile.csar b/csarvalidation/src/test/resources/pnf/noToscaMetaFile.csar Binary files differindex 331da92..f01cf20 100644 --- a/csarvalidation/src/test/resources/pnf/noToscaMetaFile.csar +++ b/csarvalidation/src/test/resources/pnf/noToscaMetaFile.csar diff --git a/csarvalidation/src/test/resources/pnf/r10087/invalidChangeHistoryLog.csar b/csarvalidation/src/test/resources/pnf/r10087/invalidChangeHistoryLog.csar Binary files differindex 56b145f..f1b8ab5 100644 --- a/csarvalidation/src/test/resources/pnf/r10087/invalidChangeHistoryLog.csar +++ b/csarvalidation/src/test/resources/pnf/r10087/invalidChangeHistoryLog.csar diff --git a/csarvalidation/src/test/resources/pnf/r10087/invalidEntryDefinitionsInToscaMeta.csar b/csarvalidation/src/test/resources/pnf/r10087/invalidEntryDefinitionsInToscaMeta.csar Binary files differindex d07dcbf..beb73d8 100644 --- a/csarvalidation/src/test/resources/pnf/r10087/invalidEntryDefinitionsInToscaMeta.csar +++ b/csarvalidation/src/test/resources/pnf/r10087/invalidEntryDefinitionsInToscaMeta.csar diff --git a/csarvalidation/src/test/resources/pnf/r10087/invalidManifestFile.csar b/csarvalidation/src/test/resources/pnf/r10087/invalidManifestFile.csar Binary files differindex 83a37cb..96f3916 100644 --- a/csarvalidation/src/test/resources/pnf/r10087/invalidManifestFile.csar +++ b/csarvalidation/src/test/resources/pnf/r10087/invalidManifestFile.csar diff --git a/csarvalidation/src/test/resources/pnf/r10087/invalidTestDirectory.csar b/csarvalidation/src/test/resources/pnf/r10087/invalidTestDirectory.csar Binary files differindex b31d8cf..65fb622 100644 --- a/csarvalidation/src/test/resources/pnf/r10087/invalidTestDirectory.csar +++ b/csarvalidation/src/test/resources/pnf/r10087/invalidTestDirectory.csar diff --git a/csarvalidation/src/test/resources/pnf/r146092/missingFieldsInNonManoArtifactManifest.csar b/csarvalidation/src/test/resources/pnf/r146092/missingFieldsInNonManoArtifactManifest.csar Binary files differindex 545dd16..5f48c14 100644 --- a/csarvalidation/src/test/resources/pnf/r146092/missingFieldsInNonManoArtifactManifest.csar +++ b/csarvalidation/src/test/resources/pnf/r146092/missingFieldsInNonManoArtifactManifest.csar diff --git a/csarvalidation/src/test/resources/pnf/r146092/missingNonManoArtifactInManifest.csar b/csarvalidation/src/test/resources/pnf/r146092/missingNonManoArtifactInManifest.csar Binary files differindex 0bb0e16..f1a5055 100644 --- a/csarvalidation/src/test/resources/pnf/r146092/missingNonManoArtifactInManifest.csar +++ b/csarvalidation/src/test/resources/pnf/r146092/missingNonManoArtifactInManifest.csar diff --git a/csarvalidation/src/test/resources/pnf/r146092/noSourceElementInNonManoArtifactEntryManifest.csar b/csarvalidation/src/test/resources/pnf/r146092/noSourceElementInNonManoArtifactEntryManifest.csar Binary files differindex edeaf9b..78360dc 100644 --- a/csarvalidation/src/test/resources/pnf/r146092/noSourceElementInNonManoArtifactEntryManifest.csar +++ b/csarvalidation/src/test/resources/pnf/r146092/noSourceElementInNonManoArtifactEntryManifest.csar diff --git a/csarvalidation/src/test/resources/pnf/r146092/sourceElementWithUnknownFileInNonManoArtifactEntryManifest.csar b/csarvalidation/src/test/resources/pnf/r146092/sourceElementWithUnknownFileInNonManoArtifactEntryManifest.csar Binary files differindex 434d614..d4c7993 100644 --- a/csarvalidation/src/test/resources/pnf/r146092/sourceElementWithUnknownFileInNonManoArtifactEntryManifest.csar +++ b/csarvalidation/src/test/resources/pnf/r146092/sourceElementWithUnknownFileInNonManoArtifactEntryManifest.csar diff --git a/csarvalidation/src/test/resources/pnf/r293901/allMandatoryEntriesDefinedInTOSCAMeta.csar b/csarvalidation/src/test/resources/pnf/r293901/allMandatoryEntriesDefinedInTOSCAMeta.csar Binary files differindex f22366a..1dd4dfd 100644 --- a/csarvalidation/src/test/resources/pnf/r293901/allMandatoryEntriesDefinedInTOSCAMeta.csar +++ b/csarvalidation/src/test/resources/pnf/r293901/allMandatoryEntriesDefinedInTOSCAMeta.csar diff --git a/csarvalidation/src/test/resources/pnf/r293901/noMandatoryEntriesInTOSCAMeta.csar b/csarvalidation/src/test/resources/pnf/r293901/noMandatoryEntriesInTOSCAMeta.csar Binary files differindex 9ef56cf..70a1939 100644 --- a/csarvalidation/src/test/resources/pnf/r293901/noMandatoryEntriesInTOSCAMeta.csar +++ b/csarvalidation/src/test/resources/pnf/r293901/noMandatoryEntriesInTOSCAMeta.csar diff --git a/csarvalidation/src/test/resources/pnf/r57019/allMandatoryEntriesDefinedInMetadataManifest.csar b/csarvalidation/src/test/resources/pnf/r57019/allMandatoryEntriesDefinedInMetadataManifest.csar Binary files differindex 3311713..b23a689 100644 --- a/csarvalidation/src/test/resources/pnf/r57019/allMandatoryEntriesDefinedInMetadataManifest.csar +++ b/csarvalidation/src/test/resources/pnf/r57019/allMandatoryEntriesDefinedInMetadataManifest.csar diff --git a/csarvalidation/src/test/resources/pnf/r57019/noMandatoryEntriesInMetadataManifest.csar b/csarvalidation/src/test/resources/pnf/r57019/noMandatoryEntriesInMetadataManifest.csar Binary files differindex 6b16ed5..570693d 100644 --- a/csarvalidation/src/test/resources/pnf/r57019/noMandatoryEntriesInMetadataManifest.csar +++ b/csarvalidation/src/test/resources/pnf/r57019/noMandatoryEntriesInMetadataManifest.csar diff --git a/csarvalidation/src/test/resources/pnf/signed-package-valid-signature.zip b/csarvalidation/src/test/resources/pnf/signed-package-valid-signature.zip Binary files differindex 15437d6..b946585 100644 --- a/csarvalidation/src/test/resources/pnf/signed-package-valid-signature.zip +++ b/csarvalidation/src/test/resources/pnf/signed-package-valid-signature.zip |