Skip to content

Commit c78bc05

Browse files
committed
Make tests' detection of SSL handshake failures more robust
Closes gh-12961
1 parent 370915f commit c78bc05

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

spring-boot/src/test/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactoryTests.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818

1919
import java.io.File;
2020
import java.io.IOException;
21+
import java.net.SocketException;
2122
import java.net.URISyntaxException;
2223
import java.nio.charset.Charset;
2324
import java.util.Arrays;
@@ -51,6 +52,8 @@
5152
import org.springframework.test.util.ReflectionTestUtils;
5253

5354
import static org.assertj.core.api.Assertions.assertThat;
55+
import static org.hamcrest.CoreMatchers.anyOf;
56+
import static org.hamcrest.CoreMatchers.instanceOf;
5457
import static org.mockito.Matchers.anyObject;
5558
import static org.mockito.Mockito.inOrder;
5659
import static org.mockito.Mockito.mock;
@@ -222,14 +225,18 @@ public void customize(Builder builder) {
222225
});
223226
}
224227

225-
@Test(expected = SSLHandshakeException.class)
228+
@Test
226229
public void sslRestrictedProtocolsEmptyCipherFailure() throws Exception {
230+
this.thrown.expect(anyOf(instanceOf(SSLHandshakeException.class),
231+
instanceOf(SocketException.class)));
227232
testRestrictedSSLProtocolsAndCipherSuites(new String[] { "TLSv1.2" },
228233
new String[] { "TLS_EMPTY_RENEGOTIATION_INFO_SCSV" });
229234
}
230235

231-
@Test(expected = SSLHandshakeException.class)
236+
@Test
232237
public void sslRestrictedProtocolsECDHETLS1Failure() throws Exception {
238+
this.thrown.expect(anyOf(instanceOf(SSLHandshakeException.class),
239+
instanceOf(SocketException.class)));
233240
testRestrictedSSLProtocolsAndCipherSuites(new String[] { "TLSv1" },
234241
new String[] { "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" });
235242
}
@@ -246,8 +253,10 @@ public void sslRestrictedProtocolsRSATLS12Success() throws Exception {
246253
new String[] { "TLS_RSA_WITH_AES_128_CBC_SHA256" });
247254
}
248255

249-
@Test(expected = SSLHandshakeException.class)
256+
@Test
250257
public void sslRestrictedProtocolsRSATLS11Failure() throws Exception {
258+
this.thrown.expect(anyOf(instanceOf(SSLHandshakeException.class),
259+
instanceOf(SocketException.class)));
251260
testRestrictedSSLProtocolsAndCipherSuites(new String[] { "TLSv1.1" },
252261
new String[] { "TLS_RSA_WITH_AES_128_CBC_SHA256" });
253262
}

0 commit comments

Comments
 (0)