summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/test/java/org/onap/cvc/csar/cc
diff options
context:
space:
mode:
authorBogumil Zebek <bogumil.zebek@nokia.com>2019-07-26 10:25:09 +0200
committerZebek Bogumil <bogumil.zebek@nokia.com>2019-07-31 11:06:50 +0200
commite66d2541cf7ee1836784681331b6909421a86d63 (patch)
treea67705ff015b7c78511e9cecc47c25c3fdddbb61 /csarvalidation/src/test/java/org/onap/cvc/csar/cc
parentdc6775fbc0779eb2db77ab8215fcb7847b94a4cf (diff)
Option 1 - vnf only
Change-Id: I281dddab930328f24b9267aa6afc6ae08fd9ed01 Issue-ID: VNFSDK-396 Signed-off-by: Zebek Bogumil <bogumil.zebek@nokia.com>
Diffstat (limited to 'csarvalidation/src/test/java/org/onap/cvc/csar/cc')
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/IntegrationTestUtils.java20
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR10087IntegrationTest.java11
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092IntegrationTest.java11
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901IntegrationTest.java9
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019IntegrationTest.java7
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965IntegrationTest.java9
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787966IntegrationTest.java29
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR87234IntegrationTest.java3
8 files changed, 69 insertions, 30 deletions
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<OnapCommandParameter> parameters = testCase.getParameters();
+ final Optional<OnapCommandParameter> 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<OnapCommandParameter> parameters = testCase.getParameters();
- OnapCommandParameter csar = parameters.stream().filter(op -> op.getName().equals("csar")).findFirst().get();
- csar.setValue(pathToFile);
+ Optional<OnapCommandParameter> csar = parameters.stream().filter(op -> op.getName().equals("csar")).findFirst();
+ if(csar.isPresent()) {
+ csar.get().setValue(pathToFile);
+ }
}
static List<String> convertToMessagesList(List<CSARArchive.CSARError> 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<CSARArchive.CSARError> 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<CSARArchive.CSARError> 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();