From ff07104316a9c49b33589fa3dc376f797d419980 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Sun, 20 May 2012 13:24:37 -0400 Subject: [PATCH] AutobahnTestSuite Added files to test Ratchet against the AutobahnTestSuite Bumped version v0.2b Updated how to handle control frames to run the test suite --- src/Ratchet/ConnectionInterface.php | 2 +- src/Ratchet/WebSocket/MessageParser.php | 5 +++-- tests/Ratchet/Tests/AbFuzzyServer.php | 22 +++++++++++++++++++ .../WebSocket/HandshakeNegotiatorTest.php | 6 ++--- tests/ab-wstest-fuzzyconf.json | 11 ++++++++++ tests/ab-wstest-server.php | 10 +++++++++ 6 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 tests/Ratchet/Tests/AbFuzzyServer.php create mode 100644 tests/ab-wstest-fuzzyconf.json create mode 100644 tests/ab-wstest-server.php diff --git a/src/Ratchet/ConnectionInterface.php b/src/Ratchet/ConnectionInterface.php index 8a22472..8a8ef34 100644 --- a/src/Ratchet/ConnectionInterface.php +++ b/src/Ratchet/ConnectionInterface.php @@ -1,7 +1,7 @@ WebSocket->frame->addBuffer($data); if ($from->WebSocket->frame->isCoalesced()) { if ($from->WebSocket->frame->getOpcode() > 2) { - $from->close(); - throw new \UnexpectedValueException('Control frame support coming soon!'); + unset($from->WebSocket->frame); + + return; } // Check frame // If is control frame, do your thing diff --git a/tests/Ratchet/Tests/AbFuzzyServer.php b/tests/Ratchet/Tests/AbFuzzyServer.php new file mode 100644 index 0000000..025cb4b --- /dev/null +++ b/tests/Ratchet/Tests/AbFuzzyServer.php @@ -0,0 +1,22 @@ +send($msg); + } + + public function onClose(ConnectionInterface $conn) { + } + + public function onError(ConnectionInterface $conn, \Exception $e) { + echo $e->getMessage() . "\n"; + + $conn->close(); + } +} \ No newline at end of file diff --git a/tests/Ratchet/Tests/WebSocket/HandshakeNegotiatorTest.php b/tests/Ratchet/Tests/WebSocket/HandshakeNegotiatorTest.php index 288e30a..cfef252 100644 --- a/tests/Ratchet/Tests/WebSocket/HandshakeNegotiatorTest.php +++ b/tests/Ratchet/Tests/WebSocket/HandshakeNegotiatorTest.php @@ -22,10 +22,10 @@ class HandshakeNegotiatorTest extends \PHPUnit_Framework_TestCase { return array( array(false, "GET / HTTP/1.1\r\nHost: socketo.me\r\n") , array(true, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\n") - , array(false, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\n1") - , array(false, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\nHixie✖") + , array(false, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\n1") + , array(false, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\nHixie✖") , array(true, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\nHixie✖\r\n\r\n") - , array(false, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\nHixie\r\n") + , array(false, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\nHixie\r\n") ); } diff --git a/tests/ab-wstest-fuzzyconf.json b/tests/ab-wstest-fuzzyconf.json new file mode 100644 index 0000000..e435908 --- /dev/null +++ b/tests/ab-wstest-fuzzyconf.json @@ -0,0 +1,11 @@ + +{ + "options": {"failByDrop": false}, + "outdir": "../reports/ab", + + "servers": [{"agent": "Ratchet/v0.2b", "url": "ws://localhost:8000", "options": {"version": 18}}], + + "cases": ["*"], + "exclude-cases": ["9.*"], + "exclude-agent-cases": {} +} diff --git a/tests/ab-wstest-server.php b/tests/ab-wstest-server.php new file mode 100644 index 0000000..d7ee557 --- /dev/null +++ b/tests/ab-wstest-server.php @@ -0,0 +1,10 @@ +run();