| 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 tests TLS session resume, by making multiple client connections | 5 // This test tests TLS session resume, by making multiple client connections |
| 6 // on the same port to the same server, with a delay of 200 ms between them. | 6 // on the same port to the same server, with a delay of 200 ms between them. |
| 7 // The unmodified secure_server_test creates all sessions simultaneously, | 7 // The unmodified secure_server_test creates all sessions simultaneously, |
| 8 // which means that no handshake completes and caches its keys in the session | 8 // which means that no handshake completes and caches its keys in the session |
| 9 // cache in time for other connections to use it. | 9 // cache in time for other connections to use it. |
| 10 // | 10 // |
| 11 // Session resume is currently disabled - see issue | 11 // Session resume is currently disabled - see issue |
| 12 // https://code.google.com/p/dart/issues/detail?id=7230 | 12 // https://code.google.com/p/dart/issues/detail?id=7230 |
| 13 // | 13 // |
| 14 // VMOptions= | 14 // VMOptions= |
| 15 // VMOptions=--short_socket_read | 15 // VMOptions=--short_socket_read |
| 16 // VMOptions=--short_socket_write | 16 // VMOptions=--short_socket_write |
| 17 // VMOptions=--short_socket_read --short_socket_write | 17 // VMOptions=--short_socket_read --short_socket_write |
| 18 | 18 |
| 19 import "dart:async"; | 19 import "dart:async"; |
| 20 import "dart:io"; | 20 import "dart:io"; |
| 21 import "dart:isolate"; | 21 import "dart:isolate"; |
| 22 | 22 |
| 23 import "package:expect/expect.dart"; | 23 import "package:expect/expect.dart"; |
| 24 import "package:async_helper/async_helper.dart"; | 24 import "package:async_helper/async_helper.dart"; |
| 25 | 25 |
| 26 InternetAddress HOST; | 26 InternetAddress HOST; |
| 27 | 27 |
| 28 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 28 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
| 29 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync(); | |
| 30 | 29 |
| 31 SecurityContext serverContext = new SecurityContext() | 30 SecurityContext serverContext = new SecurityContext() |
| 32 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem')) | 31 ..useCertificateChainSync(localFile('certificates/server_chain.pem')) |
| 33 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'), | 32 ..usePrivateKeySync(localFile('certificates/server_key.pem'), |
| 34 password: 'dartdart'); | 33 password: 'dartdart'); |
| 35 | 34 |
| 36 SecurityContext clientContext = new SecurityContext() | 35 SecurityContext clientContext = new SecurityContext() |
| 37 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); | 36 ..setTrustedCertificatesSync(localFile('certificates/trusted_certs.pem')); |
| 38 | 37 |
| 39 Future<SecureServerSocket> startServer() { | 38 Future<SecureServerSocket> startServer() { |
| 40 return SecureServerSocket.bind(HOST, | 39 return SecureServerSocket.bind(HOST, |
| 41 0, | 40 0, |
| 42 serverContext).then((server) { | 41 serverContext).then((server) { |
| 43 server.listen((SecureSocket client) { | 42 server.listen((SecureSocket client) { |
| 44 client.fold(<int>[], (message, data) => message..addAll(data)) | 43 client.fold(<int>[], (message, data) => message..addAll(data)) |
| 45 .then((message) { | 44 .then((message) { |
| 46 String received = new String.fromCharCodes(message); | 45 String received = new String.fromCharCodes(message); |
| 47 Expect.isTrue(received.contains("Hello from client ")); | 46 Expect.isTrue(received.contains("Hello from client ")); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return startServer() | 80 return startServer() |
| 82 .then((server) => Future.wait( | 81 .then((server) => Future.wait( |
| 83 ['able', 'baker', 'charlie', 'dozen', 'elapse'] | 82 ['able', 'baker', 'charlie', 'dozen', 'elapse'] |
| 84 .map((name) { | 83 .map((name) { |
| 85 delay += delay_between_connections; | 84 delay += delay_between_connections; |
| 86 return new Future.delayed(delay, () => server) | 85 return new Future.delayed(delay, () => server) |
| 87 .then((server) => testClient(server, name)); | 86 .then((server) => testClient(server, name)); |
| 88 }))) | 87 }))) |
| 89 .then((servers) => servers.first.close()); | 88 .then((servers) => servers.first.close()); |
| 90 } | 89 } |
| OLD | NEW |