diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java index f353e7f09ae..2d23ff564bf 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLCloseTest.java @@ -27,6 +27,7 @@ import java.net.Socket; import java.nio.charset.StandardCharsets; import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLEngine; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -36,6 +37,7 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; +import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.junit.Test; @@ -58,8 +60,8 @@ public class SSLCloseTest server.addConnector(connector); server.setHandler(new WriteHandler()); server.start(); - - SSLContext ctx=SSLContext.getInstance("SSLv3"); + + SSLContext ctx=SSLContext.getInstance("TLSv1.2"); ctx.init(null,SslContextFactory.TRUST_ALL_CERTS,new java.security.SecureRandom()); int port=connector.getLocalPort(); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java index 9b76d0e7023..a010774b156 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SSLEngineTest.java @@ -189,7 +189,7 @@ public class SSLEngineTest Socket[] client=new Socket[numConns]; - SSLContext ctx=SSLContext.getInstance("SSLv3"); + SSLContext ctx=SSLContext.getInstance("TLSv1.2"); ctx.init(null,SslContextFactory.TRUST_ALL_CERTS,new java.security.SecureRandom()); int port=connector.getLocalPort(); diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java index 5025b2da2c4..42f109c7d4d 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java @@ -250,14 +250,10 @@ public class SslContextFactory extends AbstractLifeCycle setTrustAll(trustAll); addExcludeProtocols("SSL", "SSLv2", "SSLv2Hello", "SSLv3"); setExcludeCipherSuites( - "SSL_RSA_WITH_DES_CBC_SHA", - "SSL_DHE_RSA_WITH_DES_CBC_SHA", + "^.*_RSA_.*_(MD5|SHA|SHA1)$", "SSL_DHE_DSS_WITH_DES_CBC_SHA", - "SSL_RSA_EXPORT_WITH_RC4_40_MD5", - "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", - "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"); -} + } /** * Construct an instance of SslContextFactory diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java index 0ca664436f0..a5e65c02513 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/ssl/SslContextFactoryTest.java @@ -29,6 +29,7 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; import java.io.InputStream; import java.security.KeyStore; +import java.util.Arrays; import javax.net.ssl.SSLEngine; @@ -56,6 +57,20 @@ public class SslContextFactoryTest cf = new SslContextFactory(); } + @Test + public void testSLOTH() throws Exception + { + cf.setKeyStorePassword("storepwd"); + cf.setKeyManagerPassword("keypwd"); + + cf.start(); + + System.err.println(Arrays.asList(cf.getSelectedProtocols())); + for (String cipher : cf.getSelectedCipherSuites()) + System.err.println(cipher); + + } + @Test public void testNoTsFileKs() throws Exception { diff --git a/tests/test-quickstart/src/test/java/org/eclipse/jetty/quickstart/AttributeNormalizerTest.java b/tests/test-quickstart/src/test/java/org/eclipse/jetty/quickstart/AttributeNormalizerTest.java new file mode 100644 index 00000000000..8121d63e8e5 --- /dev/null +++ b/tests/test-quickstart/src/test/java/org/eclipse/jetty/quickstart/AttributeNormalizerTest.java @@ -0,0 +1,204 @@ + // +// ======================================================================== +// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + +package org.eclipse.jetty.quickstart; + +import static org.junit.Assert.assertEquals; + +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jetty.util.resource.Resource; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; + +@RunWith(Parameterized.class) +public class AttributeNormalizerTest +{ + @Parameters(name="{0} = {1}") + public static List data() + { + String[][] tests = { + { "WAR", "/opt/jetty-distro/demo.base/webapps/root" }, + { "jetty.home", "/opt/jetty-distro" }, + { "jetty.base", "/opt/jetty-distro/demo.base" }, + { "user.home", "/home/user" }, + { "user.dir", "/etc/init.d" }, + }; + + return Arrays.asList(tests); + } + + private static String origJettyBase; + private static String origJettyHome; + private static String origUserHome; + private static String origUserDir; + + @BeforeClass + public static void initProperties() + { + origJettyBase = System.getProperty("jetty.base"); + origJettyHome = System.getProperty("jetty.home"); + origUserHome = System.getProperty("user.home"); + origUserDir = System.getProperty("user.dir"); + + System.setProperty("jetty.home","/opt/jetty-distro"); + System.setProperty("jetty.base","/opt/jetty-distro/demo.base"); + System.setProperty("user.home","/home/user"); + System.setProperty("user.dir","/etc/init.d"); + } + + @AfterClass + public static void restoreProperties() + { + if(origJettyBase != null) System.setProperty("jetty.base",origJettyBase); + if(origJettyHome != null) System.setProperty("jetty.home",origJettyHome); + if(origUserHome != null) System.setProperty("user.home",origUserHome); + if(origUserDir != null) System.setProperty("user.dir",origUserDir); + } + + @Parameter(0) + public String key; + + @Parameter(1) + public String path; + + private AttributeNormalizer normalizer; + + public AttributeNormalizerTest() throws MalformedURLException + { + normalizer = new AttributeNormalizer(Resource.newResource("/opt/jetty-distro/demo.base/webapps/root")); + } + + @Test + public void testEqual() + { + assertEquals("file:${" + key + "}",normalizer.normalize("file:" + path)); + } + + @Test + public void testEqualsSlash() + { + assertEquals("file:${" + key + "}",normalizer.normalize("file:" + path + "/")); + } + + @Test + public void testEqualsSlashFile() + { + assertEquals("file:${" + key + "}/file",normalizer.normalize("file:" + path + "/file")); + } + + @Test + public void testURIEquals() throws URISyntaxException + { + assertEquals("file:${" + key + "}",normalizer.normalize(new URI("file:" + path))); + } + + @Test + public void testURIEqualsSlash() throws URISyntaxException + { + assertEquals("file:${" + key + "}",normalizer.normalize(new URI("file:" + path + "/"))); + } + + @Test + public void testURIEqualsSlashFile() throws URISyntaxException + { + assertEquals("file:${" + key + "}/file",normalizer.normalize(new URI("file:" + path + "/file"))); + } + + @Test + public void testURLEquals() throws MalformedURLException + { + assertEquals("file:${" + key + "}",normalizer.normalize(new URL("file:" + path))); + } + + @Test + public void testURLEqualsSlash() throws MalformedURLException + { + assertEquals("file:${" + key + "}",normalizer.normalize(new URL("file:" + path + "/"))); + } + + @Test + public void testURLEqualsSlashFile() throws MalformedURLException + { + assertEquals("file:${" + key + "}/file",normalizer.normalize(new URL("file:" + path + "/file"))); + } + + @Test + public void testJarFileEquals_BangFile() + { + assertEquals("jar:file:${" + key + "}!/file",normalizer.normalize("jar:file:" + path + "!/file")); + } + + @Test + public void testJarFileEquals_SlashBangFile() + { + assertEquals("jar:file:${" + key + "}!/file",normalizer.normalize("jar:file:" + path + "/!/file")); + } + + @Test + public void testJarFileEquals_FileBangFile() + { + assertEquals("jar:file:${" + key + "}/file!/file",normalizer.normalize("jar:file:" + path + "/file!/file")); + } + + @Test + public void testJarFileEquals_URIBangFile() throws URISyntaxException + { + assertEquals("jar:file:${" + key + "}!/file",normalizer.normalize(new URI("jar:file:" + path + "!/file"))); + } + + @Test + public void testJarFileEquals_URISlashBangFile() throws URISyntaxException + { + assertEquals("jar:file:${" + key + "}!/file",normalizer.normalize(new URI("jar:file:" + path + "/!/file"))); + } + + @Test + public void testJarFileEquals_URIFileBangFile() throws URISyntaxException + { + assertEquals("jar:file:${" + key + "}/file!/file",normalizer.normalize(new URI("jar:file:" + path + "/file!/file"))); + } + + @Test + public void testJarFileEquals_URLBangFile() throws MalformedURLException + { + assertEquals("jar:file:${" + key + "}!/file",normalizer.normalize(new URL("jar:file:" + path + "!/file"))); + } + + @Test + public void testJarFileEquals_URLSlashBangFile() throws MalformedURLException + { + assertEquals("jar:file:${" + key + "}!/file",normalizer.normalize(new URL("jar:file:" + path + "/!/file"))); + } + + @Test + public void testJarFileEquals_URLFileBangFile() throws MalformedURLException + { + assertEquals("jar:file:${" + key + "}/file!/file",normalizer.normalize(new URL("jar:file:" + path + "/file!/file"))); + } +} diff --git a/tests/test-quickstart/src/test/java/org/eclipse/jetty/quickstart/QuickStartTest.java b/tests/test-quickstart/src/test/java/org/eclipse/jetty/quickstart/QuickStartTest.java index 54b0caa0314..5ce9c568943 100644 --- a/tests/test-quickstart/src/test/java/org/eclipse/jetty/quickstart/QuickStartTest.java +++ b/tests/test-quickstart/src/test/java/org/eclipse/jetty/quickstart/QuickStartTest.java @@ -21,10 +21,8 @@ package org.eclipse.jetty.quickstart; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -import java.io.File; import java.io.InputStream; import java.net.HttpURLConnection; -import java.net.URI; import java.net.URL; import org.eclipse.jetty.server.NetworkConnector; @@ -35,7 +33,6 @@ import org.eclipse.jetty.webapp.WebDescriptor; import org.eclipse.jetty.xml.XmlConfiguration; import org.eclipse.jetty.xml.XmlParser.Node; import org.hamcrest.Matchers; -import org.junit.Assert; import org.junit.Test; public class QuickStartTest @@ -163,7 +160,7 @@ public class QuickStartTest if (contextXml != null) { // System.err.println("Applying "+contextXml); - XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml.getURL()); + XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXml.getURI().toURL()); xmlConfiguration.configure(webapp); } @@ -179,73 +176,4 @@ public class QuickStartTest server.stop(); } - - @Test - public void testNormalize() throws Exception - { - String jetty_base=System.getProperty("jetty.base"); - String jetty_home=System.getProperty("jetty.home"); - String user_home=System.getProperty("user.home"); - String user_dir=System.getProperty("user.dir"); - try - { - System.setProperty("jetty.home","/opt/jetty-distro"); - System.setProperty("jetty.base","/opt/jetty-distro/demo.base"); - System.setProperty("user.home","/home/user"); - System.setProperty("user.dir","/etc/init.d"); - AttributeNormalizer normalizer = new AttributeNormalizer(Resource.newResource("/opt/jetty-distro/demo.base/webapps/root")); - - String[][] tests = { - { "WAR", "/opt/jetty-distro/demo.base/webapps/root" }, - { "jetty.home", "/opt/jetty-distro" }, - { "jetty.base", "/opt/jetty-distro/demo.base" }, - { "user.home", "/home/user" }, - { "user.dir", "/etc/init.d" }, - }; - - for (String[] test : tests) - { - Assert.assertEquals("file:${"+test[0]+"}",normalizer.normalize("file:"+test[1])); - Assert.assertEquals("file:${"+test[0]+"}",normalizer.normalize("file:"+test[1]+"/")); - Assert.assertEquals("file:${"+test[0]+"}/file",normalizer.normalize("file:"+test[1]+"/file")); - Assert.assertEquals("file:${"+test[0]+"}",normalizer.normalize(new URI("file:"+test[1]))); - Assert.assertEquals("file:${"+test[0]+"}",normalizer.normalize(new URI("file:"+test[1]+"/"))); - Assert.assertEquals("file:${"+test[0]+"}/file",normalizer.normalize(new URI("file:"+test[1]+"/file"))); - Assert.assertEquals("file:${"+test[0]+"}",normalizer.normalize(new URL("file:"+test[1]))); - Assert.assertEquals("file:${"+test[0]+"}",normalizer.normalize(new URL("file:"+test[1]+"/"))); - Assert.assertEquals("file:${"+test[0]+"}/file",normalizer.normalize(new URL("file:"+test[1]+"/file"))); - Assert.assertEquals("jar:file:${"+test[0]+"}!/file",normalizer.normalize("jar:file:"+test[1]+"!/file")); - Assert.assertEquals("jar:file:${"+test[0]+"}!/file",normalizer.normalize("jar:file:"+test[1]+"/!/file")); - Assert.assertEquals("jar:file:${"+test[0]+"}/file!/file",normalizer.normalize("jar:file:"+test[1]+"/file!/file")); - Assert.assertEquals("jar:file:${"+test[0]+"}!/file",normalizer.normalize(new URI("jar:file:"+test[1]+"!/file"))); - Assert.assertEquals("jar:file:${"+test[0]+"}!/file",normalizer.normalize(new URI("jar:file:"+test[1]+"/!/file"))); - Assert.assertEquals("jar:file:${"+test[0]+"}/file!/file",normalizer.normalize(new URI("jar:file:"+test[1]+"/file!/file"))); - Assert.assertEquals("jar:file:${"+test[0]+"}!/file",normalizer.normalize(new URL("jar:file:"+test[1]+"!/file"))); - Assert.assertEquals("jar:file:${"+test[0]+"}!/file",normalizer.normalize(new URL("jar:file:"+test[1]+"/!/file"))); - Assert.assertEquals("jar:file:${"+test[0]+"}/file!/file",normalizer.normalize(new URL("jar:file:"+test[1]+"/file!/file"))); - } - } - finally - { - if (user_dir==null) - System.clearProperty("user.dir"); - else - System.setProperty("user.dir",user_dir); - - if (user_home==null) - System.clearProperty("user.home"); - else - System.setProperty("user.home",user_home); - - if (jetty_home==null) - System.clearProperty("jetty.home"); - else - System.setProperty("jetty.home",jetty_home); - - if (jetty_base==null) - System.clearProperty("jetty.base"); - else - System.setProperty("jetty.base",jetty_base); - } - } }