| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import "dart:io"; | 6 import "dart:io"; |
| 7 | 7 |
| 8 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 8 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
| 9 | 9 |
| 10 bool printException(e) { print(e); return true; } | 10 bool printException(e) { print(e); return true; } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 Expect.throws(() => c.usePrivateKeySync( | 28 Expect.throws(() => c.usePrivateKeySync( |
| 29 localFile('certificates/server_key_oops.pem'), | 29 localFile('certificates/server_key_oops.pem'), |
| 30 password: "dartdart"), | 30 password: "dartdart"), |
| 31 fileSystemException); | 31 fileSystemException); |
| 32 Expect.throws(() => c.usePrivateKeySync(1), argumentOrTypeError); | 32 Expect.throws(() => c.usePrivateKeySync(1), argumentOrTypeError); |
| 33 Expect.throws(() => c.usePrivateKeySync(null), argumentError); | 33 Expect.throws(() => c.usePrivateKeySync(null), argumentError); |
| 34 Expect.throws(() => c.usePrivateKeySync( | 34 Expect.throws(() => c.usePrivateKeySync( |
| 35 localFile('certificates/server_key.pem'), password: 3), | 35 localFile('certificates/server_key.pem'), password: 3), |
| 36 argumentOrTypeError); | 36 argumentOrTypeError); |
| 37 | 37 |
| 38 // Empty data. |
| 39 Expect.throws(() => c.usePrivateKeyBytes([], password: 'dartdart'), |
| 40 tlsException); |
| 41 Expect.throws(() => c.setTrustedCertificatesBytes([]), tlsException); |
| 42 Expect.throws(() => c.useCertificateChainBytes([]), tlsException); |
| 43 Expect.throws(() => c.setClientAuthoritiesBytes([]), argumentError); |
| 44 |
| 38 // Malformed PEM certs. | 45 // Malformed PEM certs. |
| 39 Expect.throws(() => c.usePrivateKeySync( | 46 Expect.throws(() => c.usePrivateKeySync( |
| 40 localFile('certificates/client1_key_malformed.pem'), | 47 localFile('certificates/client1_key_malformed.pem'), |
| 41 password: "dartdart"), | 48 password: "dartdart"), |
| 42 tlsException); | 49 tlsException); |
| 43 Expect.throws(() => c.setTrustedCertificatesSync( | 50 Expect.throws(() => c.setTrustedCertificatesSync( |
| 44 localFile('certificates/trusted_certs_malformed.pem')), | 51 localFile('certificates/trusted_certs_malformed.pem')), |
| 45 tlsException); | 52 tlsException); |
| 46 Expect.throws(() => c.useCertificateChainSync( | 53 Expect.throws(() => c.useCertificateChainSync( |
| 47 localFile('certificates/server_chain_malformed1.pem')), | 54 localFile('certificates/server_chain_malformed1.pem')), |
| 48 tlsException); | 55 tlsException); |
| 49 Expect.throws(() => c.useCertificateChainSync( | 56 Expect.throws(() => c.useCertificateChainSync( |
| 50 localFile('certificates/server_chain_malformed2.pem')), | 57 localFile('certificates/server_chain_malformed2.pem')), |
| 51 tlsException); | 58 tlsException); |
| 52 Expect.throws(() => c.setClientAuthoritiesSync( | 59 Expect.throws(() => c.setClientAuthoritiesSync( |
| 53 localFile('certificates/client_authority_malformed.pem')), | 60 localFile('certificates/client_authority_malformed.pem')), |
| 54 argumentError); | 61 argumentError); |
| 55 | 62 |
| 56 c.usePrivateKeySync( | 63 c.usePrivateKeySync( |
| 57 localFile('certificates/server_key.pem'), password: "dartdart"); | 64 localFile('certificates/server_key.pem'), password: "dartdart"); |
| 58 } | 65 } |
| 59 | 66 |
| 60 void main() { | 67 void main() { |
| 61 testUsePrivateKeyArguments(); | 68 testUsePrivateKeyArguments(); |
| 62 } | 69 } |
| OLD | NEW |