| 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 a server certificate can be verified by a client | 5 // This test verifies that a server certificate can be verified by a client |
| 6 // that loads the certificate authority certificate it depends on at runtime. | 6 // that loads the certificate authority certificate it depends on at runtime. |
| 7 | 7 |
| 8 import "package:path/path.dart"; | 8 import "package:path/path.dart"; |
| 9 import "dart:io"; | 9 import "dart:io"; |
| 10 import "dart:async"; | 10 import "dart:async"; |
| 11 | 11 |
| 12 String scriptDir = dirname(new Options().script); | 12 String scriptDir = dirname(new Options().script); |
| 13 | 13 |
| 14 void main() { | 14 void main() { |
| 15 SecureSocket.initialize(database: join(scriptDir, 'pkcert'), | 15 SecureSocket.initialize(database: join(scriptDir, 'pkcert'), |
| 16 password: 'dartdart'); | 16 password: 'dartdart'); |
| 17 runServer().then((SecureServerSocket server) { | 17 runServer().then((SecureServerSocket server) { |
| 18 return Process.run(new Options().executable, | 18 return Process.run(new Options().executable, |
| 19 ['--checked', | 19 ['--checked', |
| 20 join(scriptDir, 'certificate_test_client.dart'), | 20 join(scriptDir, 'certificate_test_client.dart'), |
| 21 server.port.toString(), | 21 server.port.toString(), |
| 22 join(scriptDir, 'pkcert', 'myauthority.pem')]); | 22 join(scriptDir, 'pkcert', 'myauthority.pem')]); |
| 23 }).then((ProcessResult result) { | 23 }).then((ProcessResult result) { |
| 24 if (result.exitCode != 0) { | 24 if (result.exitCode != 0 || !result.stdout.contains("SUCCESS")) { |
| 25 print("Client failed with exit code ${result.exitCode}"); | 25 print("Client failed with exit code ${result.exitCode}"); |
| 26 print(" stdout:"); | 26 print(" stdout (expects \"SUCCESS\\n\"):"); |
| 27 print(result.stdout); | 27 print(result.stdout); |
| 28 print(" stderr:"); | 28 print(" stderr:"); |
| 29 print(result.stderr); | 29 print(result.stderr); |
| 30 throw new AssertionError(); | 30 throw new AssertionError(); |
| 31 } | 31 } |
| 32 }); | 32 }); |
| 33 } | 33 } |
| 34 | 34 |
| 35 Future<SecureServerSocket> runServer() => | 35 Future<SecureServerSocket> runServer() => |
| 36 SecureServerSocket.bind("localhost", 0, "localhost_cert") | 36 SecureServerSocket.bind("localhost", 0, "localhost_cert") |
| 37 .then((server) => server..listen( | 37 .then((server) => server..listen( |
| 38 (socket) => socket.pipe(socket).then((_) => server.close()))); | 38 (socket) => socket.pipe(socket).then((_) => server.close()))); |
| OLD | NEW |