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

Side by Side Diff: tests/standalone/io/secure_unauthorized_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 failing secure connection attempts always complete 5 // This test verifies that failing secure connection attempts always complete
6 // their returned future. 6 // their returned future.
7 7
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import "package:path/path.dart"; 9 import "package:path/path.dart";
10 import "dart:async"; 10 import "dart:async";
11 import "dart:io"; 11 import "dart:io";
12 12
13 const HOST_NAME = "localhost"; 13 const HOST_NAME = "localhost";
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/untrusted_server_chain.pem')) 18 ..useCertificateChainBytes(readLocalFile(
19 ..usePrivateKeyAsBytes(readLocalFile('certificates/untrusted_server_key.pem'), 19 'certificates/untrusted_server_chain.pem'))
20 ..usePrivateKeyBytes(readLocalFile('certificates/untrusted_server_key.pem'),
20 password: 'dartdart'); 21 password: 'dartdart');
21 22
22 Future<SecureServerSocket> runServer() { 23 Future<SecureServerSocket> runServer() {
23 return SecureServerSocket.bind(HOST_NAME, 0, serverContext) 24 return SecureServerSocket.bind(HOST_NAME, 0, serverContext)
24 .then((SecureServerSocket server) { 25 .then((SecureServerSocket server) {
25 server.listen((SecureSocket socket) { 26 server.listen((SecureSocket socket) {
26 socket.listen((_) { }, 27 socket.listen((_) { },
27 onDone: () { 28 onDone: () {
28 socket.close(); 29 socket.close();
29 }); 30 });
(...skipping 21 matching lines...) Expand all
51 } 52 }
52 }); 53 });
53 } 54 }
54 55
55 runServer().then((server) { 56 runServer().then((server) {
56 clientProcess(server.port).then((_) { 57 clientProcess(server.port).then((_) {
57 server.close(); 58 server.close();
58 }); 59 });
59 }); 60 });
60 } 61 }
OLDNEW
« no previous file with comments | « tests/standalone/io/secure_socket_test.dart ('k') | tests/standalone/io/security_context_argument_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698