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

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

Issue 23189002: dart:io | Add test for HttpClient requests that never complete their future. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add suppressions and issue number in standalone.status. 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
« no previous file with comments | « tests/standalone/io/secure_unauthorized_client.dart ('k') | tests/standalone/standalone.status » ('j') | 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 // This test verifies that the bad certificate callback works. 5 // This test verifies that failing secure connection attempts always complete
6 // their returned future.
6 7
7 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
8 import "package:path/path.dart"; 9 import "package:path/path.dart";
9 import "dart:async"; 10 import "dart:async";
10 import "dart:io"; 11 import "dart:io";
11 12
12 const HOST_NAME = "localhost"; 13 const HOST_NAME = "localhost";
13 const CERTIFICATE = "localhost_cert"; 14 const CERTIFICATE = "localhost_cert";
14 15
15
16 String certificateDatabase() =>
17 join(dirname(new Options().script), 'pkcert');
18
19 Future<SecureServerSocket> runServer() { 16 Future<SecureServerSocket> runServer() {
20 SecureSocket.initialize(database: certificateDatabase(), 17 SecureSocket.initialize(
21 password: 'dartdart'); 18 database: join(dirname(new Options().script), 'pkcert'),
19 password: 'dartdart');
22 20
23 return SecureServerSocket.bind(HOST_NAME, 0, CERTIFICATE) 21 return SecureServerSocket.bind(HOST_NAME, 0, CERTIFICATE)
24 .then((SecureServerSocket server) { 22 .then((SecureServerSocket server) {
25 server.listen((SecureSocket socket) { 23 server.listen((SecureSocket socket) {
26 socket.listen((_) { }, 24 socket.listen((_) { },
27 onDone: () { 25 onDone: () {
28 socket.close(); 26 socket.close();
29 }); 27 });
30 }, onError: (e) => Expect.isTrue(e is HandshakeException)); 28 }, onError: (e) => Expect.isTrue(e is HandshakeException));
31 return server; 29 return server;
32 }); 30 });
33 } 31 }
34 32
35
36 void main() { 33 void main() {
37 final options = new Options(); 34 final options = new Options();
38 var clientScript = join(dirname(options.script), 35 var clientScript = join(dirname(options.script),
39 'secure_bad_certificate_client.dart'); 36 'secure_unauthorized_client.dart');
40 37
41 Future clientProcess(int port, String acceptCertificate) { 38 Future clientProcess(int port) {
42 return Process.run(options.executable, 39 return Process.run(options.executable,
43 [clientScript, port.toString(), acceptCertificate]) 40 [clientScript, port.toString()])
44 .then((ProcessResult result) { 41 .then((ProcessResult result) {
45 if (result.exitCode != 0) { 42 if (result.exitCode != 0 || !result.stdout.contains('SUCCESS')) {
46 print("Client failed, stdout:"); 43 print("Client failed");
44 print(" stdout:");
47 print(result.stdout); 45 print(result.stdout);
48 print(" stderr:"); 46 print(" stderr:");
49 print(result.stderr); 47 print(result.stderr);
50 Expect.fail('Client subprocess exit code: ${result.exitCode}'); 48 Expect.fail('Client subprocess exit code: ${result.exitCode}');
51 } 49 }
52 }); 50 });
53 } 51 }
54 52
55 runServer().then((server) { 53 runServer().then((server) {
56 Future.wait([clientProcess(server.port, 'true'), 54 clientProcess(server.port).then((_) {
57 clientProcess(server.port, 'false'),
58 clientProcess(server.port, 'fisk'),
59 clientProcess(server.port, 'exception')]).then((_) {
60 server.close(); 55 server.close();
61 }); 56 });
62 }); 57 });
63 } 58 }
OLDNEW
« no previous file with comments | « tests/standalone/io/secure_unauthorized_client.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698