summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test
diff options
context:
space:
mode:
authorJoanna Jeremicz <joanna.jeremicz@nokia.com>2021-04-21 13:59:12 +0200
committerMichael Morris <michael.morris@est.tech>2021-05-14 14:58:14 +0000
commite3de4c9d214983d38a7d66e89dae5d4bba170ca3 (patch)
tree9f92e5fc15d06051ffff254588bbcc1e85214d3f /openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test
parentdf353be353e1ec25ac2a0e64a9eb617dcbc87703 (diff)
Integrate helm validator with SDC-BE
- Read helm validator configuration - Add call to helm validator during Helm validation - Add JUnit tests - Fix display message when CNF upload is unsuccessful - Show warning messages from validation after CNF upload Issue-ID: SDC-3185 Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com> Change-Id: If197d557e6ddef4a07bef986d7cf133aedcb2cc5 Signed-off-by: Piotr Marcinkiewicz <piotr.marcinkiewicz@nokia.com>
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessorTest.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessorUnitTest.java10
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/CsarSecurityValidatorTest.java10
3 files changed, 16 insertions, 9 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessorTest.java
index d6327866f4..6c847a713e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessorTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessorTest.java
@@ -49,6 +49,7 @@ import org.junit.runners.Parameterized.Parameters;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.vendorsoftwareproduct.impl.onboarding.validation.CnfPackageValidator;
import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackageInfo;
@RunWith(Parameterized.class)
@@ -59,6 +60,7 @@ public class OnboardingPackageProcessorTest {
private final byte[] packageBytes;
private final Set<ErrorMessage> expectedErrorSet;
private final OnboardingTypesEnum expectedPackageType;
+ private final CnfPackageValidator cnfPackageValidator;
public OnboardingPackageProcessorTest(final String packageName, final byte[] packageBytes,
final Set<ErrorMessage> expectedErrorSet,
@@ -67,6 +69,7 @@ public class OnboardingPackageProcessorTest {
this.packageBytes = packageBytes;
this.expectedErrorSet = expectedErrorSet;
this.expectedPackageType = expectedPackageType;
+ this.cnfPackageValidator = new CnfPackageValidator();
}
@Parameters(name = "Run {index} for {0}")
@@ -115,7 +118,7 @@ public class OnboardingPackageProcessorTest {
@Test
public void processPackage() {
final OnboardingPackageProcessor onboardingPackageProcessor = new OnboardingPackageProcessor(packageName,
- packageBytes);
+ packageBytes, cnfPackageValidator);
assertThat("Should contains errors", onboardingPackageProcessor.hasErrors(), is(!expectedErrorSet.isEmpty()));
assertThat("Should have the same number of errors", onboardingPackageProcessor.getErrorMessages().size(),
equalTo(expectedErrorSet.size()));
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessorUnitTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessorUnitTest.java
index a97a0f639a..795da7780f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessorUnitTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/onboarding/OnboardingPackageProcessorUnitTest.java
@@ -19,6 +19,9 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl.onboarding;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -26,14 +29,13 @@ import org.junit.Test;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
import org.openecomp.sdc.heat.datatypes.manifest.FileData.Type;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import org.openecomp.sdc.vendorsoftwareproduct.impl.onboarding.validation.CnfPackageValidator;
public class OnboardingPackageProcessorUnitTest {
- private OnboardingPackageProcessor processor = new OnboardingPackageProcessor("unitTestPackage", null);
+ private OnboardingPackageProcessor processor = new OnboardingPackageProcessor("unitTestPackage",
+ null, new CnfPackageValidator());
@Test
public void shouldValidateZipPackage_helmWithoutHeat() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/CsarSecurityValidatorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/CsarSecurityValidatorTest.java
index 0fce606052..27d80412bf 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/CsarSecurityValidatorTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/CsarSecurityValidatorTest.java
@@ -34,6 +34,7 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.openecomp.sdc.vendorsoftwareproduct.impl.onboarding.OnboardingPackageProcessor;
+import org.openecomp.sdc.vendorsoftwareproduct.impl.onboarding.validation.CnfPackageValidator;
import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManager;
import org.openecomp.sdc.vendorsoftwareproduct.security.SecurityManagerException;
import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackageInfo;
@@ -56,7 +57,7 @@ public class CsarSecurityValidatorTest {
public void isSignatureValidTestCorrectStructureAndValidSignatureExists() throws SecurityManagerException {
final byte[] packageBytes = getFileBytesOrFail("signing/signed-package.zip");
final OnboardSignedPackage onboardSignedPackage = loadSignedPackage("signed-package.zip",
- packageBytes);
+ packageBytes, null);
when(securityManager.verifySignedData(any(), any(), any())).thenReturn(true);
final boolean isSignatureValid = csarSecurityValidator.verifyPackageSignature(onboardSignedPackage);
assertThat("Signature should be valid", isSignatureValid, is(true));
@@ -66,7 +67,7 @@ public class CsarSecurityValidatorTest {
public void isSignatureValidTestCorrectStructureAndNotValidSignatureExists() throws SecurityManagerException {
final byte[] packageBytes = getFileBytesOrFail("signing/signed-package-tampered-data.zip");
final OnboardSignedPackage onboardSignedPackage = loadSignedPackage("signed-package-tampered-data.zip",
- packageBytes);
+ packageBytes, null);
//no mocked securityManager
csarSecurityValidator = new CsarSecurityValidator();
csarSecurityValidator.verifyPackageSignature(onboardSignedPackage);
@@ -86,9 +87,10 @@ public class CsarSecurityValidatorTest {
CsarSecurityValidatorTest.class.getResource(BASE_DIR + path).toURI()));
}
- private OnboardSignedPackage loadSignedPackage(final String packageName, final byte[] packageBytes) {
+ private OnboardSignedPackage loadSignedPackage(final String packageName, final byte[] packageBytes,
+ CnfPackageValidator cnfPackageValidator) {
final OnboardingPackageProcessor onboardingPackageProcessor =
- new OnboardingPackageProcessor(packageName, packageBytes);
+ new OnboardingPackageProcessor(packageName, packageBytes, cnfPackageValidator);
final OnboardPackageInfo onboardPackageInfo = onboardingPackageProcessor.getOnboardPackageInfo().orElse(null);
if (onboardPackageInfo == null) {
fail("Unexpected error. Could not load original package");