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

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

Issue 18984008: dart:io | Support connection renegotiation (rehandshake) on SecureSocket. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/secure_socket.dart ('k') | tests/standalone/io/secure_socket_renegotiate_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
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
7 // are in separate processes, and that connection renegotiation can request
8 // a client certificate to be sent.
9
10 import "dart:async";
11 import "dart:io";
12
13 const HOST_NAME = "localhost";
14 const CERTIFICATE = "localhost_cert";
15
16
17 class ExpectException implements Exception {
18 ExpectException(this.message);
19 String toString() => message;
20 String message;
21 }
22
23
24 void expectEquals(expected, actual) {
25 if (actual != expected) {
26 throw new ExpectException('Expected $expected, found $actual');
27 }
28 }
29
30
31 void expect(condition) {
32 if (!condition) {
33 throw new ExpectException('');
34 }
35 }
36
37
38 void runClient(int port) {
39 SecureSocket.connect(HOST_NAME, port, sendClientCertificate: true)
40 .then((SecureSocket socket) {
41 X509Certificate certificate = socket.peerCertificate;
42 expect(certificate != null);
43 expectEquals('CN=localhost', certificate.subject);
44 expectEquals('CN=myauthority', certificate.issuer);
45 StreamIterator<String> input = new StreamIterator(socket
46 .transform(new StringDecoder())
47 .transform(new LineTransformer()));
48 socket.writeln('first');
49 input.moveNext()
50 .then((success) {
51 expect(success);
52 expectEquals('first reply', input.current);
53 socket.renegotiate();
54 socket.writeln('renegotiated');
55 return input.moveNext();
56 })
57 .then((success) {
58 expect(success);
59 expectEquals('server renegotiated', input.current);
60 X509Certificate certificate = socket.peerCertificate;
61 expect(certificate != null);
62 expectEquals("CN=localhost", certificate.subject);
63 expectEquals("CN=myauthority", certificate.issuer);
64 socket.writeln('second');
65 return input.moveNext();
66 })
67 .then((success) {
68 expect(success != true);
69 socket.close();
70 });
71 });
72 }
73
74
75 void main() {
76 final args = new Options().arguments;
77 SecureSocket.initialize(database: args[1], password: 'dartdart');
78 runClient(int.parse(args[0]));
79 }
OLDNEW
« no previous file with comments | « sdk/lib/io/secure_socket.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