summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'csarvalidation/src/test/java/org')
-rw-r--r--csarvalidation/src/test/java/org/onap/functional/CsarValidationUtility.java1
-rw-r--r--csarvalidation/src/test/java/org/onap/functional/PnfValidationFunctionalTest.java122
2 files changed, 121 insertions, 2 deletions
diff --git a/csarvalidation/src/test/java/org/onap/functional/CsarValidationUtility.java b/csarvalidation/src/test/java/org/onap/functional/CsarValidationUtility.java
index 24ef778..efeeb5d 100644
--- a/csarvalidation/src/test/java/org/onap/functional/CsarValidationUtility.java
+++ b/csarvalidation/src/test/java/org/onap/functional/CsarValidationUtility.java
@@ -34,6 +34,7 @@ public final class CsarValidationUtility {
private CsarValidationUtility(){}
public static final String CERTIFICATION_RULE = "r130206";
+ public static final String PM_DICTIONARY_YAML_RULE = "r816745";
public static final String OPERATION_STATUS_FAILED = "FAILED";
public static final String OPERATION_STATUS_PASS = "PASS";
diff --git a/csarvalidation/src/test/java/org/onap/functional/PnfValidationFunctionalTest.java b/csarvalidation/src/test/java/org/onap/functional/PnfValidationFunctionalTest.java
index 903691e..4dec242 100644
--- a/csarvalidation/src/test/java/org/onap/functional/PnfValidationFunctionalTest.java
+++ b/csarvalidation/src/test/java/org/onap/functional/PnfValidationFunctionalTest.java
@@ -28,6 +28,7 @@ import static org.onap.cvc.csar.cc.sol004.IntegrationTestUtils.absoluteFilePath;
import static org.onap.functional.CsarValidationUtility.CERTIFICATION_RULE;
import static org.onap.functional.CsarValidationUtility.OPERATION_STATUS_FAILED;
import static org.onap.functional.CsarValidationUtility.OPERATION_STATUS_PASS;
+import static org.onap.functional.CsarValidationUtility.PM_DICTIONARY_YAML_RULE;
import static org.onap.functional.CsarValidationUtility.createExpectedError;
import static org.onap.functional.CsarValidationUtility.getCliCommandValidationResult;
import static org.onap.functional.CsarValidationUtility.verifyThatOperationFinishedWithoutAnyError;
@@ -82,7 +83,6 @@ public class PnfValidationFunctionalTest {
@Test
public void shouldReportThatPnfValidationFailedWhenCsarContainsCertificateInCmsAndInToscaAndInRootAndHashIsIncorrect_allOtherRulesShouldPass() throws URISyntaxException {
// given
-
List<OnapCliValidationResponseWrapper.ValidationResultWrapper.ValidationErrorWrapper> expectedErrors =
List.of(
createExpectedError(CERTIFICATION_RULE, "0x4007",
@@ -118,6 +118,115 @@ public class PnfValidationFunctionalTest {
verifyThatOperationFinishedWithoutAnyError(cli);
}
+ @Test
+ public void shouldReportThatPnfCertificationRuleValidationFailedWhenCsarContainsCertificateInCmsAndInToscaAndInRootAndHashIsIncorrect() throws URISyntaxException {
+ // given
+ List<OnapCliValidationResponseWrapper.ValidationResultWrapper.ValidationErrorWrapper> expectedErrors =
+ List.of(
+ createExpectedError(CERTIFICATION_RULE, "0x4007",
+ "File has invalid signature!"),
+ createExpectedError(CERTIFICATION_RULE, "0x4004",
+ "Source 'Files/pnf-sw-information/pnf-sw-information.yaml' has wrong hash!"),
+ createExpectedError(CERTIFICATION_RULE, "0x4011",
+ "ETSI-Entry-Certificate entry in Tosca.meta is defined despite the certificate is included in the signature container"),
+ createExpectedError(CERTIFICATION_RULE, "0x4012",
+ "ETSI-Entry-Certificate certificate present despite the certificate is included in the signature container"),
+ createExpectedError(CERTIFICATION_RULE, "0x4013",
+ "Certificate present in root catalog despite the certificate is included in the signature container")
+ );
+ OnapCliWrapper cli = new OnapCliWrapper(
+ createPnfValidationSelectedRulesRequestInfo(
+ "pnf/r130206/cert-in-cms-and-root-and-tosca-incorrect-hash.csar",
+ CERTIFICATION_RULE
+ ));
+
+ // when
+ cli.handle();
+
+ // then
+ final OnapCliValidationResponseWrapper result = getCliCommandValidationResult(cli);
+
+ assertThat(result.criteria).isEqualTo(OPERATION_STATUS_FAILED);
+ assertThat(result.results).hasSize(2);
+ result.results.forEach((ruleValidationResult)->{
+ assertThat(ruleValidationResult.warnings).isEmpty();
+ if (ruleValidationResult.vnfreqName.equals(CERTIFICATION_RULE)) {
+ assertThat(ruleValidationResult.errors)
+ .hasSize(5)
+ .containsAll(expectedErrors);
+ } else {
+ assertThat(ruleValidationResult.errors).isEmpty();
+ }
+ });
+ verifyThatOperationFinishedWithoutAnyError(cli);
+ }
+
+ @Test
+ public void shouldReportThatPnfPmDictionaryYamlRuleValidationSuccessWhenCsarContainsCertificateInCmsAndInToscaAndInRootAndHashIsIncorrect() throws URISyntaxException {
+ // given
+ OnapCliWrapper cli = new OnapCliWrapper(
+ createPnfValidationSelectedRulesRequestInfo(
+ "pnf/r130206/cert-in-cms-and-root-and-tosca-incorrect-hash.csar",
+ PM_DICTIONARY_YAML_RULE
+ ));
+
+ // when
+ cli.handle();
+
+ // then
+ final OnapCliValidationResponseWrapper result = getCliCommandValidationResult(cli);
+
+ assertThat(result.criteria).isEqualTo(OPERATION_STATUS_PASS);
+ assertThat(result.results).hasSize(2);
+ result.results.forEach((ruleValidationResult)->{
+ assertThat(ruleValidationResult.warnings).isEmpty();
+ assertThat(ruleValidationResult.errors).isEmpty();
+ });
+ verifyThatOperationFinishedWithoutAnyError(cli);
+ }
+
+ @Test
+ public void shouldReportThatPnfCertificationRuleAndPnfPmDictionaryYamlRuleValidationFailedWhenCsarContainsCertificateInCmsAndInToscaAndInRootAndHashIsIncorrect() throws URISyntaxException {
+ // given
+ List<OnapCliValidationResponseWrapper.ValidationResultWrapper.ValidationErrorWrapper> expectedErrors =
+ List.of(
+ createExpectedError(CERTIFICATION_RULE, "0x4007",
+ "File has invalid signature!"),
+ createExpectedError(CERTIFICATION_RULE, "0x4004",
+ "Source 'Files/pnf-sw-information/pnf-sw-information.yaml' has wrong hash!"),
+ createExpectedError(CERTIFICATION_RULE, "0x4011",
+ "ETSI-Entry-Certificate entry in Tosca.meta is defined despite the certificate is included in the signature container"),
+ createExpectedError(CERTIFICATION_RULE, "0x4012",
+ "ETSI-Entry-Certificate certificate present despite the certificate is included in the signature container"),
+ createExpectedError(CERTIFICATION_RULE, "0x4013",
+ "Certificate present in root catalog despite the certificate is included in the signature container")
+ );
+ OnapCliWrapper cli = new OnapCliWrapper(
+ createPnfValidationSelectedRulesRequestInfo(
+ "pnf/r130206/cert-in-cms-and-root-and-tosca-incorrect-hash.csar",
+ CERTIFICATION_RULE+","+PM_DICTIONARY_YAML_RULE
+ ));
+
+ // when
+ cli.handle();
+
+ // then
+ final OnapCliValidationResponseWrapper result = getCliCommandValidationResult(cli);
+
+ assertThat(result.criteria).isEqualTo(OPERATION_STATUS_FAILED);
+ assertThat(result.results).hasSize(3);
+ result.results.forEach((ruleValidationResult)->{
+ assertThat(ruleValidationResult.warnings).isEmpty();
+ if (ruleValidationResult.vnfreqName.equals(CERTIFICATION_RULE)) {
+ assertThat(ruleValidationResult.errors)
+ .hasSize(5)
+ .containsAll(expectedErrors);
+ } else {
+ assertThat(ruleValidationResult.errors).isEmpty();
+ }
+ });
+ verifyThatOperationFinishedWithoutAnyError(cli);
+ }
private String[] createPnfValidationRequestInfo(String csarPath) throws URISyntaxException {
return new String[]{
"--product", "onap-dublin",
@@ -128,5 +237,14 @@ public class PnfValidationFunctionalTest {
};
}
-
+ private String[] createPnfValidationSelectedRulesRequestInfo(String csarPath, String rulesToValidate) throws URISyntaxException {
+ return new String[]{
+ "--product", "onap-dublin",
+ "csar-validate",
+ "--format", "json",
+ "--rules", rulesToValidate,
+ "--pnf",
+ "--csar", absoluteFilePath(csarPath)
+ };
+ }
}