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 // Client for secure_bad_certificate_test, that runs in a subprocess. | 5 // Client for secure_bad_certificate_test, that runs in a subprocess. |
6 // The test verifies that the client bad certificate callback works. | 6 // The test verifies that the client bad certificate callback works. |
7 | 7 |
8 import "dart:async"; | 8 import "dart:async"; |
9 import "dart:io"; | 9 import "dart:io"; |
10 | 10 |
11 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 11 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
| 12 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync(); |
12 | 13 |
13 SecurityContext clientContext = new SecurityContext() | 14 SecurityContext clientContext = new SecurityContext() |
14 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); | 15 ..setTrustedCertificatesBytes(readLocalFile('certificates/trusted_certs.pem'))
; |
15 | 16 |
16 class ExpectException implements Exception { | 17 class ExpectException implements Exception { |
17 ExpectException(this.message); | 18 ExpectException(this.message); |
18 String toString() => "ExpectException: $message"; | 19 String toString() => "ExpectException: $message"; |
19 String message; | 20 String message; |
20 } | 21 } |
21 | 22 |
22 void expect(condition) { | 23 void expect(condition) { |
23 if (!condition) { | 24 if (!condition) { |
24 throw new ExpectException(''); | 25 throw new ExpectException(''); |
(...skipping 14 matching lines...) Expand all Loading... |
39 })); | 40 })); |
40 } | 41 } |
41 return Future.wait(testFutures); | 42 return Future.wait(testFutures); |
42 } | 43 } |
43 | 44 |
44 | 45 |
45 void main(List<String> args) { | 46 void main(List<String> args) { |
46 runClients(int.parse(args[0])) | 47 runClients(int.parse(args[0])) |
47 .then((_) => print('SUCCESS')); | 48 .then((_) => print('SUCCESS')); |
48 } | 49 } |
OLD | NEW |