| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import "package:expect/expect.dart"; |
| 6 import "dart:io"; |
| 7 |
| 8 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
| 9 |
| 10 bool printException(e) { print(e); return true; } |
| 11 bool argumentError(e) => e is ArgumentError; |
| 12 bool tlsException(e) => e is TlsException; |
| 13 |
| 14 void testUsePrivateKeyArguments() { |
| 15 var c = new SecurityContext(); |
| 16 c.useCertificateChain(localFile('certificates/server_chain.pem')); |
| 17 Expect.throws(() => c.usePrivateKey( |
| 18 localFile('certificates/server_key.pem'), password: "dart" * 1000), |
| 19 argumentError); |
| 20 Expect.throws(() => c.usePrivateKey( |
| 21 localFile('certificates/server_key.pem')), |
| 22 tlsException); |
| 23 Expect.throws(() => c.usePrivateKey( |
| 24 localFile('certificates/server_key.pem'), password: "iHackSites"), |
| 25 tlsException); |
| 26 Expect.throws(() => c.usePrivateKey( |
| 27 localFile('certificates/server_key_oops.pem'), password: "dartdart"), |
| 28 tlsException); |
| 29 Expect.throws(() => c.usePrivateKey(1), argumentError); |
| 30 Expect.throws(() => c.usePrivateKey(null), argumentError); |
| 31 Expect.throws(() => c.usePrivateKey( |
| 32 localFile('certificates/server_key_oops.pem'), password: 3), |
| 33 argumentError); |
| 34 c.usePrivateKey( |
| 35 localFile('certificates/server_key.pem'), password: "dartdart"); |
| 36 } |
| 37 |
| 38 void main() { |
| 39 testUsePrivateKeyArguments(); |
| 40 } |
| OLD | NEW |