You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2022/01/01 16:11:49 UTC

svn commit: r1896598 - /poi/trunk/poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java

Author: centic
Date: Sat Jan  1 16:11:49 2022
New Revision: 1896598

URL: http://svn.apache.org/viewvc?rev=1896598&view=rev
Log:
Do not fail TestSignatureInfo when the current JDK does not have all the necessary setup

Let's gracefully handle some expected failures with some versions of the JDK
to not have flaky/failing test for users who just want to recompile POI themselves.

Modified:
    poi/trunk/poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java

Modified: poi/trunk/poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java?rev=1896598&r1=1896597&r2=1896598&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java (original)
+++ poi/trunk/poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java Sat Jan  1 16:11:49 2022
@@ -43,6 +43,7 @@ import java.net.MalformedURLException;
 import java.net.SocketTimeoutException;
 import java.net.URL;
 import java.security.GeneralSecurityException;
+import java.security.KeyStoreException;
 import java.security.cert.X509CRL;
 import java.security.cert.X509Certificate;
 import java.util.ArrayList;
@@ -823,7 +824,14 @@ class TestSignatureInfo {
         assertNotNull(pkg);
 
         DummyKeystore ks = new DummyKeystore("test");
-        KeyCertPair certPair = ks.addEntryFromPEM(testdata.getFile(pemFile), "test");
+        final KeyCertPair certPair;
+        try {
+            certPair = ks.addEntryFromPEM(testdata.getFile(pemFile), "test");
+        } catch (KeyStoreException e) {
+            // some JDKs do not have the proper setup, let's avoid strange test-failures due to this
+            assumeTrue(e.getMessage().startsWith("unrecognized algorithm name: PBEWithSHA1AndDESede"));
+            throw e;
+        }
 
         SignatureConfig config = new SignatureConfig();
         config.setKey(certPair.getKey());
@@ -870,7 +878,14 @@ class TestSignatureInfo {
     @Test
     void createXAdES_T_65623() throws Exception {
         DummyKeystore ks = new DummyKeystore(STORE_PASS);
-        KeyCertPair certPair = ks.createDummyKey();
+        final KeyCertPair certPair;
+        try {
+            certPair = ks.createDummyKey();
+        } catch (KeyStoreException e) {
+            // some JDKs do not have the proper setup, let's avoid strange test-failures due to this
+            assumeTrue(e.getMessage().startsWith("unrecognized algorithm name: PBEWithSHA1AndDESede"));
+            throw e;
+        }
 
         UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
         try (XSSFWorkbook wb = new XSSFWorkbook()) {
@@ -1050,7 +1065,14 @@ class TestSignatureInfo {
     @Test
     void commitmentType65672() throws Exception {
         DummyKeystore ks = new DummyKeystore(STORE_PASS);
-        KeyCertPair certPair = ks.createDummyKey();
+        final KeyCertPair certPair;
+        try {
+            certPair = ks.createDummyKey();
+        } catch (KeyStoreException e) {
+            // some JDKs do not have the proper setup, let's avoid strange test-failures due to this
+            assumeTrue(e.getMessage().startsWith("unrecognized algorithm name: PBEWithSHA1AndDESede"));
+            throw e;
+        }
 
         UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
         try (XSSFWorkbook wb = new XSSFWorkbook()) {
@@ -1086,7 +1108,7 @@ class TestSignatureInfo {
 
     private SignatureConfig prepareConfig(String pfxInput) throws Exception {
         DummyKeystore ks = (pfxInput == null) ? new DummyKeystore(STORE_PASS) : new DummyKeystore(pfxInput, STORE_PASS);
-        KeyCertPair certPair = ks.createDummyKey();;
+        KeyCertPair certPair = ks.createDummyKey();
 
         SignatureConfig signatureConfig = new SignatureConfig();
         signatureConfig.setKey(certPair.getKey());



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org