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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import "dart:io"; 5 import "dart:io";
6 import "dart:async"; 6 import "dart:async";
7 7
8 import "package:async_helper/async_helper.dart"; 8 import "package:async_helper/async_helper.dart";
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 10
11 Future testGoogleUrl(SecurityContext context, String outcome) async { 11 Future testGoogleUrl(SecurityContext context, String outcome) async {
12 var client = new HttpClient(context: context); 12 var client = new HttpClient(context: context);
13 // We need to use an external server that is backed by a 13 // We need to use an external server that is backed by a
14 // built-in root certificate authority. 14 // built-in root certificate authority.
15 try { 15 try {
16 // First, check if the lookup works. 16 // First, check if the lookup works.
17 await InternetAddress.lookup('www.google.com'); 17 await InternetAddress.lookup('www.google.com');
18 var request = await client.getUrl(Uri.parse('https://www.google.com')); 18 var request = await client.getUrl(Uri.parse('https://www.google.com'));
19 request.followRedirects = false; 19 request.followRedirects = false;
20 var response = await request.close(); 20 var response = await request.close();
21 Expect.equals('pass', outcome, 'Unexpected successful connection'); 21 Expect.equals('pass', outcome, 'Unexpected successful connection');
22 try { await response.drain(); } catch (e) { } 22 try {
23 await response.drain();
24 } catch (e) {}
23 } on HandshakeException { 25 } on HandshakeException {
24 Expect.equals('fail', outcome, 'Unexpected failed connection'); 26 Expect.equals('fail', outcome, 'Unexpected failed connection');
25 } on SocketException { 27 } on SocketException {
26 // Lookup failed or connection failed. Don't report a failure. 28 // Lookup failed or connection failed. Don't report a failure.
27 } finally { 29 } finally {
28 client.close(); 30 client.close();
29 } 31 }
30 } 32 }
31 33
32
33 main() async { 34 main() async {
34 asyncStart(); 35 asyncStart();
35 await testGoogleUrl(null, "pass"); 36 await testGoogleUrl(null, "pass");
36 await testGoogleUrl(SecurityContext.defaultContext, "pass"); 37 await testGoogleUrl(SecurityContext.defaultContext, "pass");
37 await testGoogleUrl(new SecurityContext(), "fail"); 38 await testGoogleUrl(new SecurityContext(), "fail");
38 asyncEnd(); 39 asyncEnd();
39 } 40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698