Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: tests/standalone/io/https_bad_certificate_client.dart

Issue 22818006: Allow SocketException in https_bad_certificate_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Client for https_bad_certificate_test, that runs in a subprocess. 5 // Client for https_bad_certificate_test, that runs in a subprocess.
6 // It verifies that the client bad certificate callback works in HttpClient. 6 // It verifies that the client bad certificate callback works in HttpClient.
7 7
8 import "dart:async"; 8 import "dart:async";
9 import "dart:io"; 9 import "dart:io";
10 10
(...skipping 22 matching lines...) Expand all
33 expect(result != 'exception'); // Throw exception if one is requested. 33 expect(result != 'exception'); // Throw exception if one is requested.
34 if (result == 'true') return true; 34 if (result == 'true') return true;
35 if (result == 'false') return false; 35 if (result == 'false') return false;
36 return result; 36 return result;
37 } 37 }
38 38
39 HttpClient client = new HttpClient(); 39 HttpClient client = new HttpClient();
40 40
41 var testFutures = []; 41 var testFutures = [];
42 testFutures.add(client.getUrl(Uri.parse('https://$HOST_NAME:$port/$result')) 42 testFutures.add(client.getUrl(Uri.parse('https://$HOST_NAME:$port/$result'))
43 .then((HttpClientRequest request) { expect(false); }, 43 .then((HttpClientRequest request) {
44 onError: (e) { expect(e is HandshakeException); })); 44 expect(false);
45 }, onError: (e) {
46 expect(e is HandshakeException || e is SocketException);
47 }));
45 48
46 client.badCertificateCallback = badCertificateCallback; 49 client.badCertificateCallback = badCertificateCallback;
47 testFutures.add( client.getUrl(Uri.parse('https://$HOST_NAME:$port/$result')) 50 testFutures.add( client.getUrl(Uri.parse('https://$HOST_NAME:$port/$result'))
48 .then((HttpClientRequest request) { 51 .then((HttpClientRequest request) {
49 expect(result == 'true'); 52 expect(result == 'true');
50 request.close().then((result) { }); 53 request.close().then((result) { });
51 }, onError: (e) { 54 }, onError: (e) {
52 if (result == 'false') expect (e is HandshakeException); 55 if (result == 'false') expect (e is HandshakeException ||
53 else if (result == 'exception') expect (e is ExpectException); 56 e is SocketException);
54 else expect (e is ArgumentError); 57 else if (result == 'exception') expect (e is ExpectException ||
58 e is SocketException);
59 else expect (e is ArgumentError || e is SocketException);
55 })); 60 }));
56 61
57 client.badCertificateCallback = null; 62 client.badCertificateCallback = null;
58 testFutures.add(client.getUrl(Uri.parse('https://$HOST_NAME:$port/$result')) 63 testFutures.add(client.getUrl(Uri.parse('https://$HOST_NAME:$port/$result'))
59 .then((HttpClientRequest request) { 64 .then((HttpClientRequest request) {
60 expect(false); 65 expect(false);
61 }, onError: (e) { 66 }, onError: (e) {
62 expect(e is HandshakeException); 67 expect(e is HandshakeException || e is SocketException);
63 })); 68 }));
64 69
65 return Future.wait(testFutures); 70 return Future.wait(testFutures);
66 } 71 }
67 72
68 void main() { 73 void main() {
69 final args = new Options().arguments; 74 final args = new Options().arguments;
70 SecureSocket.initialize(); 75 SecureSocket.initialize();
71 int port = int.parse(args[0]); 76 int port = int.parse(args[0]);
72 runHttpClient(port, args[1]) 77 runHttpClient(port, args[1])
73 .then((_) => print('SUCCESS')); 78 .then((_) => print('SUCCESS'));
74 } 79 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698