Chromium Code Reviews| Index: test/utils.dart |
| diff --git a/test/utils.dart b/test/utils.dart |
| index 80c16ca20020cf591444c110df9416cf9288e09b..047e56a4b8eb79847ef9917c88c7ee2ec086f029 100644 |
| --- a/test/utils.dart |
| +++ b/test/utils.dart |
| @@ -13,6 +13,9 @@ import 'package:http_server/http_server.dart'; |
| import 'http_mock.dart'; |
| +SecurityContext serverContext; |
| +SecurityContext clientContext; |
| + |
| /** |
| * Used to flag a given test case as being a mock or not. |
| */ |
| @@ -85,7 +88,13 @@ Future<int> getStatusCode(int port, |
| int to}) { |
| var uri = _getUri(port, path, secure: secure, rawPath: rawPath); |
| - var client = new HttpClient(); |
| + if (secure) print(clientContext); |
|
Bill Hesse
2015/11/11 17:43:22
Debug printing? Does a context print anything?
Søren Gjesse
2015/11/12 07:37:29
Removed.
|
| + var client; |
| + if (secure) { |
| + client = new HttpClient(context: clientContext); |
|
Bill Hesse
2015/11/11 17:43:22
This is actually OK to call with clientContext nul
Søren Gjesse
2015/11/12 07:37:29
There are tests which combine secure and non-secur
|
| + } else { |
| + client = new HttpClient(); |
| + } |
| return client.getUrl(uri) |
| .then((request) { |
| if (!followRedirects) request.followRedirects = false; |
| @@ -294,7 +303,13 @@ const CERTIFICATE = "localhost_cert"; |
| void setupSecure() { |
| - String certificateDatabase = Platform.script.resolve('pkcert').toFilePath(); |
| - SecureSocket.initialize(database: certificateDatabase, |
| - password: 'dartdart'); |
| + String localFile(path) => Platform.script.resolve(path).toFilePath(); |
| + |
| + serverContext = new SecurityContext() |
| + ..useCertificateChain(localFile('certificates/server_chain.pem')) |
| + ..usePrivateKey(localFile('certificates/server_key.pem'), |
| + password: 'dartdart'); |
| + |
| + clientContext = new SecurityContext() |
| + ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); |
| } |