| 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 57%
|
| copy from tests/standalone/io/http_client_test.dart
|
| copy to tests/standalone/io/https_client_test.dart
|
| index 6c3c54976d9cae128f298be66c14f65dc32ea6a8..c17c67a2c76a2b30472725627512345d57f3677b 100644
|
| --- a/tests/standalone/io/http_client_test.dart
|
| +++ b/tests/standalone/io/https_client_test.dart
|
| @@ -6,24 +6,6 @@
|
| #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();
|
| }
|
|
|