Disabled log debugging in SslBytesServerTest enabled in previous commit, and added check to not fail the tests if the JDK does not support TLS renegotiations.
This commit is contained in:
parent
a1eabe2b32
commit
bff3a5e72e
|
@ -22,6 +22,8 @@ import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.SSLEngine;
|
import javax.net.ssl.SSLEngine;
|
||||||
import javax.net.ssl.SSLSocket;
|
import javax.net.ssl.SSLSocket;
|
||||||
|
@ -47,10 +49,12 @@ import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
import org.junit.Assume;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.greaterThan;
|
||||||
import static org.hamcrest.Matchers.lessThan;
|
import static org.hamcrest.Matchers.lessThan;
|
||||||
|
|
||||||
public class SslBytesServerTest
|
public class SslBytesServerTest
|
||||||
|
@ -66,8 +70,6 @@ public class SslBytesServerTest
|
||||||
@Before
|
@Before
|
||||||
public void startServer() throws Exception
|
public void startServer() throws Exception
|
||||||
{
|
{
|
||||||
logger.setDebugEnabled(true);
|
|
||||||
|
|
||||||
threadPool = Executors.newCachedThreadPool();
|
threadPool = Executors.newCachedThreadPool();
|
||||||
server = new Server();
|
server = new Server();
|
||||||
|
|
||||||
|
@ -898,6 +900,8 @@ public class SslBytesServerTest
|
||||||
@Test
|
@Test
|
||||||
public void testRequestWithBigContentWithRenegotiationInMiddleOfContent() throws Exception
|
public void testRequestWithBigContentWithRenegotiationInMiddleOfContent() throws Exception
|
||||||
{
|
{
|
||||||
|
assumeJavaVersionSupportsTLSRenegotiations();
|
||||||
|
|
||||||
final SSLSocket client = newClient();
|
final SSLSocket client = newClient();
|
||||||
final OutputStream clientOutput = client.getOutputStream();
|
final OutputStream clientOutput = client.getOutputStream();
|
||||||
|
|
||||||
|
@ -1026,6 +1030,8 @@ public class SslBytesServerTest
|
||||||
@Test
|
@Test
|
||||||
public void testRequestWithBigContentWithRenegotiationInMiddleOfContentWithSplitBoundary() throws Exception
|
public void testRequestWithBigContentWithRenegotiationInMiddleOfContentWithSplitBoundary() throws Exception
|
||||||
{
|
{
|
||||||
|
assumeJavaVersionSupportsTLSRenegotiations();
|
||||||
|
|
||||||
final SSLSocket client = newClient();
|
final SSLSocket client = newClient();
|
||||||
final OutputStream clientOutput = client.getOutputStream();
|
final OutputStream clientOutput = client.getOutputStream();
|
||||||
|
|
||||||
|
@ -1184,6 +1190,20 @@ public class SslBytesServerTest
|
||||||
closeClient(client);
|
closeClient(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assumeJavaVersionSupportsTLSRenegotiations()
|
||||||
|
{
|
||||||
|
// Due to a security bug, TLS renegotiations were disabled in JDK 1.6.0_19-21
|
||||||
|
// so we check the java version in order to avoid to fail the test.
|
||||||
|
String javaVersion = System.getProperty("java.version");
|
||||||
|
Pattern regexp = Pattern.compile("1\\.6\\.0_(\\d{2})");
|
||||||
|
Matcher matcher = regexp.matcher(javaVersion);
|
||||||
|
if (matcher.matches())
|
||||||
|
{
|
||||||
|
String nano = matcher.group(1);
|
||||||
|
Assume.assumeThat(Integer.parseInt(nano), greaterThan(21));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private SSLSocket newClient() throws IOException, InterruptedException
|
private SSLSocket newClient() throws IOException, InterruptedException
|
||||||
{
|
{
|
||||||
SSLSocket client = (SSLSocket)sslContext.getSocketFactory().createSocket("localhost", proxy.getPort());
|
SSLSocket client = (SSLSocket)sslContext.getSocketFactory().createSocket("localhost", proxy.getPort());
|
||||||
|
|
Loading…
Reference in New Issue