| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 |
| 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, |
| 8 // which means that no handshake completes and caches its keys in the session |
| 9 // cache in time for other connections to use it. |
| 10 // |
| 11 // Session resume is currently disabled - see issue |
| 12 // https://code.google.com/p/dart/issues/detail?id=7230 |
| 13 |
| 5 import "dart:io"; | 14 import "dart:io"; |
| 6 import "dart:isolate"; | 15 import "dart:isolate"; |
| 7 | 16 |
| 8 const SERVER_ADDRESS = "127.0.0.1"; | 17 const SERVER_ADDRESS = "127.0.0.1"; |
| 9 const HOST_NAME = "localhost"; | 18 const HOST_NAME = "localhost"; |
| 10 | 19 |
| 11 void WriteAndClose(Socket socket, String message) { | 20 void WriteAndClose(Socket socket, String message) { |
| 12 var data = message.charCodes; | 21 var data = message.charCodes; |
| 13 int written = 0; | 22 int written = 0; |
| 14 void write() { | 23 void write() { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 static int numReplies = 0; | 96 static int numReplies = 0; |
| 88 | 97 |
| 89 int port; | 98 int port; |
| 90 String name; | 99 String name; |
| 91 SecureSocket socket; | 100 SecureSocket socket; |
| 92 String reply; | 101 String reply; |
| 93 } | 102 } |
| 94 | 103 |
| 95 Function EndTest; | 104 Function EndTest; |
| 96 | 105 |
| 97 const CLIENT_NAMES = const ['able', 'baker', 'camera', 'donut', 'echo']; | 106 const CLIENT_NAMES = const ['able', 'baker']; |
| 98 | 107 |
| 99 void main() { | 108 void main() { |
| 100 ReceivePort keepAlive = new ReceivePort(); | 109 ReceivePort keepAlive = new ReceivePort(); |
| 101 Path scriptDir = new Path.fromNative(new Options().script).directoryPath; | 110 Path scriptDir = new Path.fromNative(new Options().script).directoryPath; |
| 102 Path certificateDatabase = scriptDir.append('pkcert'); | 111 Path certificateDatabase = scriptDir.append('pkcert'); |
| 103 SecureSocket.initialize(database: certificateDatabase.toNativePath(), | 112 SecureSocket.initialize(database: certificateDatabase.toNativePath(), |
| 104 password: 'dartdart'); | 113 password: 'dartdart', |
| 114 useBuiltinRoots: false); |
| 105 | 115 |
| 106 var server = new SecureTestServer(); | 116 var server = new SecureTestServer(); |
| 107 int port = server.start(); | 117 int port = server.start(); |
| 108 | 118 |
| 109 EndTest = () { | 119 EndTest = () { |
| 110 Expect.equals(CLIENT_NAMES.length, server.numConnections); | 120 Expect.equals(CLIENT_NAMES.length, server.numConnections); |
| 111 server.stop(); | 121 server.stop(); |
| 112 keepAlive.close(); | 122 keepAlive.close(); |
| 113 }; | 123 }; |
| 114 | 124 |
| 125 int delay = 0; |
| 126 int delay_between_connections = 300; // Milliseconds. |
| 127 |
| 115 for (var x in CLIENT_NAMES) { | 128 for (var x in CLIENT_NAMES) { |
| 116 new SecureTestClient(port, x); | 129 new Timer(delay, (_) { |
| 130 new SecureTestClient(port, x); |
| 131 }); |
| 132 delay += delay_between_connections; |
| 117 } | 133 } |
| 118 } | 134 } |
| OLD | NEW |