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

Side by Side Diff: tests/standalone/io/secure_server_socket_test.dart

Issue 16021016: dart:io | Fix issue involving SecureServerSocket error handling and HttpServer stream cancellation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add tests for cancelOnError on SecureServerSocket. Created 7 years, 6 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
« no previous file with comments | « tests/standalone/io/raw_secure_server_socket_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 clientEndFuture.then((clientEnd) { 75 clientEndFuture.then((clientEnd) {
76 clientEnd.close(); 76 clientEnd.close();
77 serverEnd.close(); 77 serverEnd.close();
78 server.close(); 78 server.close();
79 port.close(); 79 port.close();
80 }); 80 });
81 }); 81 });
82 }); 82 });
83 } 83 }
84 84
85 void testSimpleConnectFail(String certificate) { 85 void testSimpleConnectFail(String certificate, bool cancelOnError) {
86 ReceivePort port = new ReceivePort(); 86 ReceivePort port = new ReceivePort();
87 SecureServerSocket.bind(HOST_NAME, 0, certificate).then((server) { 87 SecureServerSocket.bind(HOST_NAME, 0, certificate).then((server) {
88 var clientEndFuture = SecureSocket.connect(HOST_NAME, server.port) 88 var clientEndFuture = SecureSocket.connect(HOST_NAME, server.port)
89 .then((clientEnd) { 89 .then((clientEnd) {
90 Expect.fail("No client connection expected."); 90 Expect.fail("No client connection expected.");
91 }) 91 })
92 .catchError((error) { 92 .catchError((error) {
93 Expect.isTrue(error is SocketIOException); 93 Expect.isTrue(error is SocketIOException);
94 }); 94 });
95 server.listen((serverEnd) { 95 server.listen((serverEnd) {
96 Expect.fail("No server connection expected."); 96 Expect.fail("No server connection expected.");
97 }, 97 },
98 onError: (error) { 98 onError: (error) {
99 Expect.isTrue(error is SocketIOException); 99 Expect.isTrue(error is SocketIOException);
100 clientEndFuture.then((_) => port.close()); 100 clientEndFuture.then((_) {
101 }); 101 if (!cancelOnError) server.close();
102 port.close();
103 });
104 },
105 cancelOnError: cancelOnError);
102 }); 106 });
103 } 107 }
104 108
105 void testServerListenAfterConnect() { 109 void testServerListenAfterConnect() {
106 ReceivePort port = new ReceivePort(); 110 ReceivePort port = new ReceivePort();
107 SecureServerSocket.bind(HOST_NAME, 0, CERTIFICATE).then((server) { 111 SecureServerSocket.bind(HOST_NAME, 0, CERTIFICATE).then((server) {
108 Expect.isTrue(server.port > 0); 112 Expect.isTrue(server.port > 0);
109 var clientEndFuture = SecureSocket.connect(HOST_NAME, server.port); 113 var clientEndFuture = SecureSocket.connect(HOST_NAME, server.port);
110 new Timer(const Duration(milliseconds: 500), () { 114 new Timer(const Duration(milliseconds: 500), () {
111 server.listen((serverEnd) { 115 server.listen((serverEnd) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 main() { 195 main() {
192 Path scriptDir = new Path(new Options().script).directoryPath; 196 Path scriptDir = new Path(new Options().script).directoryPath;
193 Path certificateDatabase = scriptDir.append('pkcert'); 197 Path certificateDatabase = scriptDir.append('pkcert');
194 SecureSocket.initialize(database: certificateDatabase.toNativePath(), 198 SecureSocket.initialize(database: certificateDatabase.toNativePath(),
195 password: 'dartdart', 199 password: 'dartdart',
196 useBuiltinRoots: false); 200 useBuiltinRoots: false);
197 testSimpleBind(); 201 testSimpleBind();
198 testInvalidBind(); 202 testInvalidBind();
199 testSimpleConnect(CERTIFICATE); 203 testSimpleConnect(CERTIFICATE);
200 testSimpleConnect("CN=localhost"); 204 testSimpleConnect("CN=localhost");
201 testSimpleConnectFail("not_a_nickname"); 205 testSimpleConnectFail("not_a_nickname", false);
202 testSimpleConnectFail("CN=notARealDistinguishedName"); 206 testSimpleConnectFail("CN=notARealDistinguishedName", false);
207 testSimpleConnectFail("not_a_nickname", true);
208 testSimpleConnectFail("CN=notARealDistinguishedName", true);
203 testServerListenAfterConnect(); 209 testServerListenAfterConnect();
204 testSimpleReadWrite(); 210 testSimpleReadWrite();
205 } 211 }
OLDNEW
« no previous file with comments | « tests/standalone/io/raw_secure_server_socket_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698