From 12e480040aa80d22e9d4f0ba04ef83b641e70352 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 23 Jan 2013 14:45:44 +0000 Subject: [PATCH] 8006669: sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.sh fails on mac Reviewed-by: alanb --- .../https/HttpsURLConnection/PostThruProxy.java | 11 +++++------ .../HttpsURLConnection/PostThruProxyWithAuth.java | 14 ++++++-------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.java b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.java index a521db2911d..26c4f400b83 100644 --- a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.java +++ b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxy.java @@ -153,7 +153,7 @@ public class PostThruProxy { /* * setup up a proxy */ - setupProxy(); + SocketAddress pAddr = setupProxy(); /* * we want to avoid URLspoofCheck failures in cases where the cert @@ -163,7 +163,8 @@ public class PostThruProxy { new NameVerifier()); URL url = new URL("https://" + hostname+ ":" + serverPort); - HttpsURLConnection https = (HttpsURLConnection)url.openConnection(); + Proxy p = new Proxy(Proxy.Type.HTTP, pAddr); + HttpsURLConnection https = (HttpsURLConnection)url.openConnection(p); https.setDoOutput(true); https.setRequestMethod("POST"); PrintStream ps = null; @@ -200,14 +201,12 @@ public class PostThruProxy { } } - static void setupProxy() throws IOException { + static SocketAddress setupProxy() throws IOException { ProxyTunnelServer pserver = new ProxyTunnelServer(); // disable proxy authentication pserver.needUserAuth(false); pserver.start(); - System.setProperty("https.proxyHost", "localhost"); - System.setProperty("https.proxyPort", String.valueOf( - pserver.getPort())); + return new InetSocketAddress("localhost", pserver.getPort()); } } diff --git a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.java b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.java index a010be0630c..11fe859223c 100644 --- a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.java +++ b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/PostThruProxyWithAuth.java @@ -152,7 +152,7 @@ public class PostThruProxyWithAuth { /* * setup up a proxy */ - setupProxy(); + SocketAddress pAddr = setupProxy(); /* * we want to avoid URLspoofCheck failures in cases where the cert @@ -162,7 +162,8 @@ public class PostThruProxyWithAuth { new NameVerifier()); URL url = new URL("https://" + hostname + ":" + serverPort); - HttpsURLConnection https = (HttpsURLConnection)url.openConnection(); + Proxy p = new Proxy(Proxy.Type.HTTP, pAddr); + HttpsURLConnection https = (HttpsURLConnection)url.openConnection(p); https.setDoOutput(true); https.setRequestMethod("POST"); PrintStream ps = null; @@ -195,7 +196,7 @@ public class PostThruProxyWithAuth { } } - static void setupProxy() throws IOException { + static SocketAddress setupProxy() throws IOException { ProxyTunnelServer pserver = new ProxyTunnelServer(); /* @@ -209,9 +210,8 @@ public class PostThruProxyWithAuth { pserver.setUserAuth("Test", "test123"); pserver.start(); - System.setProperty("https.proxyHost", "localhost"); - System.setProperty("https.proxyPort", String.valueOf( - pserver.getPort())); + + return new InetSocketAddress("localhost", pserver.getPort()); } public static class TestAuthenticator extends Authenticator { @@ -220,6 +220,4 @@ public class PostThruProxyWithAuth { "test123".toCharArray()); } } - - }