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

Unified Diff: tests/standalone/io/socket_upgrade_to_secure_test.dart

Issue 201993002: Fix SecureSocket tests to look up localhost only once, where possible. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove useless change to https_client_certificate_test.dart Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/standalone/io/secure_socket_bad_data_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/socket_upgrade_to_secure_test.dart
diff --git a/tests/standalone/io/socket_upgrade_to_secure_test.dart b/tests/standalone/io/socket_upgrade_to_secure_test.dart
index ff0f7278d9830a9d035f8b34b9db1897ea2304ea..d973a788964a35a8347596d63fa2c3f3ed503665 100644
--- a/tests/standalone/io/socket_upgrade_to_secure_test.dart
+++ b/tests/standalone/io/socket_upgrade_to_secure_test.dart
@@ -12,9 +12,8 @@ import "dart:io";
import "package:async_helper/async_helper.dart";
import "package:expect/expect.dart";
-import "package:path/path.dart";
-const HOST_NAME = "localhost";
+InternetAddress HOST;
const CERTIFICATE = "localhost_cert";
// This test creates a server and a client connects. After connecting
@@ -154,12 +153,12 @@ void test(bool hostnameInConnect,
Future<SecureSocket> connectClient(int port) {
if (!handshakeBeforeSecure) {
- return Socket.connect(HOST_NAME, port).then((socket) {
+ return Socket.connect(HOST, port).then((socket) {
var future;
if (hostnameInConnect) {
future = SecureSocket.secure(socket);
} else {
- future = SecureSocket.secure(socket, host: HOST_NAME);
+ future = SecureSocket.secure(socket, host: HOST);
}
return future.then((secureSocket) {
socket.add([0]);
@@ -167,13 +166,13 @@ void test(bool hostnameInConnect,
});
});
} else {
- return Socket.connect(HOST_NAME, port).then((socket) {
+ return Socket.connect(HOST, port).then((socket) {
return runClientHandshake(socket).then((_) {
var future;
if (hostnameInConnect) {
future = SecureSocket.secure(socket);
} else {
- future = SecureSocket.secure(socket, host: HOST_NAME);
+ future = SecureSocket.secure(socket, host: HOST.host);
}
return future.then((secureSocket) {
socket.add([0]);
@@ -209,18 +208,23 @@ void test(bool hostnameInConnect,
});
}
- ServerSocket.bind(HOST_NAME, 0).then(serverReady);
+ ServerSocket.bind(HOST, 0).then(serverReady);
}
main() {
+ asyncStart();
var certificateDatabase = Platform.script.resolve('pkcert').toFilePath();
SecureSocket.initialize(database: certificateDatabase,
password: 'dartdart',
useBuiltinRoots: false);
- test(false, false);
- test(true, false);
- test(false, true);
- test(true, true);
- test(false, true, true);
- test(true, true, true);
+ InternetAddress.lookup("localhost").then((hosts) {
+ HOST = hosts.first;
+ test(false, false);
+ test(true, false);
+ test(false, true);
+ test(true, true);
+ test(false, true, true);
+ test(true, true, true);
+ asyncEnd();
+ });
}
« no previous file with comments | « tests/standalone/io/secure_socket_bad_data_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698