diff options
Diffstat (limited to 'common-be/src/test')
2 files changed, 29 insertions, 22 deletions
diff --git a/common-be/src/test/java/org/openecomp/sdc/be/csar/security/Sha256WithRsaCmsContentSignerTest.java b/common-be/src/test/java/org/openecomp/sdc/be/csar/security/Sha256WithRsaCmsContentSignerTest.java index 2f0031d6e1..c8f1c68037 100644 --- a/common-be/src/test/java/org/openecomp/sdc/be/csar/security/Sha256WithRsaCmsContentSignerTest.java +++ b/common-be/src/test/java/org/openecomp/sdc/be/csar/security/Sha256WithRsaCmsContentSignerTest.java @@ -19,10 +19,6 @@ package org.openecomp.sdc.be.csar.security; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - import java.io.File; import java.io.IOException; import java.net.URL; @@ -48,6 +44,11 @@ import org.openecomp.sdc.be.csar.security.api.CertificateReader; import org.openecomp.sdc.be.csar.security.api.PrivateKeyReader; import org.openecomp.sdc.be.csar.security.exception.CmsSignatureException; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + class Sha256WithRsaCmsContentSignerTest { private Sha256WithRsaCmsContentSigner cmsContentSigner; @@ -85,6 +86,21 @@ class Sha256WithRsaCmsContentSignerTest { } @Test + void formatToPemSignatureTest() throws OperatorCreationException, CMSException, IOException, CmsSignatureException { + final File certFile = getResourceFile(certFilesPath.resolve("realCert1.cert")); + final File keyFile = getResourceFile(certFilesPath.resolve("realCert1.key")); + final File fileToSign = getResourceFile(testFilesPath.resolve("fileToSign.txt")); + final Key privateKey = privateKeyReader.loadPrivateKey(keyFile); + final Certificate certificate = certificateReader.loadCertificate(certFile); + final byte[] actualSignatureBytes = cmsContentSigner + .signData(Files.readAllBytes(fileToSign.toPath()), certificate, privateKey); + + assertNotNull(cmsContentSigner.formatToPemSignature(actualSignatureBytes)); + assertThrows(CmsSignatureException.class, + () -> cmsContentSigner.formatToPemSignature(new byte[10])); + } + + @Test void signDataInvalidCertAndKeyTest() { assertThrows(CmsSignatureException.class, () -> cmsContentSigner.signData(null, null, null)); diff --git a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/MapListRequirementDataDefinitionTest.java b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/MapListRequirementDataDefinitionTest.java index 4001599277..b6862393e0 100644 --- a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/MapListRequirementDataDefinitionTest.java +++ b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/MapListRequirementDataDefinitionTest.java @@ -20,11 +20,12 @@ package org.openecomp.sdc.be.datatypes.elements; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.HashMap; import java.util.Map; +import static org.junit.jupiter.api.Assertions.assertEquals; public class MapListRequirementDataDefinitionTest { @@ -33,26 +34,16 @@ public class MapListRequirementDataDefinitionTest { return new MapListRequirementDataDefinition(map); } - - @Test - public void testGetMapToscaDataDefinition() throws Exception { - MapListRequirementDataDefinition testSubject; - Map<String, ListRequirementDataDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getMapToscaDataDefinition(); - } - - @Test public void testAdd() throws Exception { - MapListRequirementDataDefinition testSubject; - String key = ""; + MapListRequirementDataDefinition testSubject = new MapListRequirementDataDefinition(); RequirementDataDefinition value = null; - // default test - testSubject = createTestSubject(); - testSubject.add(key, value); + testSubject.add("key1", value); + testSubject.add("key2", value); + testSubject.add("key2", value); + Map<String, ListRequirementDataDefinition> result = testSubject.getMapToscaDataDefinition(); + assertEquals(2, result.size()); + assertEquals(2, result.get("key2").getListToscaDataDefinition().size()); } } |