| Index: tests/standalone/io/https_client_test.dart
|
| diff --git a/tests/standalone/io/http_client_test.dart b/tests/standalone/io/https_client_test.dart
|
| similarity index 55%
|
| copy from tests/standalone/io/http_client_test.dart
|
| copy to tests/standalone/io/https_client_test.dart
|
| index 6c3c54976d9cae128f298be66c14f65dc32ea6a8..d639426a896dd365ede75f3fc8497700457c22f6 100644
|
| --- a/tests/standalone/io/http_client_test.dart
|
| +++ b/tests/standalone/io/https_client_test.dart
|
| @@ -2,28 +2,10 @@
|
| // 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:uri");
|
| -#import("dart:isolate");
|
| +import "dart:io";
|
| +import "dart:uri";
|
| +import "dart:isolate";
|
|
|
| -void testGoogle() {
|
| - HttpClient client = new HttpClient();
|
| - var conn = client.get('www.google.com', 80, '/');
|
| -
|
| - conn.onRequest = (HttpClientRequest request) {
|
| - request.outputStream.close();
|
| - };
|
| - conn.onResponse = (HttpClientResponse response) {
|
| - Expect.isTrue(response.statusCode < 500);
|
| - response.inputStream.onData = () {
|
| - response.inputStream.read();
|
| - };
|
| - response.inputStream.onClosed = () {
|
| - client.shutdown();
|
| - };
|
| - };
|
| - conn.onError = (error) => Expect.fail("Unexpected IO error");
|
| -}
|
|
|
| int testGoogleUrlCount = 0;
|
| void testGoogleUrl() {
|
| @@ -46,29 +28,22 @@ void testGoogleUrl() {
|
| response.inputStream.read();
|
| };
|
| response.inputStream.onClosed = () {
|
| - if (testGoogleUrlCount == 5) client.shutdown();
|
| + if (testGoogleUrlCount == 4) client.shutdown();
|
| };
|
| };
|
| conn.onError = (error) => Expect.fail("Unexpected IO error $error");
|
| }
|
|
|
| - testUrl('http://www.google.com');
|
| - testUrl('http://www.google.com/abc');
|
| - testUrl('http://www.google.com/?abc');
|
| - testUrl('http://www.google.com/abc?abc');
|
| - testUrl('http://www.google.com/abc?abc#abc');
|
| -}
|
| -
|
| -void testInvalidUrl() {
|
| - HttpClient client = new HttpClient();
|
| - Expect.throws(
|
| - () => client.getUrl(new Uri.fromString('ftp://www.google.com')));
|
| + testUrl('https://www.google.dk');
|
| + testUrl('https://www.google.dk');
|
| + testUrl('https://www.google.dk/#q=foo');
|
| + testUrl('https://www.google.dk/#hl=da&q=foo');
|
| }
|
|
|
| void testBadHostName() {
|
| HttpClient client = new HttpClient();
|
| - HttpClientConnection connection =
|
| - client.get("some.bad.host.name.7654321", 0, "/");
|
| + HttpClientConnection connection = client.getUrl(
|
| + new Uri.fromString("https://some.bad.host.name.7654321/"));
|
| connection.onRequest = (HttpClientRequest request) {
|
| Expect.fail("Should not open a request on bad hostname");
|
| };
|
| @@ -78,9 +53,14 @@ void testBadHostName() {
|
| };
|
| }
|
|
|
| +void InitializeSSL() {
|
| + var testPkcertDatabase =
|
| + new Path.fromNative(new Options().script).directoryPath.append('pkcert/');
|
| + SecureSocket.setCertificateDatabase(testPkcertDatabase.toNativePath());
|
| +}
|
| +
|
| void main() {
|
| - testGoogle();
|
| + InitializeSSL();
|
| testGoogleUrl();
|
| - testInvalidUrl();
|
| testBadHostName();
|
| }
|
|
|