aboutsummaryrefslogtreecommitdiffstats
path: root/integration-tests/src/test
diff options
context:
space:
mode:
authorBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>2021-01-19 13:04:48 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2021-01-20 13:11:50 +0000
commit7ca0d6eeda3be23506678eb7747b4bf0b7c62b41 (patch)
treef262b9304fa29a9906007fff0fb9e3ec41d5e7bb /integration-tests/src/test
parentbaf6ff4f604f44062bdf4963aed8591d95bb6389 (diff)
Add handling of individual artifact signature in manifest file.
Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com> Issue-ID: SDC-3397 Change-Id: I0082571a874721998a07aef3ea845de76483d9c7
Diffstat (limited to 'integration-tests/src/test')
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/validation/pmdictionary/CsarValidationTest.java44
-rw-r--r--integration-tests/src/test/resources/Files/PNFs/validation/individualSignature/invalidPnfWithIndividualSignatureCompliantWithSOL004.csarbin0 -> 103593 bytes
-rw-r--r--integration-tests/src/test/resources/Files/PNFs/validation/individualSignature/validPnfWithIndividualSignatureCompliantWithSOL004.csarbin0 -> 103607 bytes
3 files changed, 41 insertions, 3 deletions
diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/validation/pmdictionary/CsarValidationTest.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/validation/pmdictionary/CsarValidationTest.java
index e12e058d6c..2390de4780 100644
--- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/validation/pmdictionary/CsarValidationTest.java
+++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/validation/pmdictionary/CsarValidationTest.java
@@ -3,6 +3,7 @@
* SDC
* ================================================================================
* Copyright (C) 2020 Nokia. All rights reserved.
+ * Modification Copyright (C) 2021 Nokia.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +30,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validatio
import java.io.IOException;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
@@ -59,12 +61,48 @@ class CsarValidationTest {
//then
assertThat(errorList, is(not(empty())));
- assertThat(getActualErrorMessage(errorList), is(equalTo(expectedErrorMessage)));
+ assertThat(getActualErrorMessages(errorList).get(0), is(equalTo(expectedErrorMessage)));
assertThat(getActualErrorLevel(errorList), is(ErrorLevel.ERROR));
}
- private String getActualErrorMessage(List<ErrorMessage> errorList) {
- return errorList.get(0).getMessage();
+ @Test
+ void shouldNotReturnErrors_whenPnfCsarContainsIndividualSignatureInManifest() throws OnboardPackageException, IOException {
+ //given
+ FileContentHandler pnfFileContent = CsarLoader.load(
+ "validPnfWithIndividualSignatureCompliantWithSOL004.csar",
+ "/Files/PNFs/validation/individualSignature/validPnfWithIndividualSignatureCompliantWithSOL004.csar"
+ );
+
+ //when
+ Map<String, List<ErrorMessage>> errorsMap = ValidatorFactory.getValidator(pnfFileContent).validateContent(pnfFileContent);
+
+ //then
+ assertThat(errorsMap, is(anEmptyMap()));
+ }
+
+ @Test
+ void shouldReturnErrors_whenPnfCsarContainsIndividualCertificateWithNoSignatureInManifest() throws OnboardPackageException, IOException {
+ //given
+ List<String> expectedErrorMessage = List.of("Expected 'Signature' entry before 'Certificate' entry;\nAt line 9: 'Certificate: Definitions/pnf_main_descriptor.cert'.");
+ FileContentHandler pnfFileContent = CsarLoader.load(
+ "invalidPnfWithIndividualSignatureCompliantWithSOL004.csar",
+ "/Files/PNFs/validation/individualSignature/invalidPnfWithIndividualSignatureCompliantWithSOL004.csar"
+ );
+
+ //when
+ Map<String, List<ErrorMessage>> errorsMap = ValidatorFactory.getValidator(pnfFileContent).validateContent(pnfFileContent);
+ List<ErrorMessage> errorList = errorsMap.get("uploadFile");
+
+ //then
+ assertThat(getActualErrorMessages(errorList), containsInAnyOrder(expectedErrorMessage.toArray()));
+ assertThat(getActualErrorLevel(errorList), is(ErrorLevel.ERROR));
+ }
+
+
+ private List<String> getActualErrorMessages(List<ErrorMessage> errorList) {
+ return errorList.stream()
+ .map((ErrorMessage::getMessage))
+ .collect(Collectors.toUnmodifiableList());
}
private ErrorLevel getActualErrorLevel(List<ErrorMessage> errorList) {
diff --git a/integration-tests/src/test/resources/Files/PNFs/validation/individualSignature/invalidPnfWithIndividualSignatureCompliantWithSOL004.csar b/integration-tests/src/test/resources/Files/PNFs/validation/individualSignature/invalidPnfWithIndividualSignatureCompliantWithSOL004.csar
new file mode 100644
index 0000000000..7b491573d2
--- /dev/null
+++ b/integration-tests/src/test/resources/Files/PNFs/validation/individualSignature/invalidPnfWithIndividualSignatureCompliantWithSOL004.csar
Binary files differ
diff --git a/integration-tests/src/test/resources/Files/PNFs/validation/individualSignature/validPnfWithIndividualSignatureCompliantWithSOL004.csar b/integration-tests/src/test/resources/Files/PNFs/validation/individualSignature/validPnfWithIndividualSignatureCompliantWithSOL004.csar
new file mode 100644
index 0000000000..6d3ed91aaf
--- /dev/null
+++ b/integration-tests/src/test/resources/Files/PNFs/validation/individualSignature/validPnfWithIndividualSignatureCompliantWithSOL004.csar
Binary files differ