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

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

Issue 1319703002: Breaking Change: merge BoringSSL branch into master (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 // Client for secure_bad_certificate_test, that runs in a subprocess. 5 // Client for secure_bad_certificate_test, that runs in a subprocess.
6 // The test verifies that the client bad certificate callback works. 6 // The test verifies that the client bad certificate callback works.
7 7
8 import "dart:async"; 8 import "dart:async";
9 import "dart:io"; 9 import "dart:io";
10 10
11 String localFile(path) => Platform.script.resolve(path).toFilePath();
12
13 SecurityContext clientContext = new SecurityContext()
14 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem'));
15
11 class ExpectException implements Exception { 16 class ExpectException implements Exception {
12 ExpectException(this.message); 17 ExpectException(this.message);
13 String toString() => "ExpectException: $message"; 18 String toString() => "ExpectException: $message";
14 String message; 19 String message;
15 } 20 }
16 21
17 void expect(condition) { 22 void expect(condition) {
18 if (!condition) { 23 if (!condition) {
19 throw new ExpectException(''); 24 throw new ExpectException('');
20 } 25 }
21 } 26 }
22 27
23 const HOST_NAME = "localhost"; 28 const HOST_NAME = "localhost";
24 29
25 Future runClients(int port) { 30 Future runClients(int port) {
26 var testFutures = []; 31 var testFutures = [];
27 for (int i = 0; i < 20; ++i) { 32 for (int i = 0; i < 20; ++i) {
28 testFutures.add( 33 testFutures.add(
29 SecureSocket.connect(HOST_NAME, port) 34 SecureSocket.connect(HOST_NAME, port, context: clientContext)
30 .then((SecureSocket socket) { 35 .then((SecureSocket socket) {
31 expect(false); 36 expect(false);
32 }, onError: (e) { 37 }, onError: (e) {
33 expect(e is HandshakeException || e is SocketException); 38 expect(e is HandshakeException || e is SocketException);
34 })); 39 }));
35 } 40 }
36 return Future.wait(testFutures); 41 return Future.wait(testFutures);
37 } 42 }
38 43
39 44
40 void main(List<String> args) { 45 void main(List<String> args) {
41 SecureSocket.initialize();
42 runClients(int.parse(args[0])) 46 runClients(int.parse(args[0]))
43 .then((_) => print('SUCCESS')); 47 .then((_) => print('SUCCESS'));
44 } 48 }
OLDNEW
« no previous file with comments | « tests/standalone/io/secure_socket_test.dart ('k') | tests/standalone/io/secure_unauthorized_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698