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

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: 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) 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(); 18 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync();
19 19
20 SecurityContext clientContext() => new SecurityContext() 20 SecurityContext clientContext() => new SecurityContext()
21 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); 21 ..setTrustedCertificatesBytes(
22 readLocalFile('certificates/trusted_certs.pem'));
22 23
23 SecurityContext serverContext() => new SecurityContext() 24 SecurityContext serverContext() => new SecurityContext()
24 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem')) 25 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem'))
25 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'), 26 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'),
26 password: 'dartdart'); 27 password: 'dartdart');
27 28
28 // Tests that client/server with same protocol can securely establish a 29 // Tests that client/server with same protocol can securely establish a
29 // connection, negotiate the protocol and can send data to each other. 30 // connection, negotiate the protocol and can send data to each other.
30 void testSuccessfulAlpnNegotiationConnection(List<String> clientProtocols, 31 void testSuccessfulAlpnNegotiationConnection(List<String> clientProtocols,
31 List<String> serverProtocols, 32 List<String> serverProtocols,
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // Issue https://github.com/dart-lang/sdk/issues/23580 197 // Issue https://github.com/dart-lang/sdk/issues/23580
197 // Chromium issue https://code.google.com/p/chromium/issues/detail?id=497770 198 // Chromium issue https://code.google.com/p/chromium/issues/detail?id=497770
198 testSuccessfulAlpnNegotiationConnection(['a'], ['b'], null); 199 testSuccessfulAlpnNegotiationConnection(['a'], ['b'], null);
199 200
200 // Test too short / too long protocol names. 201 // Test too short / too long protocol names.
201 testInvalidArgument([longname256], NAME_LENGTH_ERROR); 202 testInvalidArgument([longname256], NAME_LENGTH_ERROR);
202 testInvalidArgument([strangelongname256], NAME_LENGTH_ERROR); 203 testInvalidArgument([strangelongname256], NAME_LENGTH_ERROR);
203 testInvalidArgument([''], NAME_LENGTH_ERROR); 204 testInvalidArgument([''], NAME_LENGTH_ERROR);
204 testInvalidArgument(tooManyProtocols, MESSAGE_LENGTH_ERROR); 205 testInvalidArgument(tooManyProtocols, MESSAGE_LENGTH_ERROR);
205 } 206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698