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

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

Issue 14771007: Always connect using HOST_NAME, but swicth on host source on secure upgrade, in secure_upgrade test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | « sdk/lib/io/secure_socket.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 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
11 import "dart:async"; 11 import "dart:async";
12 import "dart:io"; 12 import "dart:io";
13 import "dart:isolate"; 13 import "dart:isolate";
14 14
15 const HOST_IP = "127.0.0.1";
16 const HOST_NAME = "localhost"; 15 const HOST_NAME = "localhost";
17 const CERTIFICATE = "localhost_cert"; 16 const CERTIFICATE = "localhost_cert";
18 17
19 // This test creates a server and a client connects. After connecting 18 // This test creates a server and a client connects. After connecting
20 // and an optional initial handshake the connection is secured by 19 // and an optional initial handshake the connection is secured by
21 // upgrading to a secure connection The client then writes and the 20 // upgrading to a secure connection The client then writes and the
22 // server echos. When the server has finished its echo it 21 // server echos. When the server has finished its echo it
23 // half-closes. When the client gets the close event is closes fully. 22 // half-closes. When the client gets the close event is closes fully.
24 // 23 //
25 // The test can be run in different configurations based on 24 // The test can be run in different configurations based on
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 completer.complete(null); 144 completer.complete(null);
146 } 145 }
147 }, 146 },
148 onDone: () => Expect.fail("Should not be called") 147 onDone: () => Expect.fail("Should not be called")
149 ); 148 );
150 socket.add(createHandshakeTestData()); 149 socket.add(createHandshakeTestData());
151 return completer.future; 150 return completer.future;
152 } 151 }
153 152
154 Future<SecureSocket> connectClient(int port) { 153 Future<SecureSocket> connectClient(int port) {
155 var host = hostnameInConnect ? HOST_NAME : HOST_IP;
156 if (!handshakeBeforeSecure) { 154 if (!handshakeBeforeSecure) {
157 return Socket.connect(host, port).then((socket) { 155 return Socket.connect(HOST_NAME, port).then((socket) {
158 var future; 156 var future;
159 if (hostnameInConnect) { 157 if (hostnameInConnect) {
160 future = SecureSocket.secure(socket); 158 future = SecureSocket.secure(socket);
161 } else { 159 } else {
162 future = SecureSocket.secure(socket, host: HOST_NAME); 160 future = SecureSocket.secure(socket, host: HOST_NAME);
163 } 161 }
164 return future.then((secureSocket) { 162 return future.then((secureSocket) {
165 Expect.throws(() => socket.add([0])); 163 Expect.throws(() => socket.add([0]));
166 return secureSocket; 164 return secureSocket;
167 }); 165 });
168 }); 166 });
169 } else { 167 } else {
170 return Socket.connect(host, port).then((socket) { 168 return Socket.connect(HOST_NAME, port).then((socket) {
171 return runClientHandshake(socket).then((_) { 169 return runClientHandshake(socket).then((_) {
172 var future; 170 var future;
173 if (hostnameInConnect) { 171 if (hostnameInConnect) {
174 future = SecureSocket.secure(socket); 172 future = SecureSocket.secure(socket);
175 } else { 173 } else {
176 future = SecureSocket.secure(socket, host: HOST_NAME); 174 future = SecureSocket.secure(socket, host: HOST_NAME);
177 } 175 }
178 return future.then((secureSocket) { 176 return future.then((secureSocket) {
179 Expect.throws(() => socket.add([0])); 177 Expect.throws(() => socket.add([0]));
180 return secureSocket; 178 return secureSocket;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 SecureSocket.initialize(database: certificateDatabase.toNativePath(), 216 SecureSocket.initialize(database: certificateDatabase.toNativePath(),
219 password: 'dartdart', 217 password: 'dartdart',
220 useBuiltinRoots: false); 218 useBuiltinRoots: false);
221 test(false, false); 219 test(false, false);
222 test(true, false); 220 test(true, false);
223 test(false, true); 221 test(false, true);
224 test(true, true); 222 test(true, true);
225 test(false, true, true); 223 test(false, true, true);
226 test(true, true, true); 224 test(true, true, true);
227 } 225 }
OLDNEW
« no previous file with comments | « sdk/lib/io/secure_socket.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698