Chromium Code Reviews| Index: tests/standalone/io/certificate_test_client.dart |
| diff --git a/tests/standalone/io/certificate_test_client.dart b/tests/standalone/io/certificate_test_client.dart |
| index f7f2fb238e0a37139cdf0d9f182541edb6b2b9ea..70ca0d58a83bbbe484c40aa2802b8ed11fa37e1a 100644 |
| --- a/tests/standalone/io/certificate_test_client.dart |
| +++ b/tests/standalone/io/certificate_test_client.dart |
| @@ -13,6 +13,7 @@ void main() { |
| int port = int.parse(new Options().arguments[0]); |
| String certificate = new Options().arguments[1]; |
| SecureSocket.initialize(); |
| + // SecureSocket.initialize(database: "/usr/local/google/home/whesse/ssd/dart/tests/standalone/io/pkcert", password: 'dartdart', readOnly: false); |
|
Søren Gjesse
2013/08/08 19:03:42
Long line and absolute path to your home dir.
|
| var mycert = new File(certificate).readAsBytesSync(); |
| bool threw = false; |
| try { |
| @@ -21,7 +22,7 @@ void main() { |
| } on CertificateException catch (e) { |
| threw = true; |
| } |
| - if (!threw) throw new AssertException("Expected bad certificate to throw"); |
| + if (!threw) throw "Expected bad certificate to throw"; |
| threw = false; |
| try { |
| @@ -29,13 +30,37 @@ void main() { |
| } on CertificateException catch (e) { |
| threw = true; |
| } |
| - if (!threw) throw new AssertException("Expected bad trust string to throw"); |
| + if (!threw) throw "Expected bad trust string to throw"; |
| SecureSocket.addCertificate(mycert, |
| SecureSocket.TRUST_ISSUE_SERVER_CERTIFICATES); |
| + |
| SecureSocket.connect('localhost', port).then((SecureSocket socket) { |
| - socket.writeln("hello world"); |
| + socket.writeln('hello world'); |
| + socket.listen((data) { }); |
| + return socket.close(); |
| + }).then((_) { |
| + SecureSocket.changeTrust('myauthority_cert', ',,'); |
| + return SecureSocket.connect('localhost', port); |
| + }).then((_) { |
| + throw "Expected untrusted authority to stop connection"; |
| + }, onError: (e) { |
| + if (e is! CertificateException) throw e; |
| + }).then((_) { |
| + SecureSocket.changeTrust('myauthority_cert', 'C,,'); |
| + return SecureSocket.connect('localhost', port); |
| + }).then((SecureSocket socket) { |
| + socket.writeln('hello world'); |
| socket.listen((data) { }); |
| - socket.close(); |
| + return socket.close(); |
| + }).then((_) { |
| + SecureSocket.removeCertificate('myauthority_cert'); |
| + return SecureSocket.connect('localhost', port); |
| + }).then((_) { |
| + throw "Expected untrusted root to stop connection"; |
| + }, onError: (e) { |
| + if (e is! CertificateException) throw e; |
| + }).then((_) { |
| + print('SUCCESS'); // Checked by parent process. |
| }); |
| } |