| Index: tests/standalone/io/http_proxy_advanced_test.dart
|
| diff --git a/tests/standalone/io/http_proxy_test.dart b/tests/standalone/io/http_proxy_advanced_test.dart
|
| similarity index 74%
|
| copy from tests/standalone/io/http_proxy_test.dart
|
| copy to tests/standalone/io/http_proxy_advanced_test.dart
|
| index 9b8803b7c91150ca0cbef0aa0e2d49a7f5196af4..1e89f4f7eaab47a62cdf3cd026dcac6bcdc85bb9 100644
|
| --- a/tests/standalone/io/http_proxy_test.dart
|
| +++ b/tests/standalone/io/http_proxy_advanced_test.dart
|
| @@ -284,128 +284,6 @@ Future<ProxyServer> setupProxyServer({ipV6: false}) {
|
| return proxyServer.start();
|
| }
|
|
|
| -testInvalidProxy() {
|
| - HttpClient client = new HttpClient();
|
| -
|
| - client.findProxy = (Uri uri) => "";
|
| - client.getUrl(Uri.parse("http://www.google.com/test"))
|
| - .catchError((error) {}, test: (e) => e is HttpException);
|
| -
|
| - client.findProxy = (Uri uri) => "XXX";
|
| - client.getUrl(Uri.parse("http://www.google.com/test"))
|
| - .catchError((error) {}, test: (e) => e is HttpException);
|
| -
|
| - client.findProxy = (Uri uri) => "PROXY www.google.com";
|
| - client.getUrl(Uri.parse("http://www.google.com/test"))
|
| - .catchError((error) {}, test: (e) => e is HttpException);
|
| -
|
| - client.findProxy = (Uri uri) => "PROXY www.google.com:http";
|
| - client.getUrl(Uri.parse("http://www.google.com/test"))
|
| - .catchError((error) {}, test: (e) => e is HttpException);
|
| -}
|
| -
|
| -int testDirectDoneCount = 0;
|
| -void testDirectProxy() {
|
| - setupServer(0).then((server) {
|
| - HttpClient client = new HttpClient();
|
| - List<String> proxy =
|
| - ["DIRECT", " DIRECT ", "DIRECT ;", " DIRECT ; ",
|
| - ";DIRECT", " ; DIRECT ", ";;DIRECT;;"];
|
| -
|
| - client.findProxy = (Uri uri) {
|
| - int index = int.parse(uri.path.substring(1));
|
| - return proxy[index];
|
| - };
|
| -
|
| - for (int i = 0; i < proxy.length; i++) {
|
| - client.getUrl(Uri.parse("http://localhost:${server.port}/$i"))
|
| - .then((HttpClientRequest clientRequest) {
|
| - String content = "$i$i$i";
|
| - clientRequest.contentLength = content.length;
|
| - clientRequest.write(content);
|
| - return clientRequest.close();
|
| - })
|
| - .then((HttpClientResponse response) {
|
| - response.listen((_) {}, onDone: () {
|
| - testDirectDoneCount++;
|
| - if (testDirectDoneCount == proxy.length) {
|
| - Expect.equals(proxy.length, server.requestCount);
|
| - server.shutdown();
|
| - client.close();
|
| - }
|
| - });
|
| - });
|
| - }
|
| - });
|
| -}
|
| -
|
| -int testProxyDoneCount = 0;
|
| -void testProxy() {
|
| - setupProxyServer().then((proxyServer) {
|
| - setupServer(1, directRequestPaths: ["/4"]).then((server) {
|
| - setupServer(1, directRequestPaths: ["/4"], secure: true).then((secureServer) {
|
| - HttpClient client = new HttpClient(context: clientContext);
|
| -
|
| - List<String> proxy;
|
| - if (Platform.operatingSystem == "windows") {
|
| - proxy =
|
| - ["PROXY localhost:${proxyServer.port}",
|
| - "PROXY localhost:${proxyServer.port}; PROXY hede.hule.hest:8080",
|
| - "PROXY localhost:${proxyServer.port}",
|
| - ""
|
| - " PROXY localhost:${proxyServer.port}",
|
| - "DIRECT",
|
| - "PROXY localhost:${proxyServer.port}; DIRECT"];
|
| - } else {
|
| - proxy =
|
| - ["PROXY localhost:${proxyServer.port}",
|
| - "PROXY localhost:${proxyServer.port}; PROXY hede.hule.hest:8080",
|
| - "PROXY hede.hule.hest:8080; PROXY localhost:${proxyServer.port}",
|
| - "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181;"
|
| - " PROXY localhost:${proxyServer.port}",
|
| - "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181; DIRECT",
|
| - "PROXY localhost:${proxyServer.port}; DIRECT"];
|
| - }
|
| - client.findProxy = (Uri uri) {
|
| - // Pick the proxy configuration based on the request path.
|
| - int index = int.parse(uri.path.substring(1));
|
| - return proxy[index];
|
| - };
|
| -
|
| - for (int i = 0; i < proxy.length; i++) {
|
| - test(bool secure) {
|
| - String url = secure
|
| - ? "https://localhost:${secureServer.port}/$i"
|
| - : "http://localhost:${server.port}/$i";
|
| -
|
| - client.postUrl(Uri.parse(url))
|
| - .then((HttpClientRequest clientRequest) {
|
| - String content = "$i$i$i";
|
| - clientRequest.write(content);
|
| - return clientRequest.close();
|
| - })
|
| - .then((HttpClientResponse response) {
|
| - response.listen((_) {}, onDone: () {
|
| - testProxyDoneCount++;
|
| - if (testProxyDoneCount == proxy.length * 2) {
|
| - Expect.equals(proxy.length, server.requestCount);
|
| - Expect.equals(proxy.length, secureServer.requestCount);
|
| - proxyServer.shutdown();
|
| - server.shutdown();
|
| - secureServer.shutdown();
|
| - client.close();
|
| - }
|
| - });
|
| - });
|
| - }
|
| -
|
| - test(false);
|
| - test(true);
|
| - }
|
| - });
|
| - });
|
| - });
|
| -}
|
|
|
| int testProxyIPV6DoneCount = 0;
|
| void testProxyIPV6() {
|
| @@ -456,67 +334,6 @@ void testProxyIPV6() {
|
| });
|
| }
|
|
|
| -int testProxyChainDoneCount = 0;
|
| -void testProxyChain() {
|
| - // Setup two proxy servers having the first using the second as its proxy.
|
| - setupProxyServer().then((proxyServer1) {
|
| - setupProxyServer().then((proxyServer2) {
|
| - proxyServer1.client.findProxy = (_) => "PROXY localhost:${proxyServer2.port}";
|
| -
|
| - setupServer(2, directRequestPaths: ["/4"]).then((server) {
|
| - HttpClient client = new HttpClient();
|
| -
|
| - List<String> proxy;
|
| - if (Platform.operatingSystem == "windows") {
|
| - proxy =
|
| - ["PROXY localhost:${proxyServer1.port}",
|
| - "PROXY localhost:${proxyServer1.port}; PROXY hede.hule.hest:8080",
|
| - "PROXY localhost:${proxyServer1.port}",
|
| - "PROXY localhost:${proxyServer1.port}",
|
| - "DIRECT",
|
| - "PROXY localhost:${proxyServer1.port}; DIRECT"];
|
| - } else {
|
| - proxy =
|
| - ["PROXY localhost:${proxyServer1.port}",
|
| - "PROXY localhost:${proxyServer1.port}; PROXY hede.hule.hest:8080",
|
| - "PROXY hede.hule.hest:8080; PROXY localhost:${proxyServer1.port}",
|
| - "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181;"
|
| - " PROXY localhost:${proxyServer1.port}",
|
| - "PROXY hede.hule.hest:8080; PROXY hede.hule.hest:8181; DIRECT",
|
| - "PROXY localhost:${proxyServer1.port}; DIRECT"];
|
| - }
|
| -
|
| - client.findProxy = (Uri uri) {
|
| - // Pick the proxy configuration based on the request path.
|
| - int index = int.parse(uri.path.substring(1));
|
| - return proxy[index];
|
| - };
|
| -
|
| - for (int i = 0; i < proxy.length; i++) {
|
| - client.getUrl(Uri.parse("http://localhost:${server.port}/$i"))
|
| - .then((HttpClientRequest clientRequest) {
|
| - String content = "$i$i$i";
|
| - clientRequest.contentLength = content.length;
|
| - clientRequest.write(content);
|
| - return clientRequest.close();
|
| - })
|
| - .then((HttpClientResponse response) {
|
| - response.listen((_) {}, onDone: () {
|
| - testProxyChainDoneCount++;
|
| - if (testProxyChainDoneCount == proxy.length) {
|
| - Expect.equals(proxy.length, server.requestCount);
|
| - proxyServer1.shutdown();
|
| - proxyServer2.shutdown();
|
| - server.shutdown();
|
| - client.close();
|
| - }
|
| - });
|
| - });
|
| - }
|
| - });
|
| - });
|
| - });
|
| -}
|
|
|
| int testProxyFromEnviromentDoneCount = 0;
|
| void testProxyFromEnviroment() {
|
| @@ -805,18 +622,12 @@ void testRealProxyAuth() {
|
| }
|
|
|
| main() {
|
| - testInvalidProxy();
|
| - testDirectProxy();
|
| - testProxy();
|
| - // testProxyIPV6(); // TODO(24074): Move failing tests to separate files.
|
| - testProxyChain();
|
| - // TODO(24074): Move failing tests to separate files.
|
| - // testProxyFromEnviroment();
|
| - // The two invocations of uses the same global variable for state -
|
| + testProxyIPV6();
|
| + testProxyFromEnviroment();
|
| + // The two invocations use the same global variable for state -
|
| // run one after the other.
|
| - // TODO(24074): Move failing tests to separate files.
|
| - // testProxyAuthenticate(false)
|
| - // .then((_) => testProxyAuthenticate(true));
|
| + testProxyAuthenticate(false)
|
| + .then((_) => testProxyAuthenticate(true));
|
|
|
| // This test is not normally run. It can be used for locally testing
|
| // with a real proxy server (e.g. Apache).
|
|
|