| 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 that makes HttpClient secure gets from a server that replies with |
| 6 // a certificate that can't be authenticated. This checks that all the |
| 7 // futures returned from these connection attempts complete (with errors). |
| 8 |
| 9 import "dart:async"; |
| 10 import "dart:io"; |
| 11 |
| 12 class ExpectException implements Exception { |
| 13 ExpectException(this.message); |
| 14 String toString() => "ExpectException: $message"; |
| 15 String message; |
| 16 } |
| 17 |
| 18 void expect(condition) { |
| 19 if (!condition) { |
| 20 throw new ExpectException(''); |
| 21 } |
| 22 } |
| 23 |
| 24 const HOST_NAME = "localhost"; |
| 25 |
| 26 Future runClients(int port) { |
| 27 HttpClient client = new HttpClient(); |
| 28 |
| 29 var testFutures = []; |
| 30 for (int i = 0; i < 20; ++i) { |
| 31 testFutures.add( |
| 32 client.getUrl(Uri.parse('https://$HOST_NAME:$port/')) |
| 33 .then((HttpClientRequest request) { |
| 34 expect(false); |
| 35 }, onError: (e) { |
| 36 expect(e is HandshakeException || e is SocketException); |
| 37 })); |
| 38 } |
| 39 return Future.wait(testFutures); |
| 40 } |
| 41 |
| 42 void main() { |
| 43 final args = new Options().arguments; |
| 44 SecureSocket.initialize(); |
| 45 runClients(int.parse(args[0])) |
| 46 .then((_) => print('SUCCESS')); |
| 47 } |
| OLD | NEW |