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/server_chain.pem | 5 // OtherResources=certificates/server_chain.pem |
6 // OtherResources=certificates/server_key.pem | 6 // OtherResources=certificates/server_key.pem |
| 7 // OtherResources=certificates/untrusted_server_chain.pem |
| 8 // OtherResources=certificates/untrusted_server_key.pem |
| 9 // OtherResources=certificates/trusted_certs.pem |
| 10 // OtherResources=https_unauthorized_client.dart |
7 | 11 |
8 // This test verifies that secure connections that fail due to | 12 // This test verifies that secure connections that fail due to |
9 // unauthenticated certificates throw exceptions in HttpClient. | 13 // unauthenticated certificates throw exceptions in HttpClient. |
10 | 14 |
11 import "package:expect/expect.dart"; | 15 import "package:expect/expect.dart"; |
12 import "package:path/path.dart"; | 16 import "package:path/path.dart"; |
13 import "dart:async"; | 17 import "dart:async"; |
14 import "dart:io"; | 18 import "dart:io"; |
15 | 19 |
16 const HOST_NAME = "localhost"; | 20 const HOST_NAME = "localhost"; |
(...skipping 14 matching lines...) Expand all Loading... |
31 HOST_NAME, 0, untrustedServerContext, backlog: 5) | 35 HOST_NAME, 0, untrustedServerContext, backlog: 5) |
32 .then((server) { | 36 .then((server) { |
33 server.listen((HttpRequest request) { | 37 server.listen((HttpRequest request) { |
34 request.listen((_) { }, onDone: () { request.response.close(); }); | 38 request.listen((_) { }, onDone: () { request.response.close(); }); |
35 }, onError: (e) { if (e is! HandshakeException) throw e; }); | 39 }, onError: (e) { if (e is! HandshakeException) throw e; }); |
36 return server; | 40 return server; |
37 }); | 41 }); |
38 } | 42 } |
39 | 43 |
40 void main() { | 44 void main() { |
41 var clientScript = Platform.script | 45 var clientScript = localFile('https_unauthorized_client.dart'); |
42 .resolve('https_unauthorized_client.dart') | |
43 .toFilePath(); | |
44 Future clientProcess(int port) { | 46 Future clientProcess(int port) { |
45 return Process.run(Platform.executable, | 47 return Process.run(Platform.executable, |
46 [clientScript, port.toString()]) | 48 [clientScript, port.toString()]) |
47 .then((ProcessResult result) { | 49 .then((ProcessResult result) { |
48 if (result.exitCode != 0 || !result.stdout.contains('SUCCESS')) { | 50 if (result.exitCode != 0 || !result.stdout.contains('SUCCESS')) { |
49 print("Client failed"); | 51 print("Client failed"); |
50 print(" stdout:"); | 52 print(" stdout:"); |
51 print(result.stdout); | 53 print(result.stdout); |
52 print(" stderr:"); | 54 print(" stderr:"); |
53 print(result.stderr); | 55 print(result.stderr); |
54 Expect.fail('Client subprocess exit code: ${result.exitCode}'); | 56 Expect.fail('Client subprocess exit code: ${result.exitCode}'); |
55 } | 57 } |
56 }); | 58 }); |
57 } | 59 } |
58 | 60 |
59 runServer().then((server) { | 61 runServer().then((server) { |
60 clientProcess(server.port).then((_) { | 62 clientProcess(server.port).then((_) { |
61 server.close(); | 63 server.close(); |
62 }); | 64 }); |
63 }); | 65 }); |
64 } | 66 } |
OLD | NEW |