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

Side by Side Diff: tests/standalone/io/secure_socket_renegotiate_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_socket_renegotiate_test, that runs in a subprocess. 5 // Client for secure_socket_renegotiate_test, that runs in a subprocess.
6 // The test verifies that client certificates work, if the client and server 6 // The test verifies that client certificates work, if the client and server
7 // are in separate processes, and that connection renegotiation can request 7 // are in separate processes, and that connection renegotiation can request
8 // a client certificate to be sent. 8 // a client certificate to be sent.
9 9
10 import "dart:async"; 10 import "dart:async";
11 import "dart:convert"; 11 import "dart:convert";
12 import "dart:io"; 12 import "dart:io";
13 13
14 const HOST_NAME = "localhost"; 14 const HOST_NAME = "localhost";
15 const CERTIFICATE = "localhost_cert"; 15 String localFile(path) => Platform.script.resolve(path).toFilePath();
16 16
17 SecurityContext clientContext = new SecurityContext()
18 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem'));
17 19
18 class ExpectException implements Exception { 20 class ExpectException implements Exception {
19 ExpectException(this.message); 21 ExpectException(this.message);
20 String toString() => message; 22 String toString() => message;
21 String message; 23 String message;
22 } 24 }
23 25
24 26
25 void expectEquals(expected, actual) { 27 void expectEquals(expected, actual) {
26 if (actual != expected) { 28 if (actual != expected) {
27 throw new ExpectException('Expected $expected, found $actual'); 29 throw new ExpectException('Expected $expected, found $actual');
28 } 30 }
29 } 31 }
30 32
31 33
32 void expect(condition) { 34 void expect(condition) {
33 if (!condition) { 35 if (!condition) {
34 throw new ExpectException(''); 36 throw new ExpectException('');
35 } 37 }
36 } 38 }
37 39
38 40
39 void runClient(int port) { 41 void runClient(int port) {
40 SecureSocket.connect(HOST_NAME, port, sendClientCertificate: true) 42 SecureSocket.connect(HOST_NAME,
43 port,
44 context: clientContext,
45 sendClientCertificate: true)
41 .then((SecureSocket socket) { 46 .then((SecureSocket socket) {
42 X509Certificate certificate = socket.peerCertificate; 47 X509Certificate certificate = socket.peerCertificate;
43 expect(certificate != null); 48 expect(certificate != null);
44 expectEquals('CN=localhost', certificate.subject); 49 expectEquals('CN=localhost', certificate.subject);
45 expectEquals('CN=myauthority', certificate.issuer); 50 expectEquals('CN=myauthority', certificate.issuer);
46 StreamIterator<String> input = new StreamIterator(socket 51 StreamIterator<String> input = new StreamIterator(socket
47 .transform(UTF8.decoder) 52 .transform(UTF8.decoder)
48 .transform(new LineSplitter())); 53 .transform(new LineSplitter()));
49 socket.writeln('first'); 54 socket.writeln('first');
50 input.moveNext() 55 input.moveNext()
(...skipping 16 matching lines...) Expand all
67 }) 72 })
68 .then((success) { 73 .then((success) {
69 expect(success != true); 74 expect(success != true);
70 socket.close(); 75 socket.close();
71 }); 76 });
72 }); 77 });
73 } 78 }
74 79
75 80
76 void main(List<String> args) { 81 void main(List<String> args) {
77 SecureSocket.initialize(database: args[1], password: 'dartdart');
78 runClient(int.parse(args[0])); 82 runClient(int.parse(args[0]));
79 } 83 }
OLDNEW
« no previous file with comments | « tests/standalone/io/secure_socket_bad_data_test.dart ('k') | tests/standalone/io/secure_socket_renegotiate_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698