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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import "package:path/path.dart"; | 6 import "package:path/path.dart"; |
7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
8 | 8 |
9 import "dart:async"; | 9 import "dart:async"; |
10 import "dart:io"; | 10 import "dart:io"; |
11 import "dart:typed_data"; | 11 import "dart:typed_data"; |
12 | 12 |
13 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 13 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
14 | 14 |
15 SecurityContext serverContext = new SecurityContext() | 15 SecurityContext serverContext = new SecurityContext() |
16 ..useCertificateChainSync(localFile('certificates/server_chain.pem')) | 16 ..useCertificateChain(localFile('certificates/server_chain.pem')) |
17 ..usePrivateKeySync(localFile('certificates/server_key.pem'), | 17 ..usePrivateKey(localFile('certificates/server_key.pem'), |
18 password: 'dartdart'); | 18 password: 'dartdart'); |
19 | 19 |
20 SecurityContext clientContext = new SecurityContext() | 20 SecurityContext clientContext = new SecurityContext() |
21 ..setTrustedCertificatesSync(localFile('certificates/trusted_certs.pem')); | 21 ..setTrustedCertificates(localFile('certificates/trusted_certs.pem')); |
22 | 22 |
23 // 10 KiB of i%256 data. | 23 // 10 KiB of i%256 data. |
24 Uint8List DATA = new Uint8List.fromList( | 24 Uint8List DATA = new Uint8List.fromList( |
25 new List.generate(10 * 1024, (i) => i % 256)); | 25 new List.generate(10 * 1024, (i) => i % 256)); |
26 | 26 |
27 Future<SecureServerSocket> startServer() { | 27 Future<SecureServerSocket> startServer() { |
28 return SecureServerSocket.bind("localhost", | 28 return SecureServerSocket.bind("localhost", |
29 0, | 29 0, |
30 serverContext).then((server) { | 30 serverContext).then((server) { |
31 server.listen((SecureSocket request) async { | 31 server.listen((SecureSocket request) async { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 Expect.fail('Unexpected error: $e'); | 71 Expect.fail('Unexpected error: $e'); |
72 }, onDone: () { | 72 }, onDone: () { |
73 Expect.equals(body.length, DATA.length); | 73 Expect.equals(body.length, DATA.length); |
74 for (int i = 0; i < body.length; i++) { | 74 for (int i = 0; i < body.length; i++) { |
75 Expect.equals(body[i], DATA[i]); | 75 Expect.equals(body[i], DATA[i]); |
76 } | 76 } |
77 server.close(); | 77 server.close(); |
78 asyncEnd(); | 78 asyncEnd(); |
79 }); | 79 }); |
80 } | 80 } |
OLD | NEW |