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

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

Issue 158773002: Change RawSocket.secureServer and RawSoccket.secure to fail on paused subscriptions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 6 years, 10 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 44cb7fc19e581abb14cf29b8344ee9fbdbf77361..49c04fb24086f25ddc052fd594f440aece2cf395 100644
--- a/tests/standalone/io/raw_secure_server_socket_test.dart
+++ b/tests/standalone/io/raw_secure_server_socket_test.dart
@@ -472,6 +472,67 @@ void testSimpleReadWrite({bool listenSecure,
}
}
+testPausedSecuringSubscription(bool pausedServer, bool pausedClient) {
+ bool expectFail = pausedServer || pausedClient;
+
+ asyncStart();
+ var clientComplete = new Completer();
+ RawServerSocket.bind(HOST_NAME, 0).then((server) {
+ server.listen((client) {
+ var subscription;
+ subscription = client.listen((_) {
+ 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(() {
+ server.close();
+ clientComplete.future.then((_) {
+ client.close();
+ asyncEnd();
+ });
+ });
+ });
+ });
+
+ RawSocket.connect(HOST_NAME, server.port).then((socket) {
+ var subscription;
+ subscription = socket.listen((_) {
+ 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) {
+ Expect.fail("secure failed with non-paused subscriptions ($e)");
+ }
+ if (pausedClient) {
+ Expect.isTrue(e is StateError);
+ }
+ }).whenComplete(() {
+ clientComplete.complete(null);
+ });
+ });
+ });
+ });
+}
+
main() {
var certificateDatabase = Platform.script.resolve('pkcert').toFilePath();
SecureSocket.initialize(database: certificateDatabase,
@@ -526,4 +587,8 @@ main() {
handshakeBeforeSecure: true,
postponeSecure: true,
dropReads: true);
+ testPausedSecuringSubscription(false, false);
+ testPausedSecuringSubscription(true, false);
+ testPausedSecuringSubscription(false, true);
+ testPausedSecuringSubscription(true, true);
}
« 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