| 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 "dart:async"; | 9 import "dart:async"; |
| 10 import "dart:convert"; | 10 import "dart:convert"; |
| 11 import "dart:io"; | 11 import "dart:io"; |
| 12 | 12 |
| 13 import "package:expect/expect.dart"; | 13 import "package:expect/expect.dart"; |
| 14 import "package:path/path.dart"; | 14 import "package:path/path.dart"; |
| 15 | 15 |
| 16 const HOST_NAME = "localhost"; | 16 const HOST_NAME = "localhost"; |
| 17 const CERTIFICATE = "localhost_cert"; | 17 const CERTIFICATE = "localhost_cert"; |
| 18 | 18 |
| 19 | 19 |
| 20 String certificateDatabase() => join(dirname(new Options().script), 'pkcert'); | 20 String certificateDatabase() => join(dirname(Platform.script), 'pkcert'); |
| 21 | 21 |
| 22 | 22 |
| 23 Future<SecureServerSocket> runServer() { | 23 Future<SecureServerSocket> runServer() { |
| 24 SecureSocket.initialize(database: certificateDatabase(), | 24 SecureSocket.initialize(database: certificateDatabase(), |
| 25 password: 'dartdart'); | 25 password: 'dartdart'); |
| 26 | 26 |
| 27 return SecureServerSocket.bind(HOST_NAME, 0, CERTIFICATE) | 27 return SecureServerSocket.bind(HOST_NAME, 0, CERTIFICATE) |
| 28 .then((SecureServerSocket server) { | 28 .then((SecureServerSocket server) { |
| 29 server.listen((SecureSocket socket) { | 29 server.listen((SecureSocket socket) { |
| 30 Expect.isNull(socket.peerCertificate); | 30 Expect.isNull(socket.peerCertificate); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 58 }); | 58 }); |
| 59 }); | 59 }); |
| 60 return server; | 60 return server; |
| 61 }); | 61 }); |
| 62 } | 62 } |
| 63 | 63 |
| 64 | 64 |
| 65 void main() { | 65 void main() { |
| 66 runServer() | 66 runServer() |
| 67 .then((SecureServerSocket server) { | 67 .then((SecureServerSocket server) { |
| 68 final options = new Options(); | |
| 69 var clientScript = | 68 var clientScript = |
| 70 options.script.replaceFirst("_test.dart", "_client.dart"); | 69 Platform.script.replaceFirst("_test.dart", "_client.dart"); |
| 71 Expect.isTrue(clientScript.endsWith("_client.dart")); | 70 Expect.isTrue(clientScript.endsWith("_client.dart")); |
| 72 Process.run(options.executable, | 71 Process.run(Platform.executable, |
| 73 [clientScript, | 72 [clientScript, |
| 74 server.port.toString(), | 73 server.port.toString(), |
| 75 certificateDatabase()]) | 74 certificateDatabase()]) |
| 76 .then((ProcessResult result) { | 75 .then((ProcessResult result) { |
| 77 if (result.exitCode != 0) { | 76 if (result.exitCode != 0) { |
| 78 print("Client failed, stdout:"); | 77 print("Client failed, stdout:"); |
| 79 print(result.stdout); | 78 print(result.stdout); |
| 80 print(" stderr:"); | 79 print(" stderr:"); |
| 81 print(result.stderr); | 80 print(result.stderr); |
| 82 Expect.fail('Client subprocess exit code: ${result.exitCode}'); | 81 Expect.fail('Client subprocess exit code: ${result.exitCode}'); |
| 83 } | 82 } |
| 84 }); | 83 }); |
| 85 }); | 84 }); |
| 86 } | 85 } |
| OLD | NEW |