OLD | NEW |
---|---|
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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
542 Expect.equals("Hello", message); | 542 Expect.equals("Hello", message); |
543 return websocket.close(); | 543 return websocket.close(); |
544 }).asFuture(); | 544 }).asFuture(); |
545 }).then((_) { | 545 }).then((_) { |
546 return server.close(); | 546 return server.close(); |
547 }).whenComplete(() { | 547 }).whenComplete(() { |
548 asyncEnd(); | 548 asyncEnd(); |
549 }); | 549 }); |
550 }); | 550 }); |
551 } | 551 } |
552 | 552 |
Søren Gjesse
2015/08/24 08:21:50
Please create a new test file web_socket_compressi
| |
553 void testCompressionSupport(bool enabled, bool allowContextTakeover) { | |
Søren Gjesse
2015/08/24 08:21:50
Please add tests involving the max_window_bits as
| |
554 asyncStart(); | |
555 | |
556 var options = new CompressionOptions( | |
557 enabled: enabled, | |
558 serverNoContextTakeover: allowContextTakeover, | |
559 clientNoContextTakeover: allowContextTakeover); | |
560 | |
561 createServer().then((server) { | |
562 server.listen((request) { | |
563 Expect.isTrue(WebSocketTransformer.isUpgradeRequest(request)); | |
564 WebSocketTransformer.upgrade(request, compression: options).then((webSoc ket) { | |
Søren Gjesse
2015/08/24 08:21:50
nit: Long line.
| |
565 webSocket.listen((message) { | |
566 Expect.equals("Hello World", message); | |
567 | |
568 webSocket.add(message); | |
569 webSocket.close(); | |
570 }); | |
571 webSocket.add("Hello World"); | |
572 }); | |
573 }); | |
574 | |
575 var url = '${secure ? "wss" : "ws"}://$HOST_NAME:${server.port}/'; | |
576 WebSocket.connect(url, compression: options).then((websocket) { | |
577 var future = websocket.listen((message) { | |
578 Expect.equals("Hello World", message); | |
579 }).asFuture(); | |
580 websocket.add("Hello World"); | |
581 return future; | |
582 }).then((_) { | |
583 server.close(); | |
584 asyncEnd(); | |
585 }); | |
586 }); | |
587 } | |
588 | |
553 void runTests() { | 589 void runTests() { |
554 testRequestResponseClientCloses(2, null, null, 1); | 590 testRequestResponseClientCloses(2, null, null, 1); |
555 testRequestResponseClientCloses(2, 3001, null, 2); | 591 testRequestResponseClientCloses(2, 3001, null, 2); |
556 testRequestResponseClientCloses(2, 3002, "Got tired", 3); | 592 testRequestResponseClientCloses(2, 3002, "Got tired", 3); |
557 testRequestResponseServerCloses(2, null, null); | 593 testRequestResponseServerCloses(2, null, null); |
558 testRequestResponseServerCloses(2, 3001, null); | 594 testRequestResponseServerCloses(2, 3001, null); |
559 testRequestResponseServerCloses(2, 3002, "Got tired"); | 595 testRequestResponseServerCloses(2, 3002, "Got tired"); |
560 testMessageLength(125); | 596 testMessageLength(125); |
561 testMessageLength(126); | 597 testMessageLength(126); |
562 testMessageLength(127); | 598 testMessageLength(127); |
563 testMessageLength(65535); | 599 testMessageLength(65535); |
564 testMessageLength(65536); | 600 testMessageLength(65536); |
565 testCloseNoListen(); | 601 testCloseNoListen(); |
566 testCancelThenClose(); | 602 testCancelThenClose(); |
567 testCloseThenCancel(); | 603 testCloseThenCancel(); |
568 testListenAfterClose(); | 604 testListenAfterClose(); |
569 testDoubleCloseClient(); | 605 testDoubleCloseClient(); |
570 testDoubleCloseServer(); | 606 testDoubleCloseServer(); |
571 testImmediateCloseServer(); | 607 testImmediateCloseServer(); |
572 testImmediateCloseClient(); | 608 testImmediateCloseClient(); |
573 testNoUpgrade(); | 609 testNoUpgrade(); |
574 testUsePOST(); | 610 testUsePOST(); |
575 testConnections(10, 3002, "Got tired"); | 611 testConnections(10, 3002, "Got tired"); |
612 testCompressionSupport(false, false); | |
613 testCompressionSupport(true, false); | |
614 testCompressionSupport(true, true); | |
576 testIndividualUpgrade(5); | 615 testIndividualUpgrade(5); |
577 testFromUpgradedSocket(); | 616 testFromUpgradedSocket(); |
578 testAdditionalHeaders(); | 617 testAdditionalHeaders(); |
579 testBasicAuthentication(); | 618 testBasicAuthentication(); |
580 } | 619 } |
581 } | 620 } |
582 | 621 |
583 | 622 |
584 void initializeSSL() { | 623 void initializeSSL() { |
585 var testPkcertDatabase = Platform.script.resolve('pkcert').toFilePath(); | 624 var testPkcertDatabase = Platform.script.resolve('pkcert').toFilePath(); |
586 SecureSocket.initialize(database: testPkcertDatabase, | 625 SecureSocket.initialize(database: testPkcertDatabase, |
587 password: "dartdart"); | 626 password: "dartdart"); |
588 } | 627 } |
589 | 628 |
590 | 629 |
591 main() { | 630 main() { |
592 new SecurityConfiguration(secure: false).runTests(); | 631 new SecurityConfiguration(secure: false).runTests(); |
593 initializeSSL(); | 632 initializeSSL(); |
594 new SecurityConfiguration(secure: true).runTests(); | 633 new SecurityConfiguration(secure: true).runTests(); |
595 } | 634 } |
OLD | NEW |