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

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

Issue 11299210: Add support for https scheme in dart:io HttpClient. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 1 month 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
« sdk/lib/io/http_impl.dart ('K') | « sdk/lib/io/http_impl.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/https_client_test.dart
diff --git a/tests/standalone/io/http_client_test.dart b/tests/standalone/io/https_client_test.dart
similarity index 55%
copy from tests/standalone/io/http_client_test.dart
copy to tests/standalone/io/https_client_test.dart
index 6c3c54976d9cae128f298be66c14f65dc32ea6a8..d639426a896dd365ede75f3fc8497700457c22f6 100644
--- a/tests/standalone/io/http_client_test.dart
+++ b/tests/standalone/io/https_client_test.dart
@@ -2,28 +2,10 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-#import("dart:io");
-#import("dart:uri");
-#import("dart:isolate");
+import "dart:io";
+import "dart:uri";
+import "dart:isolate";
-void testGoogle() {
- HttpClient client = new HttpClient();
- var conn = client.get('www.google.com', 80, '/');
-
- conn.onRequest = (HttpClientRequest request) {
- request.outputStream.close();
- };
- conn.onResponse = (HttpClientResponse response) {
- Expect.isTrue(response.statusCode < 500);
- response.inputStream.onData = () {
- response.inputStream.read();
- };
- response.inputStream.onClosed = () {
- client.shutdown();
- };
- };
- conn.onError = (error) => Expect.fail("Unexpected IO error");
-}
int testGoogleUrlCount = 0;
void testGoogleUrl() {
@@ -46,29 +28,22 @@ void testGoogleUrl() {
response.inputStream.read();
};
response.inputStream.onClosed = () {
- if (testGoogleUrlCount == 5) client.shutdown();
+ if (testGoogleUrlCount == 4) client.shutdown();
};
};
conn.onError = (error) => Expect.fail("Unexpected IO error $error");
}
- testUrl('http://www.google.com');
- testUrl('http://www.google.com/abc');
- testUrl('http://www.google.com/?abc');
- testUrl('http://www.google.com/abc?abc');
- testUrl('http://www.google.com/abc?abc#abc');
-}
-
-void testInvalidUrl() {
- HttpClient client = new HttpClient();
- Expect.throws(
- () => client.getUrl(new Uri.fromString('ftp://www.google.com')));
+ testUrl('https://www.google.dk');
+ testUrl('https://www.google.dk');
+ testUrl('https://www.google.dk/#q=foo');
+ testUrl('https://www.google.dk/#hl=da&q=foo');
}
void testBadHostName() {
HttpClient client = new HttpClient();
- HttpClientConnection connection =
- client.get("some.bad.host.name.7654321", 0, "/");
+ HttpClientConnection connection = client.getUrl(
+ new Uri.fromString("https://some.bad.host.name.7654321/"));
connection.onRequest = (HttpClientRequest request) {
Expect.fail("Should not open a request on bad hostname");
};
@@ -78,9 +53,14 @@ void testBadHostName() {
};
}
+void InitializeSSL() {
+ var testPkcertDatabase =
+ new Path.fromNative(new Options().script).directoryPath.append('pkcert/');
+ SecureSocket.setCertificateDatabase(testPkcertDatabase.toNativePath());
+}
+
void main() {
- testGoogle();
+ InitializeSSL();
testGoogleUrl();
- testInvalidUrl();
testBadHostName();
}
« sdk/lib/io/http_impl.dart ('K') | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698