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

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

Issue 1665433002: Adds SecurityContext.setTrustedCertificatesBytes (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Adds MemBIOScope Created 4 years, 10 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) 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 14 matching lines...) Expand all
25 var HOST = (await InternetAddress.lookup(HOST_NAME)).first; 25 var HOST = (await InternetAddress.lookup(HOST_NAME)).first;
26 var server = await HttpServer.bindSecure(HOST, 0, serverContext, backlog: 5); 26 var server = await HttpServer.bindSecure(HOST, 0, serverContext, backlog: 5);
27 server.listen((request) { 27 server.listen((request) {
28 request.listen((_) { 28 request.listen((_) {
29 }, onDone: () { 29 }, onDone: () {
30 request.response.close(); 30 request.response.close();
31 }); 31 });
32 }); 32 });
33 33
34 SecurityContext goodContext = new SecurityContext() 34 SecurityContext goodContext = new SecurityContext()
35 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); 35 ..setTrustedCertificatesBytes(
36 readLocalFile('certificates/trusted_certs.pem'));
36 SecurityContext badContext = new SecurityContext(); 37 SecurityContext badContext = new SecurityContext();
37 SecurityContext defaultContext = SecurityContext.defaultContext; 38 SecurityContext defaultContext = SecurityContext.defaultContext;
38 39
39 await runClient(server.port, goodContext, true, 'pass'); 40 await runClient(server.port, goodContext, true, 'pass');
40 await runClient(server.port, goodContext, false, 'pass'); 41 await runClient(server.port, goodContext, false, 'pass');
41 await runClient(server.port, goodContext, 'fisk', 'pass'); 42 await runClient(server.port, goodContext, 'fisk', 'pass');
42 await runClient(server.port, goodContext, 'exception', 'pass'); 43 await runClient(server.port, goodContext, 'exception', 'pass');
43 await runClient(server.port, badContext, true, 'pass'); 44 await runClient(server.port, badContext, true, 'pass');
44 await runClient(server.port, badContext, false, 'fail'); 45 await runClient(server.port, badContext, false, 'fail');
45 await runClient(server.port, badContext, 'fisk', 'fail'); 46 await runClient(server.port, badContext, 'fisk', 'fail');
(...skipping 27 matching lines...) Expand all
73 Expect.notEquals(result, 'pass'); 74 Expect.notEquals(result, 'pass');
74 if (result == 'fail') { 75 if (result == 'fail') {
75 Expect.isTrue(error is HandshakeException); 76 Expect.isTrue(error is HandshakeException);
76 } else if (result == 'throw') { 77 } else if (result == 'throw') {
77 Expect.isTrue(error is CustomException); 78 Expect.isTrue(error is CustomException);
78 } else { 79 } else {
79 Expect.fail('Unknown expectation $result'); 80 Expect.fail('Unknown expectation $result');
80 } 81 }
81 } 82 }
82 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698