| 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();
|
| }
|
|
|