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

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

Issue 11308271: Add built-in root certificates to dart:io SecureSocket. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
Index: tests/standalone/io/secure_builtin_roots_test.dart
diff --git a/tests/standalone/io/https_client_test.dart b/tests/standalone/io/secure_builtin_roots_test.dart
similarity index 51%
copy from tests/standalone/io/https_client_test.dart
copy to tests/standalone/io/secure_builtin_roots_test.dart
index d639426a896dd365ede75f3fc8497700457c22f6..2077d691457bc0217ddc6bc29fdfc6ef438b1e13 100644
--- a/tests/standalone/io/https_client_test.dart
+++ b/tests/standalone/io/secure_builtin_roots_test.dart
@@ -6,8 +6,6 @@ import "dart:io";
import "dart:uri";
import "dart:isolate";
-
-int testGoogleUrlCount = 0;
void testGoogleUrl() {
HttpClient client = new HttpClient();
@@ -19,48 +17,30 @@ void testGoogleUrl() {
request.outputStream.close();
};
conn.onResponse = (HttpClientResponse response) {
- testGoogleUrlCount++;
Expect.isTrue(response.statusCode < 500);
- if (requestUri.path.length == 0) {
- Expect.isTrue(response.statusCode != 404);
- }
+ Expect.isTrue(response.statusCode != 404);
response.inputStream.onData = () {
response.inputStream.read();
};
response.inputStream.onClosed = () {
- if (testGoogleUrlCount == 4) client.shutdown();
+ client.shutdown();
};
};
conn.onError = (error) => Expect.fail("Unexpected IO error $error");
}
- 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.getUrl(
- new Uri.fromString("https://some.bad.host.name.7654321/"));
- connection.onRequest = (HttpClientRequest request) {
- Expect.fail("Should not open a request on bad hostname");
- };
- ReceivePort port = new ReceivePort();
- connection.onError = (Exception error) {
- port.close(); // We expect onError to be called, due to bad host name.
- };
+ testUrl('https://www.google.com');
}
void InitializeSSL() {
- var testPkcertDatabase =
- new Path.fromNative(new Options().script).directoryPath.append('pkcert/');
+ // The pkcert_empty database contains no certificates, so the built-in roots
+ // must be loaded correctly for the secure connection to work.
+ var testPkcertDatabase = new Path.fromNative(new Options().script).
+ directoryPath.append('pkcert_empty');
SecureSocket.setCertificateDatabase(testPkcertDatabase.toNativePath());
Mads Ager (google) 2012/11/29 20:13:05 This is where it would be nice to just call Secure
Bill Hesse 2012/11/30 12:51:16 Done.
}
void main() {
InitializeSSL();
testGoogleUrl();
- testBadHostName();
}

Powered by Google App Engine
This is Rietveld 408576698