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

Unified Diff: tests/standalone/io/secure_socket_bad_data_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
Index: tests/standalone/io/secure_socket_bad_data_test.dart
diff --git a/tests/standalone/io/secure_socket_bad_data_test.dart b/tests/standalone/io/secure_socket_bad_data_test.dart
index bff3f463d8167bd8ce61ac8c6ae8ff51f9fa5e0c..f0c3fa51190bc008960ac70b5c1949e87c036e53 100644
--- a/tests/standalone/io/secure_socket_bad_data_test.dart
+++ b/tests/standalone/io/secure_socket_bad_data_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 sends corrupt data in the middle of a secure network connection.
@@ -133,15 +132,15 @@ Future<RawSocket> runClient(List sockets) {
Future<List> connectClient(int port, bool hostnameInConnect) =>
- RawSocket.connect(HOST_NAME, port)
+ RawSocket.connect(HOST, port)
.then((socket) =>
(hostnameInConnect ? RawSecureSocket.secure(socket)
- : RawSecureSocket.secure(socket, host: HOST_NAME))
+ : RawSecureSocket.secure(socket, host: HOST))
.then((secureSocket) => [socket, secureSocket]));
Future test(bool hostnameInConnect) {
- return RawServerSocket.bind(HOST_NAME, 0).then((server) {
+ return RawServerSocket.bind(HOST, 0).then((server) {
server.listen((client) {
RawSecureSocket.secureServer(client, CERTIFICATE)
.then((secureClient) {
@@ -164,6 +163,8 @@ main() {
password: 'dartdart',
useBuiltinRoots: false);
asyncStart();
- Future.wait([test(false), test(true)])
- .then((_) => asyncEnd());
+ InternetAddress.lookup("localhost").then((hosts) {
+ HOST = hosts.first;
+ return Future.wait([test(false), test(true)]);
+ }).then((_) => asyncEnd());
}
« no previous file with comments | « tests/standalone/io/secure_session_resume_test.dart ('k') | tests/standalone/io/socket_upgrade_to_secure_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698