diff options
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test')
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"); |