Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1340)

Unified Diff: tests/standalone/io/http_proxy_test.dart

Issue 12866005: Add a function for finding the HTTP proxy server from environment variables (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/standalone/io/http_proxy_configuration_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/http_proxy_test.dart
diff --git a/tests/standalone/io/http_proxy_test.dart b/tests/standalone/io/http_proxy_test.dart
index dd87619910666171b48d39a23d3bdd06c79814ac..945189d7198dcab7d8b37574d5ee21094d982c1b 100644
--- a/tests/standalone/io/http_proxy_test.dart
+++ b/tests/standalone/io/http_proxy_test.dart
@@ -232,6 +232,7 @@ void testProxy() {
testProxyDoneCount++;
if (testProxyDoneCount == proxy.length * 2) {
Expect.equals(proxy.length, server.requestCount);
+ Expect.equals(proxy.length, secureServer.requestCount);
proxyServer.shutdown();
server.shutdown();
secureServer.shutdown();
@@ -311,6 +312,56 @@ void testProxyChain() {
});
}
+int testProxyFromEnviromentDoneCount = 0;
+void testProxyFromEnviroment() {
+ setupProxyServer().then((proxyServer) {
+ setupServer(1).then((server) {
+ setupServer(1, secure: true).then((secureServer) {
+ HttpClient client = new HttpClient();
+
+ client.findProxy = (Uri uri) {
+ return HttpClient.findProxyFromEnvironment(
+ uri,
+ environment: {"http_proxy": "localhost:${proxyServer.port}",
+ "https_proxy": "localhost:${proxyServer.port}"});
+ };
+
+ const int loopCount = 5;
+ for (int i = 0; i < loopCount; i++) {
+ test(bool secure) {
+ String url = secure
+ ? "https://localhost:${secureServer.port}/$i"
+ : "http://127.0.0.1:${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: () {
+ testProxyFromEnviromentDoneCount++;
+ if (testProxyFromEnviromentDoneCount == loopCount * 2) {
+ Expect.equals(loopCount, server.requestCount);
+ Expect.equals(loopCount, secureServer.requestCount);
+ proxyServer.shutdown();
+ server.shutdown();
+ secureServer.shutdown();
+ client.close();
+ }
+ });
+ });
+ }
+
+ test(false);
+ test(true);
+ }
+ });
+ });
+ });
+}
+
int testRealProxyDoneCount = 0;
void testRealProxy() {
setupServer(1).then((server) {
@@ -363,6 +414,7 @@ main() {
testDirectProxy();
testProxy();
testProxyChain();
+ testProxyFromEnviroment();
// This test is not normally run. It can be used for locally testing
// with a real proxy server (e.g. Apache).
//testRealProxy();
« no previous file with comments | « tests/standalone/io/http_proxy_configuration_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698