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 // OtherResources=certificates/untrusted_server_chain.pem |
| 6 // OtherResources=certificates/untrusted_server_key.pem |
| 7 // OtherResources=certificates/untrusted_server_chain.pem |
| 8 // OtherResources=certificates/trusted_certs.pem |
| 9 // OtherResources=secure_unauthorized_client.dart |
| 10 |
5 // This test verifies that failing secure connection attempts always complete | 11 // This test verifies that failing secure connection attempts always complete |
6 // their returned future. | 12 // their returned future. |
7 | 13 |
8 import "package:expect/expect.dart"; | 14 import "package:expect/expect.dart"; |
9 import "package:path/path.dart"; | 15 import "package:path/path.dart"; |
10 import "dart:async"; | 16 import "dart:async"; |
11 import "dart:io"; | 17 import "dart:io"; |
12 | 18 |
13 const HOST_NAME = "localhost"; | 19 const HOST_NAME = "localhost"; |
14 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 20 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
(...skipping 10 matching lines...) Expand all Loading... |
25 socket.listen((_) { }, | 31 socket.listen((_) { }, |
26 onDone: () { | 32 onDone: () { |
27 socket.close(); | 33 socket.close(); |
28 }); | 34 }); |
29 }, onError: (e) => Expect.isTrue(e is HandshakeException)); | 35 }, onError: (e) => Expect.isTrue(e is HandshakeException)); |
30 return server; | 36 return server; |
31 }); | 37 }); |
32 } | 38 } |
33 | 39 |
34 void main() { | 40 void main() { |
35 var clientScript = Platform.script | 41 var clientScript = localFile('secure_unauthorized_client.dart'); |
36 .resolve('secure_unauthorized_client.dart') | |
37 .toFilePath(); | |
38 | 42 |
39 Future clientProcess(int port) { | 43 Future clientProcess(int port) { |
40 return Process.run(Platform.executable, | 44 return Process.run(Platform.executable, |
41 [clientScript, port.toString()]) | 45 [clientScript, port.toString()]) |
42 .then((ProcessResult result) { | 46 .then((ProcessResult result) { |
43 if (result.exitCode != 0 || !result.stdout.contains('SUCCESS')) { | 47 if (result.exitCode != 0 || !result.stdout.contains('SUCCESS')) { |
44 print("Client failed"); | 48 print("Client failed"); |
45 print(" stdout:"); | 49 print(" stdout:"); |
46 print(result.stdout); | 50 print(result.stdout); |
47 print(" stderr:"); | 51 print(" stderr:"); |
48 print(result.stderr); | 52 print(result.stderr); |
49 Expect.fail('Client subprocess exit code: ${result.exitCode}'); | 53 Expect.fail('Client subprocess exit code: ${result.exitCode}'); |
50 } | 54 } |
51 }); | 55 }); |
52 } | 56 } |
53 | 57 |
54 runServer().then((server) { | 58 runServer().then((server) { |
55 clientProcess(server.port).then((_) { | 59 clientProcess(server.port).then((_) { |
56 server.close(); | 60 server.close(); |
57 }); | 61 }); |
58 }); | 62 }); |
59 } | 63 } |
OLD | NEW |