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

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

Issue 11299228: Add HttpsServer class and test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adress comment Created 8 years, 1 month 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
« sdk/lib/io/http_impl.dart ('K') | « sdk/lib/io/http_impl.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/https_server_test.dart
diff --git a/tests/standalone/io/http_server_test.dart b/tests/standalone/io/https_server_test.dart
similarity index 60%
copy from tests/standalone/io/http_server_test.dart
copy to tests/standalone/io/https_server_test.dart
index 7cda6f4599646a86cb9fc6d481ca6a749c5ba8de..8eb639f9976e2583103f1ed7de09ebdc4a0d4530 100644
--- a/tests/standalone/io/http_server_test.dart
+++ b/tests/standalone/io/https_server_test.dart
@@ -2,18 +2,16 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-#import("dart:io");
-#import("dart:isolate");
+import "dart:io";
+import "dart:uri";
+import "dart:isolate";
-void testListenOn() {
- ServerSocket socket = new ServerSocket("127.0.0.1", 0, 5);
-
- socket.onError = (Exception e) {
- Expect.fail("ServerSocket closed unexpected");
- };
+const SERVER_ADDRESS = "127.0.0.1";
+const HOST_NAME = "localhost";
+void testListenOn() {
void test(void onDone()) {
- HttpServer server = new HttpServer();
+ HttpsServer server = new HttpsServer();
Expect.throws(() => server.port);
ReceivePort serverPort = new ReceivePort();
@@ -26,14 +24,17 @@ void testListenOn() {
};
server.onError = (Exception e) {
- Expect.fail("Unexpected error in Http Server: $e");
+ Expect.fail("Unexpected error in Https Server: $e");
};
- server.listenOn(socket);
- Expect.equals(socket.port, server.port);
+ server.listen(SERVER_ADDRESS,
+ 0,
+ backlog: 5,
+ certificate_name: 'CN=$HOST_NAME');
HttpClient client = new HttpClient();
- HttpClientConnection conn = client.get("127.0.0.1", socket.port, "/");
+ HttpClientConnection conn =
+ client.getUrl(new Uri.fromString("https://$HOST_NAME:${server.port}/"));
conn.onRequest = (HttpClientRequest request) {
request.outputStream.close();
};
@@ -48,18 +49,25 @@ void testListenOn() {
};
};
conn.onError = (Exception e) {
- Expect.fail("Unexpected error in Http Client: $e");
+ Expect.fail("Unexpected error in Https Client: $e");
};
};
// Test two connection after each other.
test(() {
test(() {
- socket.close();
});
});
}
+void InitializeSSL() {
+ var testPkcertDatabase =
+ new Path.fromNative(new Options().script).directoryPath.append('pkcert/');
+ SecureSocket.setCertificateDatabase(testPkcertDatabase.toNativePath(),
+ 'dartdart');
+}
+
void main() {
+ InitializeSSL();
testListenOn();
}
« sdk/lib/io/http_impl.dart ('K') | « sdk/lib/io/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698