| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // VMOptions= | 5 // VMOptions= |
| 6 // VMOptions=--short_socket_read | 6 // VMOptions=--short_socket_read |
| 7 // VMOptions=--short_socket_write | 7 // VMOptions=--short_socket_write |
| 8 // VMOptions=--short_socket_read --short_socket_write | 8 // VMOptions=--short_socket_read --short_socket_write |
| 9 | 9 |
| 10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
| 11 import "package:path/path.dart"; | 11 import "package:path/path.dart"; |
| 12 import "dart:async"; | 12 import "dart:async"; |
| 13 import "dart:io"; | 13 import "dart:io"; |
| 14 import "dart:isolate"; | 14 import "dart:isolate"; |
| 15 | 15 |
| 16 const SERVER_ADDRESS = "127.0.0.1"; | 16 const SERVER_ADDRESS = "127.0.0.1"; |
| 17 const CERTIFICATE = "localhost_cert"; | 17 const CERTIFICATE = "localhost_cert"; |
| 18 | 18 |
| 19 | 19 |
| 20 void testArguments() { | 20 void testArguments() { |
| 21 bool isArgOrTypeError(e) => e is ArgumentError || e is TypeError; | 21 bool isArgOrTypeError(e) => e is ArgumentError || e is TypeError; |
| 22 Expect.throws(() => | 22 Expect.throws(() => |
| 23 RawSecureServerSocket.bind(SERVER_ADDRESS, 65536, CERTIFICATE), | 23 RawSecureServerSocket.bind(SERVER_ADDRESS, 65536, null), |
| 24 isArgOrTypeError); | 24 isArgOrTypeError); |
| 25 Expect.throws(() => | 25 Expect.throws(() => |
| 26 RawSecureServerSocket.bind(SERVER_ADDRESS, -1, CERTIFICATE), | 26 RawSecureServerSocket.bind(SERVER_ADDRESS, -1, null), |
| 27 isArgOrTypeError); | 27 isArgOrTypeError); |
| 28 Expect.throws(() => RawSecureServerSocket.bind(SERVER_ADDRESS, 0, | 28 Expect.throws(() => RawSecureServerSocket.bind(SERVER_ADDRESS, 0, |
| 29 CERTIFICATE, backlog: -1), | 29 null, backlog: -1), |
| 30 isArgOrTypeError); | |
| 31 Expect.throws(() => RawSecureSocket.connect(SERVER_ADDRESS, 3456, | |
| 32 sendClientCertificate: true, | |
| 33 certificateName: 12.3), | |
| 34 isArgOrTypeError); | 30 isArgOrTypeError); |
| 35 Expect.throws(() => RawSecureSocket.connect(SERVER_ADDRESS, null), | 31 Expect.throws(() => RawSecureSocket.connect(SERVER_ADDRESS, null), |
| 36 isArgOrTypeError); | 32 isArgOrTypeError); |
| 37 Expect.throws(() => RawSecureSocket.connect(SERVER_ADDRESS, -1), | 33 Expect.throws(() => RawSecureSocket.connect(SERVER_ADDRESS, -1), |
| 38 isArgOrTypeError); | 34 isArgOrTypeError); |
| 39 Expect.throws(() => RawSecureSocket.connect(SERVER_ADDRESS, 345656), | 35 Expect.throws(() => RawSecureSocket.connect(SERVER_ADDRESS, 345656), |
| 40 isArgOrTypeError); | 36 isArgOrTypeError); |
| 41 Expect.throws(() => RawSecureSocket.connect(SERVER_ADDRESS, 'hest'), | 37 Expect.throws(() => RawSecureSocket.connect(SERVER_ADDRESS, 'hest'), |
| 42 isArgOrTypeError); | 38 isArgOrTypeError); |
| 43 Expect.throws(() => RawSecureSocket.connect(null, 0), | 39 Expect.throws(() => RawSecureSocket.connect(null, 0), |
| 44 isArgOrTypeError); | 40 isArgOrTypeError); |
| 45 Expect.throws(() => RawSecureSocket.connect(SERVER_ADDRESS, 0, | 41 Expect.throws(() => RawSecureSocket.connect(SERVER_ADDRESS, 0, |
| 46 certificateName: 77), | |
| 47 isArgOrTypeError); | |
| 48 Expect.throws(() => RawSecureSocket.connect(SERVER_ADDRESS, 0, | |
| 49 sendClientCertificate: 'fisk'), | |
| 50 isArgOrTypeError); | |
| 51 Expect.throws(() => RawSecureSocket.connect(SERVER_ADDRESS, 0, | |
| 52 onBadCertificate: 'hund'), | 42 onBadCertificate: 'hund'), |
| 53 isArgOrTypeError); | 43 isArgOrTypeError); |
| 54 } | 44 } |
| 55 | 45 |
| 56 | 46 |
| 57 main() { | 47 main() { |
| 58 var certificateDatabase = Platform.script.resolve('pkcert').toFilePath(); | |
| 59 SecureSocket.initialize(database: certificateDatabase, | |
| 60 password: 'dartdart', | |
| 61 useBuiltinRoots: false); | |
| 62 testArguments(); | 48 testArguments(); |
| 63 } | 49 } |
| OLD | NEW |