| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // Client for secure_bad_certificate_test, that runs in a subprocess. |
| 6 // The test verifies that the client bad certificate callback works. |
| 7 |
| 8 import "dart:async"; |
| 9 import "dart:io"; |
| 10 |
| 11 class ExpectException implements Exception { |
| 12 ExpectException(this.message); |
| 13 String toString() => "ExpectException: $message"; |
| 14 String message; |
| 15 } |
| 16 |
| 17 void expect(condition) { |
| 18 if (!condition) { |
| 19 throw new ExpectException(''); |
| 20 } |
| 21 } |
| 22 |
| 23 const HOST_NAME = "localhost"; |
| 24 |
| 25 Future runClients(int port) { |
| 26 var testFutures = []; |
| 27 for (int i = 0; i < 20; ++i) { |
| 28 testFutures.add( |
| 29 SecureSocket.connect(HOST_NAME, port) |
| 30 .then((SecureSocket socket) { |
| 31 expect(false); |
| 32 }, onError: (e) { |
| 33 expect(e is HandshakeException || e is SocketException); |
| 34 })); |
| 35 } |
| 36 return Future.wait(testFutures); |
| 37 } |
| 38 |
| 39 |
| 40 void main() { |
| 41 final args = new Options().arguments; |
| 42 SecureSocket.initialize(); |
| 43 runClients(int.parse(args[0])) |
| 44 .then((_) => print('SUCCESS')); |
| 45 } |
| OLD | NEW |