Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: tests/standalone/io/secure_multiple_client_server_test.dart

Issue 24454003: Revert "dart:io | Change two secure networking tests to account for the session cache." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/standalone/io/https_bad_certificate_client.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 6 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 7 // Tests multiple secure connections from a client to a server, hitting
8 // the secure connection cache.
9 9
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
11 import "package:path/path.dart"; 11 import "package:path/path.dart";
12 import "dart:async"; 12 import "dart:async";
13 import "dart:io"; 13 import "dart:io";
14 import "dart:isolate"; 14 import "dart:isolate";
15 15
16 const HOST_NAME = "localhost"; 16 const HOST_NAME = "localhost";
17 const CERTIFICATE = "localhost_cert"; 17 const CERTIFICATE = "localhost_cert";
18 Future<SecureServerSocket> startServer() { 18 Future<SecureServerSocket> startServer() {
19 return SecureServerSocket.bind(HOST_NAME, 19 return SecureServerSocket.bind(HOST_NAME,
20 0, 20 0,
21 CERTIFICATE).then((server) { 21 CERTIFICATE).then((server) {
22 server.listen((SecureSocket client) { 22 server.listen((SecureSocket client) {
23 client.fold(<int>[], (message, data) => message..addAll(data)) 23 client.fold(<int>[], (message, data) => message..addAll(data))
24 .then((message) { 24 .then((message) {
25 String received = new String.fromCharCodes(message); 25 String received = new String.fromCharCodes(message);
26 Expect.isTrue(received.contains("Hello from client ")); 26 Expect.isTrue(received.contains("Hello from client "));
27 String name = received.substring(received.indexOf("client ") + 7); 27 String name = received.substring(received.indexOf("client ") + 7);
28 client.add("Welcome, client $name".codeUnits); 28 client.add("Welcome, client $name".codeUnits);
29 client.close(); 29 client.close();
30 }); 30 });
31 }); 31 });
32 return server; 32 return server;
33 }); 33 });
34 } 34 }
35 35
36 // A delay is inserted so that later connections use the secure
37 // connection cache to reestablish connection with a shorter handshake.
38 Duration delay = new Duration(milliseconds: 0);
39 Duration betweenTests = new Duration(milliseconds: 200);
36 Future testClient(server, name) { 40 Future testClient(server, name) {
37 return SecureSocket.connect(HOST_NAME, server.port).then((socket) { 41 delay += betweenTests;
42 return new Future.delayed(delay).then((_) {
43 return SecureSocket.connect(HOST_NAME, server.port);
44 }).then((socket) {
38 socket.add("Hello from client $name".codeUnits); 45 socket.add("Hello from client $name".codeUnits);
39 socket.close(); 46 socket.close();
40 return socket.fold(<int>[], (message, data) => message..addAll(data)) 47 return socket.fold(<int>[], (message, data) => message..addAll(data))
41 .then((message) { 48 .then((message) {
42 Expect.listEquals("Welcome, client $name".codeUnits, message); 49 Expect.listEquals("Welcome, client $name".codeUnits, message);
43 return server; 50 return server;
44 }); 51 });
45 }); 52 });
46 } 53 }
47 54
48 void main() { 55 void main() {
49 var certificateDatabase = join(dirname(Platform.script), 'pkcert'); 56 var certificateDatabase = join(dirname(Platform.script), 'pkcert');
50 SecureSocket.initialize(database: certificateDatabase, 57 SecureSocket.initialize(database: certificateDatabase,
51 password: 'dartdart'); 58 password: 'dartdart');
52 59
53 startServer() 60 startServer()
54 .then((server) => Future.wait( 61 .then((server) => Future.wait(
55 ['able', 'baker', 'charlie', 'dozen', 'elapse'] 62 ['able', 'baker', 'charlie', 'dozen', 'elapse']
56 .map((name) => testClient(server, name)))) 63 .map((name) => testClient(server, name))))
57 .then((servers) => servers.first.close()); 64 .then((servers) => servers.first.close());
58 } 65 }
OLDNEW
« no previous file with comments | « tests/standalone/io/https_bad_certificate_client.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698