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 // This test verifies that the bad certificate callback works in HttpClient. | 5 // This test verifies that the bad certificate callback works in HttpClient. |
6 | 6 |
7 import "dart:async"; | 7 import "dart:async"; |
8 import "dart:io"; | 8 import "dart:io"; |
9 | 9 |
10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 return callbackReturns; | 64 return callbackReturns; |
65 }; | 65 }; |
66 | 66 |
67 try { | 67 try { |
68 var request = await client.getUrl(Uri.parse('https://$HOST_NAME:$port/')); | 68 var request = await client.getUrl(Uri.parse('https://$HOST_NAME:$port/')); |
69 Expect.equals('pass', result); | 69 Expect.equals('pass', result); |
70 await request.close(); | 70 await request.close(); |
71 } catch (error) { | 71 } catch (error) { |
72 Expect.notEquals(result, 'pass'); | 72 Expect.notEquals(result, 'pass'); |
73 if (result == 'fail') { | 73 if (result == 'fail') { |
74 Expect.isTrue(error is HandshakeException || | 74 Expect.isTrue(error is HandshakeException); |
75 (callbackReturns is! bool && error is TypeError)); | |
76 } else if (result == 'throw') { | 75 } else if (result == 'throw') { |
77 Expect.isTrue(error is CustomException); | 76 Expect.isTrue(error is CustomException); |
78 } else { | 77 } else { |
79 Expect.fail('Unknown expectation $result'); | 78 Expect.fail('Unknown expectation $result'); |
80 } | 79 } |
81 } | 80 } |
82 } | 81 } |
OLD | NEW |