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

Side by Side Diff: tests/standalone/io/raw_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
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 clientEndFuture.then((clientEnd) { 76 clientEndFuture.then((clientEnd) {
77 clientEnd.shutdown(SocketDirection.SEND); 77 clientEnd.shutdown(SocketDirection.SEND);
78 serverEnd.shutdown(SocketDirection.SEND); 78 serverEnd.shutdown(SocketDirection.SEND);
79 server.close(); 79 server.close();
80 port.close(); 80 port.close();
81 }); 81 });
82 }); 82 });
83 }); 83 });
84 } 84 }
85 85
86 void testSimpleConnectFail(String certificate) { 86 void testSimpleConnectFail(String certificate, bool cancelOnError) {
87 ReceivePort port = new ReceivePort(); 87 ReceivePort port = new ReceivePort();
88 RawSecureServerSocket.bind(HOST_NAME, 0, certificate).then((server) { 88 RawSecureServerSocket.bind(HOST_NAME, 0, certificate).then((server) {
89 var clientEndFuture = RawSecureSocket.connect(HOST_NAME, server.port) 89 var clientEndFuture = RawSecureSocket.connect(HOST_NAME, server.port)
90 .then((clientEnd) { 90 .then((clientEnd) {
91 Expect.fail("No client connection expected."); 91 Expect.fail("No client connection expected.");
92 }) 92 })
93 .catchError((error) { 93 .catchError((error) {
94 Expect.isTrue(error is SocketIOException); 94 Expect.isTrue(error is SocketIOException);
95 }); 95 });
96 server.listen((serverEnd) { 96 server.listen((serverEnd) {
97 Expect.fail("No server connection expected."); 97 Expect.fail("No server connection expected.");
98 }, 98 },
99 onError: (error) { 99 onError: (error) {
100 Expect.isTrue(error is SocketIOException); 100 Expect.isTrue(error is SocketIOException);
101 clientEndFuture.then((_) => port.close()); 101 clientEndFuture.then((_) {
102 }); 102 if (!cancelOnError) server.close();
103 port.close();
104 });
105 },
106 cancelOnError: cancelOnError);
103 }); 107 });
104 } 108 }
105 109
106 void testServerListenAfterConnect() { 110 void testServerListenAfterConnect() {
107 ReceivePort port = new ReceivePort(); 111 ReceivePort port = new ReceivePort();
108 RawSecureServerSocket.bind(HOST_NAME, 0, CERTIFICATE).then((server) { 112 RawSecureServerSocket.bind(HOST_NAME, 0, CERTIFICATE).then((server) {
109 Expect.isTrue(server.port > 0); 113 Expect.isTrue(server.port > 0);
110 var clientEndFuture = RawSecureSocket.connect(HOST_NAME, server.port); 114 var clientEndFuture = RawSecureSocket.connect(HOST_NAME, server.port);
111 new Timer(const Duration(milliseconds: 500), () { 115 new Timer(const Duration(milliseconds: 500), () {
112 server.listen((serverEnd) { 116 server.listen((serverEnd) {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 main() { 442 main() {
439 Path scriptDir = new Path(new Options().script).directoryPath; 443 Path scriptDir = new Path(new Options().script).directoryPath;
440 Path certificateDatabase = scriptDir.append('pkcert'); 444 Path certificateDatabase = scriptDir.append('pkcert');
441 SecureSocket.initialize(database: certificateDatabase.toNativePath(), 445 SecureSocket.initialize(database: certificateDatabase.toNativePath(),
442 password: 'dartdart', 446 password: 'dartdart',
443 useBuiltinRoots: false); 447 useBuiltinRoots: false);
444 testSimpleBind(); 448 testSimpleBind();
445 testInvalidBind(); 449 testInvalidBind();
446 testSimpleConnect(CERTIFICATE); 450 testSimpleConnect(CERTIFICATE);
447 testSimpleConnect("CN=localhost"); 451 testSimpleConnect("CN=localhost");
448 testSimpleConnectFail("not_a_nickname"); 452 testSimpleConnectFail("not_a_nickname", false);
449 testSimpleConnectFail("CN=notARealDistinguishedName"); 453 testSimpleConnectFail("CN=notARealDistinguishedName", false);
454 testSimpleConnectFail("not_a_nickname", true);
455 testSimpleConnectFail("CN=notARealDistinguishedName", true);
450 testServerListenAfterConnect(); 456 testServerListenAfterConnect();
451 testSimpleReadWrite(true, true, false); 457 testSimpleReadWrite(true, true, false);
452 testSimpleReadWrite(true, false, false); 458 testSimpleReadWrite(true, false, false);
453 testSimpleReadWrite(false, true, false); 459 testSimpleReadWrite(false, true, false);
454 testSimpleReadWrite(false, false, false); 460 testSimpleReadWrite(false, false, false);
455 testSimpleReadWrite(false, false, true, true); 461 testSimpleReadWrite(false, false, true, true);
456 testSimpleReadWrite(false, false, true, false); 462 testSimpleReadWrite(false, false, true, false);
457 } 463 }
OLDNEW
« no previous file with comments | « sdk/lib/io/secure_server_socket.dart ('k') | tests/standalone/io/secure_server_socket_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698