summaryrefslogtreecommitdiffstats
path: root/luni
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2015-07-17 10:09:34 +0100
committerNeil Fuller <nfuller@google.com>2015-07-17 11:16:30 +0100
commit11c3934f61c6c873fd9caae16947285bc0068965 (patch)
treeeff2a43f5d7854d2ef78029bbe97ae5c8588f8b1 /luni
parent2cc187049ed0a5fc6168ffdb8f837b59462e5b53 (diff)
downloadlibcore-11c3934f61c6c873fd9caae16947285bc0068965.zip
libcore-11c3934f61c6c873fd9caae16947285bc0068965.tar.gz
libcore-11c3934f61c6c873fd9caae16947285bc0068965.tar.bz2
Revert "Changes associated with an OkHttp bad proxy response fix"
This reverts commit 467a6809cd31cbfa94c326415ff3c441d9b1e8be. commit 467a6809cd31cbfa94c326415ff3c441d9b1e8be is present in lollipop-cts-dev but not lollipop-release. This causes the tests to fail when run against a lollipop-release build. DO NOT MERGE ANYWHERE Bug: 22546532 Change-Id: I4582824e94679213f27352e18e7d9bb985954909
Diffstat (limited to 'luni')
-rw-r--r--luni/src/test/java/libcore/java/net/URLConnectionTest.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/luni/src/test/java/libcore/java/net/URLConnectionTest.java b/luni/src/test/java/libcore/java/net/URLConnectionTest.java
index b672b19..f438d1b 100644
--- a/luni/src/test/java/libcore/java/net/URLConnectionTest.java
+++ b/luni/src/test/java/libcore/java/net/URLConnectionTest.java
@@ -641,32 +641,42 @@ public final class URLConnectionTest extends AbstractResourceLeakageDetectorTest
* Tolerate bad https proxy response when using HttpResponseCache. http://b/6754912
*/
public void testConnectViaHttpProxyToHttpsUsingBadProxyAndHttpResponseCache() throws Exception {
+ ProxyConfig proxyConfig = ProxyConfig.PROXY_SYSTEM_PROPERTY;
+
TestSSLContext testSSLContext = TestSSLContext.create();
initResponseCache();
server.useHttps(testSSLContext.serverContext.getSocketFactory(), true);
-
- // The inclusion of a body in the response to the CONNECT is key to reproducing b/6754912.
MockResponse badProxyResponse = new MockResponse()
.setSocketPolicy(SocketPolicy.UPGRADE_TO_SSL_AT_END)
.clearHeaders()
- .setBody("bogus proxy connect response content");
+ .setBody("bogus proxy connect response content"); // Key to reproducing b/6754912
+ // We enqueue the bad response twice because the connection will
+ // be retried with TLS_MODE_COMPATIBLE after the first connection
+ // fails.
+ server.enqueue(badProxyResponse);
server.enqueue(badProxyResponse);
- server.enqueue(new MockResponse().setBody("response"));
server.play();
URL url = new URL("https://android.com/foo");
- ProxyConfig proxyConfig = ProxyConfig.PROXY_SYSTEM_PROPERTY;
HttpsURLConnection connection = (HttpsURLConnection) proxyConfig.connect(server, url);
connection.setSSLSocketFactory(testSSLContext.clientContext.getSocketFactory());
- connection.setHostnameVerifier(new RecordingHostnameVerifier());
- assertContent("response", connection);
+
+ try {
+ connection.connect();
+ fail();
+ } catch (SSLHandshakeException expected) {
+ // Thrown when the connect causes SSLSocket.startHandshake() to throw
+ // when it sees the "bogus proxy connect response content"
+ // instead of a ServerHello handshake message.
+ }
RecordedRequest connect = server.takeRequest();
- assertEquals("CONNECT android.com:443 HTTP/1.1", connect.getRequestLine());
+ assertEquals("Connect line failure on proxy",
+ "CONNECT android.com:443 HTTP/1.1", connect.getRequestLine());
assertContains(connect.getHeaders(), "Host: android.com");
}