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

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

Issue 1665433002: Adds SecurityContext.setTrustedCertificatesBytes (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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:convert'; 6 import 'dart:convert';
7 7
8 import 'package:expect/expect.dart'; 8 import 'package:expect/expect.dart';
9 import 'package:async_helper/async_helper.dart'; 9 import 'package:async_helper/async_helper.dart';
10 10
11 const String NAME_LENGTH_ERROR = 11 const String NAME_LENGTH_ERROR =
12 'Length of protocol must be between 1 and 255'; 12 'Length of protocol must be between 1 and 255';
13 13
14 const String MESSAGE_LENGTH_ERROR = 14 const String MESSAGE_LENGTH_ERROR =
15 'The maximum message length supported is 2^13-1'; 15 'The maximum message length supported is 2^13-1';
16 16
17 String localFile(path) => Platform.script.resolve(path).toFilePath(); 17 String localFile(path) => Platform.script.resolve(path).toFilePath();
18 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync();
19 18
20 SecurityContext clientContext() => new SecurityContext() 19 SecurityContext clientContext() => new SecurityContext()
21 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); 20 ..setTrustedCertificatesSync(localFile('certificates/trusted_certs.pem'));
22 21
23 SecurityContext serverContext() => new SecurityContext() 22 SecurityContext serverContext() => new SecurityContext()
24 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem')) 23 ..useCertificateChainSync(localFile('certificates/server_chain.pem'))
25 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'), 24 ..usePrivateKeySync(localFile('certificates/server_key.pem'),
26 password: 'dartdart'); 25 password: 'dartdart');
27 26
28 // Tests that client/server with same protocol can securely establish a 27 // Tests that client/server with same protocol can securely establish a
29 // connection, negotiate the protocol and can send data to each other. 28 // connection, negotiate the protocol and can send data to each other.
30 void testSuccessfulAlpnNegotiationConnection(List<String> clientProtocols, 29 void testSuccessfulAlpnNegotiationConnection(List<String> clientProtocols,
31 List<String> serverProtocols, 30 List<String> serverProtocols,
32 String selectedProtocol) { 31 String selectedProtocol) {
33 asyncStart(); 32 asyncStart();
34 var sContext = serverContext()..setAlpnProtocols(serverProtocols, true); 33 var sContext = serverContext()..setAlpnProtocols(serverProtocols, true);
35 SecureServerSocket.bind('localhost', 0, sContext) 34 SecureServerSocket.bind('localhost', 0, sContext)
36 .then((SecureServerSocket server) { 35 .then((SecureServerSocket server) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // Issue https://github.com/dart-lang/sdk/issues/23580 195 // Issue https://github.com/dart-lang/sdk/issues/23580
197 // Chromium issue https://code.google.com/p/chromium/issues/detail?id=497770 196 // Chromium issue https://code.google.com/p/chromium/issues/detail?id=497770
198 testSuccessfulAlpnNegotiationConnection(['a'], ['b'], null); 197 testSuccessfulAlpnNegotiationConnection(['a'], ['b'], null);
199 198
200 // Test too short / too long protocol names. 199 // Test too short / too long protocol names.
201 testInvalidArgument([longname256], NAME_LENGTH_ERROR); 200 testInvalidArgument([longname256], NAME_LENGTH_ERROR);
202 testInvalidArgument([strangelongname256], NAME_LENGTH_ERROR); 201 testInvalidArgument([strangelongname256], NAME_LENGTH_ERROR);
203 testInvalidArgument([''], NAME_LENGTH_ERROR); 202 testInvalidArgument([''], NAME_LENGTH_ERROR);
204 testInvalidArgument(tooManyProtocols, MESSAGE_LENGTH_ERROR); 203 testInvalidArgument(tooManyProtocols, MESSAGE_LENGTH_ERROR);
205 } 204 }
OLDNEW
« no previous file with comments | « tests/standalone/io/secure_session_resume_test.dart ('k') | tests/standalone/io/secure_socket_renegotiate_client.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698