Skip to content

Commit 055b50a

Browse files
committed
Fixed test to match on instances of IOException.
1 parent bebf38b commit 055b50a

1 file changed

Lines changed: 13 additions & 17 deletions

File tree

test/src/test/java/org/bouncycastle/test/est/TestCACertsFetch.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.io.ByteArrayInputStream;
44
import java.io.ByteArrayOutputStream;
5-
import java.io.EOFException;
65
import java.io.FileReader;
76
import java.io.IOException;
87
import java.io.InputStream;
@@ -43,7 +42,6 @@
4342
import org.bouncycastle.est.Source;
4443
import org.bouncycastle.est.jcajce.JcaJceUtils;
4544
import org.bouncycastle.est.jcajce.JsseESTServiceBuilder;
46-
import org.bouncycastle.jsse.provider.BouncyCastleJsseProvider;
4745
import org.bouncycastle.test.est.examples.ExampleUtils;
4846
import org.bouncycastle.util.Store;
4947
import org.bouncycastle.util.io.pem.PemReader;
@@ -152,7 +150,7 @@ public void testFetchCaCertsWithTimeout()
152150

153151
int port = res.open(null);
154152

155-
ESTService est = new JsseESTServiceBuilder("localhost:" + port , JcaJceUtils.getTrustAllTrustManager()).withTimeout(500).addCipherSuites(res.getEnabledSuites()).build();
153+
ESTService est = new JsseESTServiceBuilder("localhost:" + port, JcaJceUtils.getTrustAllTrustManager()).withTimeout(500).addCipherSuites(res.getEnabledSuites()).build();
156154

157155
try
158156
{
@@ -259,8 +257,6 @@ public void testFetchCaCertsWithBogusTrustAnchor()
259257
}
260258

261259

