| OLD | NEW |
| 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 client certificates work, if the client and server | 5 // This test verifies that client certificates work, if the client and server |
| 6 // are in separate processes, and that connection renegotiation works, and | 6 // are in separate processes, and that connection renegotiation works, and |
| 7 // can request a client certificate to be sent. | 7 // can request a client certificate to be sent. |
| 8 | 8 |
| 9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
| 10 import "package:path/path.dart" as path; | 10 import "package:path/path.dart"; |
| 11 import "dart:async"; | 11 import "dart:async"; |
| 12 import "dart:io"; | 12 import "dart:io"; |
| 13 | 13 |
| 14 const HOST_NAME = "localhost"; | 14 const HOST_NAME = "localhost"; |
| 15 const CERTIFICATE = "localhost_cert"; | 15 const CERTIFICATE = "localhost_cert"; |
| 16 | 16 |
| 17 | 17 |
| 18 String certificateDatabase() => | 18 String certificateDatabase() => join(dirname(new Options().script), 'pkcert'); |
| 19 path.join(path.dirname(new Options().script), 'pkcert', ''); | |
| 20 | 19 |
| 21 | 20 |
| 22 Future<SecureServerSocket> runServer() { | 21 Future<SecureServerSocket> runServer() { |
| 23 SecureSocket.initialize(database: certificateDatabase(), | 22 SecureSocket.initialize(database: certificateDatabase(), |
| 24 password: 'dartdart'); | 23 password: 'dartdart'); |
| 25 | 24 |
| 26 return SecureServerSocket.bind(HOST_NAME, 0, CERTIFICATE) | 25 return SecureServerSocket.bind(HOST_NAME, 0, CERTIFICATE) |
| 27 .then((SecureServerSocket server) { | 26 .then((SecureServerSocket server) { |
| 28 server.listen((SecureSocket socket) { | 27 server.listen((SecureSocket socket) { |
| 29 Expect.isNull(socket.peerCertificate); | 28 Expect.isNull(socket.peerCertificate); |
| 30 | 29 |
| 31 StreamIterator<String> input = | 30 StreamIterator<String> input = |
| 32 new StreamIterator(socket.transform(new StringDecoder()) | 31 new StreamIterator(socket.transform(new StringDecoder()) |
| 33 .transform(new LineTransformer())); | 32 .transform(new LineTransformer())); |
| 34 input.moveNext().then((success) { | 33 input.moveNext().then((success) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 if (result.exitCode != 0) { | 75 if (result.exitCode != 0) { |
| 77 print("Client failed, stdout:"); | 76 print("Client failed, stdout:"); |
| 78 print(result.stdout); | 77 print(result.stdout); |
| 79 print(" stderr:"); | 78 print(" stderr:"); |
| 80 print(result.stderr); | 79 print(result.stderr); |
| 81 Expect.fail('Client subprocess exit code: ${result.exitCode}'); | 80 Expect.fail('Client subprocess exit code: ${result.exitCode}'); |
| 82 } | 81 } |
| 83 }); | 82 }); |
| 84 }); | 83 }); |
| 85 } | 84 } |
| OLD | NEW |