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

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

Issue 20316002: dart:io | Fix handling of exceptions from onBadCertificate callback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: try again Created 7 years, 5 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
Index: tests/standalone/io/secure_socket_bad_certificate_test.dart
diff --git a/tests/standalone/io/secure_socket_bad_certificate_test.dart b/tests/standalone/io/secure_socket_bad_certificate_test.dart
deleted file mode 100644
index 5edba315f38835fe8cd3dd680b8c7c6d87a675cf..0000000000000000000000000000000000000000
--- a/tests/standalone/io/secure_socket_bad_certificate_test.dart
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// 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.
-//
-// VMOptions=
-// VMOptions=--short_socket_read
-// VMOptions=--short_socket_write
-// VMOptions=--short_socket_write --short_socket_read
-// The --short_socket_write option does not work with external server
-// www.google.dk. Add this to the test when we have secure server sockets.
-// See TODO below.
-
-import "package:expect/expect.dart";
-import "dart:async";
-import "dart:isolate";
-import "dart:io";
-
-void main() {
- ReceivePort keepAlive = new ReceivePort();
- SecureSocket.initialize(useBuiltinRoots: false);
- testCertificateCallback(host: "www.google.com",
- acceptCertificate: false)
- .then((_) =>
- testCertificateCallback(host: "www.google.com",
- acceptCertificate: true))
- .then((_) =>
- keepAlive.close());
-}
-
-Future testCertificateCallback({String host, bool acceptCertificate}) {
- var x = 7;
- Expect.throws(() => SecureSocket.connect(host, 443, onBadCertificate: x),
- (e) => e is ArgumentError || e is TypeError);
-
- bool badCertificateCallback(X509Certificate certificate) {
- Expect.isTrue(certificate.subject.contains("O=Google Inc"));
- Expect.isTrue(certificate.startValidity.isBefore(new DateTime.now()));
- Expect.isTrue(certificate.endValidity.isAfter(new DateTime.now()));
- return acceptCertificate;
- };
-
- return SecureSocket.connect(host,
- 443,
- onBadCertificate: badCertificateCallback)
- .then((socket) {
- Expect.isTrue(acceptCertificate);
- socket.write("GET / HTTP/1.0\r\nHost: $host\r\n\r\n");
- socket.close();
- return socket.fold(<int>[], (message, data) => message..addAll(data))
- .then((message) {
- String received = new String.fromCharCodes(message);
- Expect.isTrue(received.startsWith('HTTP/1.0 '));
- });
- }).catchError((e) {
- if (e is HandshakeException) {
- Expect.isFalse(acceptCertificate);
- } else {
- Expect.isTrue(e is SocketException);
- }
- });
-}
« no previous file with comments | « tests/standalone/io/secure_server_socket_test.dart ('k') | tests/standalone/io/secure_socket_renegotiate_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698