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

Side by Side 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: Changed to make paused subscriptions an error 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/secure_socket.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 import "dart:async"; 10 import "dart:async";
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 } 465 }
466 466
467 if (listenSecure) { 467 if (listenSecure) {
468 RawSecureServerSocket.bind( 468 RawSecureServerSocket.bind(
469 HOST_NAME, 0, CERTIFICATE).then(serverReady); 469 HOST_NAME, 0, CERTIFICATE).then(serverReady);
470 } else { 470 } else {
471 RawServerSocket.bind(HOST_NAME, 0).then(serverReady); 471 RawServerSocket.bind(HOST_NAME, 0).then(serverReady);
472 } 472 }
473 } 473 }
474 474
475 testPausedSecuringSubscription(bool pausedServer, bool pausedClient) {
476 asyncStart();
Bill Hesse 2014/02/10 12:50:14 Maybe bool expectFail = pausedServer || pausedClie
477 var clientComplete = new Completer();
478 RawServerSocket.bind(HOST_NAME, 0).then((server) {
479 server.listen((client) {
480 var subscription;
481 subscription = client.listen((_) {
482 if (pausedServer) {
483 subscription.pause();
484 }
485 RawSecureSocket.secureServer(
486 client, CERTIFICATE, subscription: subscription).then((client) {
487 if (pausedServer || pausedClient) {
488 Expect.fail("secureServer succeeded with paused subscription");
489 }
490 }).catchError((e) {
491 if (!pausedServer && !pausedClient) {
492 Expect.fail("secureServer failed with non-paused subscriptions");
493 }
494 if (pausedServer) {
495 Expect.isTrue(e is StateError);
496 }
497 }).whenComplete(() {
498 server.close();
499 clientComplete.future.then((_) {
500 client.close();
501 asyncEnd();
502 });
503 });
504 });
505 });
506
507 RawSocket.connect(HOST_NAME, server.port).then((socket) {
508 var subscription;
509 subscription = socket.listen((_) {
510 if (pausedClient) {
511 subscription.pause();
512 }
513 RawSecureSocket.secure(
514 socket, subscription: subscription).then((socket) {
515 if (pausedServer || pausedClient) {
516 Expect.fail("secure succeeded with paused subscription");
517 }
518 socket.close();
519 }).catchError((e) {
520 if (!pausedServer && !pausedClient) {
521 Expect.fail("secure failed with non-paused subscriptions ($e)");
522 }
523 if (pausedClient) {
524 Expect.isTrue(e is StateError);
525 }
526 }).whenComplete(() {
527 clientComplete.complete(null);
528 });
529 });
530 });
531 });
532 }
533
475 main() { 534 main() {
476 var certificateDatabase = Platform.script.resolve('pkcert').toFilePath(); 535 var certificateDatabase = Platform.script.resolve('pkcert').toFilePath();
477 SecureSocket.initialize(database: certificateDatabase, 536 SecureSocket.initialize(database: certificateDatabase,
478 password: 'dartdart', 537 password: 'dartdart',
479 useBuiltinRoots: false); 538 useBuiltinRoots: false);
480 testSimpleBind(); 539 testSimpleBind();
481 testInvalidBind(); 540 testInvalidBind();
482 testSimpleConnect(CERTIFICATE); 541 testSimpleConnect(CERTIFICATE);
483 testSimpleConnect("CN=localhost"); 542 testSimpleConnect("CN=localhost");
484 testSimpleConnectFail("not_a_nickname", false); 543 testSimpleConnectFail("not_a_nickname", false);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 testSimpleReadWrite(listenSecure: true, 578 testSimpleReadWrite(listenSecure: true,
520 connectSecure: true, 579 connectSecure: true,
521 handshakeBeforeSecure: false, 580 handshakeBeforeSecure: false,
522 postponeSecure: false, 581 postponeSecure: false,
523 dropReads: true); 582 dropReads: true);
524 testSimpleReadWrite(listenSecure: false, 583 testSimpleReadWrite(listenSecure: false,
525 connectSecure: false, 584 connectSecure: false,
526 handshakeBeforeSecure: true, 585 handshakeBeforeSecure: true,
527 postponeSecure: true, 586 postponeSecure: true,
528 dropReads: true); 587 dropReads: true);
588 testPausedSecuringSubscription(false, false);
589 testPausedSecuringSubscription(true, false);
590 testPausedSecuringSubscription(false, true);
591 testPausedSecuringSubscription(true, true);
529 } 592 }
OLDNEW
« 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