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

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

Issue 1757453002: Rolls back fix of SecurityContext method names. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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. 5 // This test verifies that the bad certificate callback works.
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";
11 11
12 final HOST_NAME = 'localhost'; 12 final HOST_NAME = 'localhost';
13 13
14 String localFile(path) => Platform.script.resolve(path).toFilePath(); 14 String localFile(path) => Platform.script.resolve(path).toFilePath();
15 15
16 SecurityContext serverContext = new SecurityContext() 16 SecurityContext serverContext = new SecurityContext()
17 ..useCertificateChainSync(localFile('certificates/server_chain.pem')) 17 ..useCertificateChain(localFile('certificates/server_chain.pem'))
18 ..usePrivateKeySync(localFile('certificates/server_key.pem'), 18 ..usePrivateKey(localFile('certificates/server_key.pem'),
19 password: 'dartdart'); 19 password: 'dartdart');
20 20
21 class CustomException {} 21 class CustomException {}
22 22
23 main() async { 23 main() async {
24 var HOST = (await InternetAddress.lookup(HOST_NAME)).first; 24 var HOST = (await InternetAddress.lookup(HOST_NAME)).first;
25 var server = await SecureServerSocket.bind(HOST_NAME, 0, serverContext); 25 var server = await SecureServerSocket.bind(HOST_NAME, 0, serverContext);
26 server.listen((SecureSocket socket) { 26 server.listen((SecureSocket socket) {
27 socket.listen((_) {}, onDone: () { 27 socket.listen((_) {}, onDone: () {
28 socket.close(); 28 socket.close();
29 }); 29 });
30 }, onError: (e) { if (e is! HandshakeException) throw e; }); 30 }, onError: (e) { if (e is! HandshakeException) throw e; });
31 31
32 SecurityContext goodContext = new SecurityContext() 32 SecurityContext goodContext = new SecurityContext()
33 ..setTrustedCertificatesSync(localFile('certificates/trusted_certs.pem')); 33 ..setTrustedCertificates(localFile('certificates/trusted_certs.pem'));
34 SecurityContext badContext = new SecurityContext(); 34 SecurityContext badContext = new SecurityContext();
35 SecurityContext defaultContext = SecurityContext.defaultContext; 35 SecurityContext defaultContext = SecurityContext.defaultContext;
36 36
37 await runClient(server.port, goodContext, true, 'pass'); 37 await runClient(server.port, goodContext, true, 'pass');
38 await runClient(server.port, goodContext, false, 'pass'); 38 await runClient(server.port, goodContext, false, 'pass');
39 await runClient(server.port, goodContext, 'fisk', 'pass'); 39 await runClient(server.port, goodContext, 'fisk', 'pass');
40 await runClient(server.port, goodContext, 'exception', 'pass'); 40 await runClient(server.port, goodContext, 'exception', 'pass');
41 await runClient(server.port, badContext, true, 'pass'); 41 await runClient(server.port, badContext, true, 'pass');
42 await runClient(server.port, badContext, false, 'fail'); 42 await runClient(server.port, badContext, false, 'fail');
43 await runClient(server.port, badContext, 'fisk', 'fail'); 43 await runClient(server.port, badContext, 'fisk', 'fail');
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 Expect.notEquals(result, 'pass'); 75 Expect.notEquals(result, 'pass');
76 if (result == 'fail') { 76 if (result == 'fail') {
77 Expect.isTrue(error is HandshakeException || error is ArgumentError); 77 Expect.isTrue(error is HandshakeException || error is ArgumentError);
78 } else if (result == 'throw') { 78 } else if (result == 'throw') {
79 Expect.isTrue(error is CustomException); 79 Expect.isTrue(error is CustomException);
80 } else { 80 } else {
81 Expect.fail('Unknown expectation $result'); 81 Expect.fail('Unknown expectation $result');
82 } 82 }
83 } 83 }
84 } 84 }
OLDNEW
« no previous file with comments | « tests/standalone/io/regress_21160_test.dart ('k') | tests/standalone/io/secure_client_raw_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698