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 "package:expect/expect.dart"; | 19 import "package:expect/expect.dart"; |
20 import "dart:async"; | 20 import "dart:async"; |
21 import "dart:io"; | 21 import "dart:io"; |
22 import "dart:isolate"; | 22 import "dart:isolate"; |
23 | 23 |
24 const HOST_NAME = "localhost"; | 24 const HOST_NAME = "localhost"; |
25 const CERTIFICATE = "localhost_cert"; | 25 const CERTIFICATE = "localhost_cert"; |
26 Future<SecureServerSocket> startServer() { | 26 Future<SecureServerSocket> startServer() { |
27 return SecureServerSocket.bind(HOST_NAME, | 27 return SecureServerSocket.bind(HOST_NAME, |
28 0, | 28 0, |
29 5, | |
30 CERTIFICATE).then((server) { | 29 CERTIFICATE).then((server) { |
31 server.listen((SecureSocket client) { | 30 server.listen((SecureSocket client) { |
32 client.fold(<int>[], (message, data) => message..addAll(data)) | 31 client.fold(<int>[], (message, data) => message..addAll(data)) |
33 .then((message) { | 32 .then((message) { |
34 String received = new String.fromCharCodes(message); | 33 String received = new String.fromCharCodes(message); |
35 Expect.isTrue(received.contains("Hello from client ")); | 34 Expect.isTrue(received.contains("Hello from client ")); |
36 String name = received.substring(received.indexOf("client ") + 7); | 35 String name = received.substring(received.indexOf("client ") + 7); |
37 client.write("Welcome, client $name"); | 36 client.write("Welcome, client $name"); |
38 client.close(); | 37 client.close(); |
39 }); | 38 }); |
(...skipping 26 matching lines...) Expand all Loading... |
66 startServer() | 65 startServer() |
67 .then((server) => Future.wait( | 66 .then((server) => Future.wait( |
68 ['able', 'baker', 'charlie', 'dozen', 'elapse'] | 67 ['able', 'baker', 'charlie', 'dozen', 'elapse'] |
69 .map((name) { | 68 .map((name) { |
70 delay += delay_between_connections; | 69 delay += delay_between_connections; |
71 return new Future.delayed(delay, () => server) | 70 return new Future.delayed(delay, () => server) |
72 .then((server) => testClient(server, name)); | 71 .then((server) => testClient(server, name)); |
73 }))) | 72 }))) |
74 .then((servers) => servers.first.close()); | 73 .then((servers) => servers.first.close()); |
75 } | 74 } |
OLD | NEW |