summaryrefslogtreecommitdiffstats
path: root/luni
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2015-08-04 07:57:30 +0000
committerandroid-build-merger <android-build-merger@google.com>2015-08-04 07:57:30 +0000
commit8426987be01baeb67aa8f49a25a3ac56e1c4102a (patch)
treebe66077ab77eae8561eabffc0ba4c78c2b288739 /luni
parent89ebe31d361ee423ae49b54f910eefad0c27675d (diff)
parent34d183b404333627266d568e905a60e2be3a06f3 (diff)
downloadlibcore-8426987be01baeb67aa8f49a25a3ac56e1c4102a.zip
libcore-8426987be01baeb67aa8f49a25a3ac56e1c4102a.tar.gz
libcore-8426987be01baeb67aa8f49a25a3ac56e1c4102a.tar.bz2
Merge "Revert "Changes associated with an OkHttp bad proxy response fix"" into lollipop-cts-dev
automerge: 34d183b * commit '34d183b404333627266d568e905a60e2be3a06f3': Revert "Changes associated with an OkHttp bad proxy response fix"
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 c09939f..f664b08 100644
--- a/luni/src/test/java/libcore/java/net/URLConnectionTest.java
+++ b/luni/src/test/java/libcore/java/net/URLConnectionTest.java
@@ -642,32 +642,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");
}