262-
263-
264260
/**
265261
* Fetch CA certs relying on TLS to validate the server by specifying a trust anchor.
266262
*
@@ -684,7 +680,7 @@ public boolean isTrusted()
684680
catch (Exception ex)
685681
{
686682
Assert.assertEquals("Expect EST Exception", ESTException.class, ex.getClass());
687-
Assert.assertEquals("Expect cause an IOException", EOFException.class, ex.getCause().getClass());
683+
Assert.assertTrue("Expect cause an IOException", ex.getCause() instanceof IOException);
688684
}
689685

690686
}
@@ -835,7 +831,7 @@ public void testEmptyCaCertsResponseContentLengthExceedsAbsoluteLimit()
835831

836832

837833
JsseESTServiceBuilder builder = new JsseESTServiceBuilder(
838-
"localhost:" + port , JcaJceUtils.getTrustAllTrustManager());
834+
"localhost:" + port, JcaJceUtils.getTrustAllTrustManager());
839835

840836

841837
builder.withReadLimit(1000L);
@@ -903,7 +899,7 @@ public void testContentLengthBelowAbsoluteLimit()
903899
int port = res.open(responseData.toByteArray());
904900

905901
JsseESTServiceBuilder builder = new JsseESTServiceBuilder(
906-
"localhost:" + port , JcaJceUtils.getTrustAllTrustManager());
902+
"localhost:" + port, JcaJceUtils.getTrustAllTrustManager());
907903
builder.withReadLimit(530);
908904
builder.addCipherSuites(res.getEnabledSuites());
909905

@@ -960,7 +956,7 @@ public void testResponseContentLengthInvalid()
960956

961957
int port = res.open(responseData.toByteArray());
962958
JsseESTServiceBuilder builder = new JsseESTServiceBuilder(
963-
"localhost:" + port , JcaJceUtils.getTrustAllTrustManager());
959+
"localhost:" + port, JcaJceUtils.getTrustAllTrustManager());
964960
builder.withReadLimit(530);
965961
builder.addCipherSuites(res.getSupportedCipherSuites());
966962

@@ -1023,7 +1019,7 @@ public void testResponseNoContentLengthHeader()
10231019

10241020
int port = res.open(responseData.toByteArray());
10251021
JsseESTServiceBuilder builder = new JsseESTServiceBuilder(
1026-
"localhost:" + port , JcaJceUtils.getTrustAllTrustManager());
1022+
"localhost:" + port, JcaJceUtils.getTrustAllTrustManager());
10271023
builder.withReadLimit(530);
10281024
builder.addCipherSuites(res.getSupportedCipherSuites());
10291025

@@ -1088,7 +1084,7 @@ public void testResponseNegativeContentLength()
10881084
int port = res.open(responseData.toByteArray());
10891085

10901086
JsseESTServiceBuilder builder = new JsseESTServiceBuilder(
1091-
"localhost:" + port , JcaJceUtils.getTrustAllTrustManager());
1087+
"localhost:" + port, JcaJceUtils.getTrustAllTrustManager());
10921088
builder.withReadLimit(530);
10931089
builder.addCipherSuites(res.getSupportedCipherSuites());
10941090

@@ -1150,7 +1146,7 @@ public void testIncorrectContentType()
11501146

11511147
int port = res.open(responseData.toByteArray());
11521148
JsseESTServiceBuilder builder = new JsseESTServiceBuilder(
1153-
"localhost:" + port , JcaJceUtils.getTrustAllTrustManager());
1149+
"localhost:" + port, JcaJceUtils.getTrustAllTrustManager());
11541150
builder.withReadLimit(530);
11551151
builder.addCipherSuites(res.getSupportedCipherSuites());
11561152

@@ -1212,7 +1208,7 @@ public void testMissingContentType()
12121208

12131209
int port = res.open(responseData.toByteArray());
12141210
JsseESTServiceBuilder builder = new JsseESTServiceBuilder(
1215-
"localhost:" + port , JcaJceUtils.getTrustAllTrustManager());
1211+
"localhost:" + port, JcaJceUtils.getTrustAllTrustManager());
12161212
builder.withReadLimit(530);
12171213
builder.addCipherSuites(res.getSupportedCipherSuites());
12181214

@@ -1277,7 +1273,7 @@ public void testRejectOnTLSv1Establishment()
12771273
int port = res.open(responseData.toByteArray());
12781274

12791275
JsseESTServiceBuilder builder = new JsseESTServiceBuilder(
1280-
"localhost:" + port , JcaJceUtils.getTrustAllTrustManager());
1276+
"localhost:" + port, JcaJceUtils.getTrustAllTrustManager());
12811277
builder.withReadLimit(530);
12821278
builder.addCipherSuites(res.getSupportedCipherSuites());
12831279
builder.withTLSVersion("TLSv1");
@@ -1351,7 +1347,7 @@ public void testRejectOnNullCipherEstablishment()
13511347
{
13521348
int port = res.open(responseData.toByteArray());
13531349
JsseESTServiceBuilder builder = new JsseESTServiceBuilder(
1354-
"127.0.0.1:" + port , JcaJceUtils.getTrustAllTrustManager());
1350+
"127.0.0.1:" + port, JcaJceUtils.getTrustAllTrustManager());
13551351
builder.withReadLimit(530).withHostNameAuthorizer(null);
13561352
builder.addCipherSuites(res.getEnabledSuites());
13571353

@@ -1442,7 +1438,7 @@ public void testRejectOnAnonCipherEstablishment()
14421438
catch (Exception ex)
14431439
{
14441440
Assert.assertEquals("EST Exception", ESTException.class, ex.getClass());
1445-
Assert.assertTrue("", ex.getCause() instanceof IOException);
1441+
Assert.assertTrue("", ex.getCause() instanceof IOException);
14461442
Assert.assertTrue(ex.getMessage().contains("must not use anon"));
14471443
}
14481444
}
@@ -1618,7 +1614,7 @@ public void testRejectOnDESCipherEstablishment()
16181614
int port = res.open(responseData.toByteArray());
16191615

16201616
JsseESTServiceBuilder builder = new JsseESTServiceBuilder(
1621-
"127.0.0.1:" + port , JcaJceUtils.getTrustAllTrustManager());
1617+
"127.0.0.1:" + port, JcaJceUtils.getTrustAllTrustManager());
16221618
builder.withReadLimit(530);
16231619
builder.addCipherSuites(res.getEnabledSuites());
16241620
builder.withTLSVersion("TLSv1"); // <- needed to get export suites to work.

0 commit comments

Comments
 (0)