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

Side by Side Diff: tests/standalone/io/secure_server_socket_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, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 78
79 void testSimpleConnectFail(String certificate, bool cancelOnError) { 79 void testSimpleConnectFail(String certificate, bool cancelOnError) {
80 ReceivePort port = new ReceivePort(); 80 ReceivePort port = new ReceivePort();
81 SecureServerSocket.bind(HOST_NAME, 0, certificate).then((server) { 81 SecureServerSocket.bind(HOST_NAME, 0, certificate).then((server) {
82 var clientEndFuture = SecureSocket.connect(HOST_NAME, server.port) 82 var clientEndFuture = SecureSocket.connect(HOST_NAME, server.port)
83 .then((clientEnd) { 83 .then((clientEnd) {
84 Expect.fail("No client connection expected."); 84 Expect.fail("No client connection expected.");
85 }) 85 })
86 .catchError((error) { 86 .catchError((error) {
87 Expect.isTrue(error is HandshakeException); 87 Expect.isTrue(error is HandshakeException ||
88 error is SocketException);
88 }); 89 });
89 server.listen((serverEnd) { 90 server.listen((serverEnd) {
90 Expect.fail("No server connection expected."); 91 Expect.fail("No server connection expected.");
91 }, 92 },
92 onError: (error) { 93 onError: (error) {
93 Expect.isTrue(error is CertificateException); 94 Expect.isTrue(error is CertificateException);
94 clientEndFuture.then((_) { 95 clientEndFuture.then((_) {
95 if (!cancelOnError) server.close(); 96 if (!cancelOnError) server.close();
96 port.close(); 97 port.close();
97 }); 98 });
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 testInvalidBind(); 196 testInvalidBind();
196 testSimpleConnect(CERTIFICATE); 197 testSimpleConnect(CERTIFICATE);
197 testSimpleConnect("CN=localhost"); 198 testSimpleConnect("CN=localhost");
198 testSimpleConnectFail("not_a_nickname", false); 199 testSimpleConnectFail("not_a_nickname", false);
199 testSimpleConnectFail("CN=notARealDistinguishedName", false); 200 testSimpleConnectFail("CN=notARealDistinguishedName", false);
200 testSimpleConnectFail("not_a_nickname", true); 201 testSimpleConnectFail("not_a_nickname", true);
201 testSimpleConnectFail("CN=notARealDistinguishedName", true); 202 testSimpleConnectFail("CN=notARealDistinguishedName", true);
202 testServerListenAfterConnect(); 203 testServerListenAfterConnect();
203 testSimpleReadWrite(); 204 testSimpleReadWrite();
204 } 205 }
OLDNEW
« no previous file with comments | « tests/standalone/io/secure_bad_certificate_test.dart ('k') | tests/standalone/io/secure_socket_bad_certificate_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698