Chromium Code Reviews| Index: tests/standalone/io/secure_no_builtin_roots_test.dart |
| diff --git a/tests/standalone/io/secure_no_builtin_roots_test.dart b/tests/standalone/io/secure_no_builtin_roots_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..03ecdd6dfd4e300cddad5bec480afc668dacb277 |
| --- /dev/null |
| +++ b/tests/standalone/io/secure_no_builtin_roots_test.dart |
| @@ -0,0 +1,44 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// 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"; |
| + |
| +void testGoogleUrl() { |
| + ReceivePort keepalivePort = new ReceivePort(); |
| + HttpClient client = new HttpClient(); |
| + |
| + void testUrl(String url) { |
| + var requestUri = new Uri.fromString(url); |
| + var conn = client.getUrl(requestUri); |
| + |
| + conn.onRequest = (HttpClientRequest request) { |
| + request.outputStream.close(); |
| + }; |
| + conn.onResponse = (HttpClientResponse response) { |
| + Expect.fail("Https connection unexpectedly succeeded"); |
| + }; |
| + conn.onError = (error) { |
| + Expect.isTrue(error is SocketIOException); |
| + keepalivePort.close(); |
| + }; |
| + } |
| + |
| + testUrl('https://www.google.com'); |
| +} |
| + |
| +void InitializeSSL() { |
| + // The pkcert_empty database contains no certificates, so if the built-in |
| + // roots certificates aren't loaded, the connection should signal an error. |
| + var testPkcertDatabase = new Path.fromNative(new Options().script). |
| + directoryPath.append('pkcert_empty'); |
| + SecureSocket.setCertificateDatabase(testPkcertDatabase.toNativePath(), |
|
Mads Ager (google)
2012/11/29 20:13:05
SecureSocket.initialize(useBuiltinRoots: false); w
Bill Hesse
2012/11/30 12:51:16
Done.
|
| + useBuiltinRoots: false); |
| +} |
| + |
| +void main() { |
| + InitializeSSL(); |
| + testGoogleUrl(); |
| +} |