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

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

Issue 24740002: Fix https_bad_certificate_test: allow for session cache to be hit in all getUrl calls (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 20 matching lines...) Expand all
31 expect('CN=localhost' == certificate.subject); 31 expect('CN=localhost' == certificate.subject);
32 expect('CN=myauthority' == certificate.issuer); 32 expect('CN=myauthority' == certificate.issuer);
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 = []; // The three async getUrl calls run simultaneously.
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) { 43 .then((HttpClientRequest request) {
44 expect(false); 44 expect(result == 'true'); // The session cache may keep the session.
45 }, onError: (e) { 45 }, onError: (e) {
46 expect(e is HandshakeException || e is SocketException); 46 expect(e is HandshakeException || e is SocketException);
47 })); 47 }));
48 48
49 client.badCertificateCallback = badCertificateCallback; 49 client.badCertificateCallback = badCertificateCallback;
50 testFutures.add(client.getUrl(Uri.parse('https://$HOST_NAME:$port/$result')) 50 testFutures.add(client.getUrl(Uri.parse('https://$HOST_NAME:$port/$result'))
51 .then((HttpClientRequest request) { 51 .then((HttpClientRequest request) {
52 expect(result == 'true'); 52 expect(result == 'true');
kasperl 2013/09/26 10:52:56 Should this have a "The session cache may keep the
Bill Hesse 2013/09/26 11:31:36 No, this one succeeds always, and its success is w
53 request.close().then((result) { }); 53 request.close().then((result) { });
54 }, onError: (e) { 54 }, onError: (e) {
55 if (result == 'false') expect (e is HandshakeException || 55 if (result == 'false') expect (e is HandshakeException ||
56 e is SocketException); 56 e is SocketException);
57 else if (result == 'exception') expect (e is ExpectException || 57 else if (result == 'exception') expect (e is ExpectException ||
58 e is SocketException); 58 e is SocketException);
59 else expect (e is ArgumentError || e is SocketException); 59 else expect (e is ArgumentError || e is SocketException);
60 })); 60 }));
61 61
62 client.badCertificateCallback = null; 62 client.badCertificateCallback = null;
63 testFutures.add(client.getUrl(Uri.parse('https://$HOST_NAME:$port/$result')) 63 testFutures.add(client.getUrl(Uri.parse('https://$HOST_NAME:$port/$result'))
64 .then((HttpClientRequest request) { 64 .then((HttpClientRequest request) {
65 expect(result == 'true'); // The session cache may keep the session. 65 expect(result == 'true'); // The session cache may keep the session.
66 }, onError: (e) { 66 }, onError: (e) {
67 expect(e is HandshakeException || e is SocketException); 67 expect(e is HandshakeException || e is SocketException);
68 })); 68 }));
69 69
70 return Future.wait(testFutures); 70 return Future.wait(testFutures);
71 } 71 }
72 72
73 void main() { 73 void main() {
74 final args = new Options().arguments; 74 final args = new Options().arguments;
75 SecureSocket.initialize(); 75 SecureSocket.initialize();
76 int port = int.parse(args[0]); 76 int port = int.parse(args[0]);
77 runHttpClient(port, args[1]) 77 runHttpClient(port, args[1])
78 .then((_) => print('SUCCESS')); 78 .then((_) => print('SUCCESS'));
79 } 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