aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2022-01-01 16:11:49 +0000
committerDominik Stadler <centic@apache.org>2022-01-01 16:11:49 +0000
commit6de48ada5733b8571e6bac5931252de4ce8b4908 (patch)
tree9550be904c2f416d809b054ae972a9532751f5a5 /poi-ooxml
parent3e66ca24b28fa9ea8488e2875ee7e6a03a5f3b0a (diff)
downloadpoi-6de48ada5733b8571e6bac5931252de4ce8b4908.tar.gz
poi-6de48ada5733b8571e6bac5931252de4ce8b4908.zip
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. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1896598 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r--poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java30
1 files changed, 26 insertions, 4 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java b/poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java
index 77cc1472e3..91cda44fd7 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java
@@ -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());