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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/secure_socket_renegotiate_client.dart
diff --git a/tests/standalone/io/secure_socket_renegotiate_client.dart b/tests/standalone/io/secure_socket_renegotiate_client.dart
new file mode 100644
index 0000000000000000000000000000000000000000..9ac2192b07f7f661e387d01eb17fe34221db51a3
--- /dev/null
+++ b/tests/standalone/io/secure_socket_renegotiate_client.dart
@@ -0,0 +1,79 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Client for secure_socket_renegotiate_test, that runs in a subprocess.
+// The test verifies that client certificates work, if the client and server
+// are in separate processes, and that connection renegotiation can request
+// a client certificate to be sent.
+
+import "dart:async";
+import "dart:io";
+
+const HOST_NAME = "localhost";
+const CERTIFICATE = "localhost_cert";
+
+
+class ExpectException implements Exception {
+ ExpectException(this.message);
+ String toString() => message;
+ String message;
+}
+
+
+void expectEquals(expected, actual) {
+ if (actual != expected) {
+ throw new ExpectException('Expected $expected, found $actual');
+ }
+}
+
+
+void expect(condition) {
+ if (!condition) {
+ throw new ExpectException('');
+ }
+}
+
+
+void runClient(int port) {
+ SecureSocket.connect(HOST_NAME, port, sendClientCertificate: true)
+ .then((SecureSocket socket) {
+ X509Certificate certificate = socket.peerCertificate;
+ expect(certificate != null);
+ expectEquals('CN=localhost', certificate.subject);
+ expectEquals('CN=myauthority', certificate.issuer);
+ StreamIterator<String> input = new StreamIterator(socket
+ .transform(new StringDecoder())
+ .transform(new LineTransformer()));
+ socket.writeln('first');
+ input.moveNext()
+ .then((success) {
+ expect(success);
+ expectEquals('first reply', input.current);
+ socket.renegotiate();
+ socket.writeln('renegotiated');
+ return input.moveNext();
+ })
+ .then((success) {
+ expect(success);
+ expectEquals('server renegotiated', input.current);
+ X509Certificate certificate = socket.peerCertificate;
+ expect(certificate != null);
+ expectEquals("CN=localhost", certificate.subject);
+ expectEquals("CN=myauthority", certificate.issuer);
+ socket.writeln('second');
+ return input.moveNext();
+ })
+ .then((success) {
+ expect(success != true);
+ socket.close();
+ });
+ });
+}
+
+
+void main() {
+ final args = new Options().arguments;
+ SecureSocket.initialize(database: args[1], password: 'dartdart');
+ runClient(int.parse(args[0]));
+}
« 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