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

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

Issue 17589007: dart:io | Change names for SecureSocket exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix bad upload to review tool. Created 7 years, 5 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
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 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_write --short_socket_read 8 // VMOptions=--short_socket_write --short_socket_read
9 // The --short_socket_write option does not work with external server 9 // The --short_socket_write option does not work with external server
10 // www.google.dk. Add this to the test when we have secure server sockets. 10 // www.google.dk. Add this to the test when we have secure server sockets.
(...skipping 13 matching lines...) Expand all
24 acceptCertificate: true).then((_) { 24 acceptCertificate: true).then((_) {
25 keepAlive.close(); 25 keepAlive.close();
26 // TODO(7153): Open a receive port, and close it when we get here. 26 // TODO(7153): Open a receive port, and close it when we get here.
27 // Currently, it can happen that neither onClosed or onError is called. 27 // Currently, it can happen that neither onClosed or onError is called.
28 // So we never reach this point. Diagnose this and fix. 28 // So we never reach this point. Diagnose this and fix.
29 }); 29 });
30 }); 30 });
31 } 31 }
32 32
33 Future testCertificateCallback({String host, bool acceptCertificate}) { 33 Future testCertificateCallback({String host, bool acceptCertificate}) {
34 try { 34 var x = 7;
35 var x = 7; 35 Expect.throws(() => SecureSocket.connect(host, 443, onBadCertificate: x),
36 SecureSocket.connect(host, 443, onBadCertificate: x) 36 (e) => e is ArgumentError || e is TypeError);
37 .catchError((e) {}, test: (e) => e is ArgumentError);
38 } on TypeError catch (e) {
39 }
40 37
41 bool badCertificateCallback(X509Certificate certificate) { 38 bool badCertificateCallback(X509Certificate certificate) {
42 Expect.isTrue(certificate.subject.contains("O=Google Inc")); 39 Expect.isTrue(certificate.subject.contains("O=Google Inc"));
43 Expect.isTrue(certificate.startValidity.isBefore(new DateTime.now())); 40 Expect.isTrue(certificate.startValidity.isBefore(new DateTime.now()));
44 Expect.isTrue(certificate.endValidity.isAfter(new DateTime.now())); 41 Expect.isTrue(certificate.endValidity.isAfter(new DateTime.now()));
45 return acceptCertificate; 42 return acceptCertificate;
46 }; 43 };
47 44
48 return SecureSocket.connect(host, 45 return SecureSocket.connect(host,
49 443, 46 443,
50 onBadCertificate: badCertificateCallback) 47 onBadCertificate: badCertificateCallback)
51 .then((socket) { 48 .then((socket) {
52 Expect.isTrue(acceptCertificate); 49 Expect.isTrue(acceptCertificate);
53 socket.write("GET / HTTP/1.0\r\nHost: $host\r\n\r\n"); 50 socket.write("GET / HTTP/1.0\r\nHost: $host\r\n\r\n");
54 socket.close(); 51 socket.close();
55 return socket.fold(<int>[], (message, data) => message..addAll(data)) 52 return socket.fold(<int>[], (message, data) => message..addAll(data))
56 .then((message) { 53 .then((message) {
57 String received = new String.fromCharCodes(message); 54 String received = new String.fromCharCodes(message);
58 Expect.isTrue(received.contains('</body></html>')); 55 Expect.isTrue(received.contains('</body></html>'));
59 }); 56 });
60 }).catchError((e) { 57 }).catchError((e) {
61 Expect.isFalse(acceptCertificate); 58 Expect.isFalse(acceptCertificate);
62 }); 59 });
63 } 60 }
OLDNEW
« runtime/bin/secure_socket.cc ('K') | « tests/standalone/io/secure_server_socket_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698