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

Unified Diff: tests/standalone/io/raw_secure_server_socket_test.dart

Issue 262923002: Clean up secure socket connect. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/raw_secure_server_socket_test.dart
diff --git a/tests/standalone/io/raw_secure_server_socket_test.dart b/tests/standalone/io/raw_secure_server_socket_test.dart
index 6c90ed92676b6ab39dc317cc2d573afac56dc378..33fc191de87b07c50fad59aa84757d367dbc8213 100644
--- a/tests/standalone/io/raw_secure_server_socket_test.dart
+++ b/tests/standalone/io/raw_secure_server_socket_test.dart
@@ -472,8 +472,6 @@ void testSimpleReadWrite({bool listenSecure,
}
testPausedSecuringSubscription(bool pausedServer, bool pausedClient) {
- bool expectFail = pausedServer || pausedClient;
-
asyncStart();
var clientComplete = new Completer();
RawServerSocket.bind(HOST, 0).then((server) {
@@ -483,25 +481,32 @@ testPausedSecuringSubscription(bool pausedServer, bool pausedClient) {
if (pausedServer) {
subscription.pause();
}
- RawSecureSocket.secureServer(
- client, CERTIFICATE, subscription: subscription).then((client) {
- if (expectFail) {
- Expect.fail("secureServer succeeded with paused subscription");
- }
- }).catchError((e) {
- if (!expectFail) {
- Expect.fail("secureServer failed with non-paused subscriptions");
- }
- if (pausedServer) {
- Expect.isTrue(e is StateError);
- }
- }).whenComplete(() {
+ void done() {
server.close();
clientComplete.future.then((_) {
client.close();
asyncEnd();
});
- });
+ }
+ try {
+ RawSecureSocket.secureServer(
+ client, CERTIFICATE, subscription: subscription)
+ .catchError((_) {})
+ .whenComplete(() {
+ if (pausedServer) {
+ Expect.fail("secureServer succeeded with paused subscription");
+ }
+ done();
+ });
+ } catch (e) {
+ if (!pausedServer) {
+ Expect.fail("secureServer failed with non-paused subscriptions");
+ }
+ if (pausedServer) {
+ Expect.isTrue(e is ArgumentError);
+ }
+ done();
+ }
});
});
@@ -511,22 +516,26 @@ testPausedSecuringSubscription(bool pausedServer, bool pausedClient) {
if (pausedClient) {
subscription.pause();
}
- RawSecureSocket.secure(
- socket, subscription: subscription).then((socket) {
- if (expectFail) {
- Expect.fail("secure succeeded with paused subscription");
- }
- socket.close();
- }).catchError((e) {
- if (!expectFail) {
+ try {
+ RawSecureSocket.secure(
+ socket, subscription: subscription)
+ .catchError((_) {})
+ .whenComplete(() {
+ if (pausedClient) {
+ Expect.fail("secure succeeded with paused subscription");
+ }
+ socket.close();
+ clientComplete.complete(null);
+ });
+ } catch (e) {
+ if (!pausedClient) {
Expect.fail("secure failed with non-paused subscriptions ($e)");
}
if (pausedClient) {
- Expect.isTrue(e is StateError);
+ Expect.isTrue(e is ArgumentError);
}
- }).whenComplete(() {
clientComplete.complete(null);
- });
+ }
});
});
});
@@ -555,6 +564,7 @@ runTests() {
testSimpleConnectFail("not_a_nickname", true);
testSimpleConnectFail("CN=notARealDistinguishedName", true);
testServerListenAfterConnect();
+
testSimpleReadWrite(listenSecure: true,
connectSecure: true,
handshakeBeforeSecure: false,
« no previous file with comments | « sdk/lib/io/secure_socket.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698