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

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

Issue 1648793005: Adds SecurityContext.useCertificateChainBytes (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: *AsBytes -> *Bytes 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. 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 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync(); 15 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync();
16 16
17 SecurityContext serverContext = new SecurityContext() 17 SecurityContext serverContext = new SecurityContext()
18 ..useCertificateChain(localFile('certificates/server_chain.pem')) 18 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem'))
19 ..usePrivateKeyAsBytes(readLocalFile('certificates/server_key.pem'), 19 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'),
20 password: 'dartdart'); 20 password: 'dartdart');
21 21
22 class CustomException {} 22 class CustomException {}
23 23
24 main() async { 24 main() async {
25 var HOST = (await InternetAddress.lookup(HOST_NAME)).first; 25 var HOST = (await InternetAddress.lookup(HOST_NAME)).first;
26 var server = await SecureServerSocket.bind(HOST_NAME, 0, serverContext); 26 var server = await SecureServerSocket.bind(HOST_NAME, 0, serverContext);
27 server.listen((SecureSocket socket) { 27 server.listen((SecureSocket socket) {
28 socket.listen((_) {}, onDone: () { 28 socket.listen((_) {}, onDone: () {
29 socket.close(); 29 socket.close();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 Expect.notEquals(result, 'pass'); 76 Expect.notEquals(result, 'pass');
77 if (result == 'fail') { 77 if (result == 'fail') {
78 Expect.isTrue(error is HandshakeException || error is ArgumentError); 78 Expect.isTrue(error is HandshakeException || error is ArgumentError);
79 } else if (result == 'throw') { 79 } else if (result == 'throw') {
80 Expect.isTrue(error is CustomException); 80 Expect.isTrue(error is CustomException);
81 } else { 81 } else {
82 Expect.fail('Unknown expectation $result'); 82 Expect.fail('Unknown expectation $result');
83 } 83 }
84 } 84 }
85 } 85 }
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