summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/tools/third_party/websockets/compliance
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/tools/third_party/websockets/compliance')
-rw-r--r--testing/web-platform/tests/tools/third_party/websockets/compliance/README.rst50
-rw-r--r--testing/web-platform/tests/tools/third_party/websockets/compliance/fuzzingclient.json11
-rw-r--r--testing/web-platform/tests/tools/third_party/websockets/compliance/fuzzingserver.json12
-rw-r--r--testing/web-platform/tests/tools/third_party/websockets/compliance/test_client.py48
-rw-r--r--testing/web-platform/tests/tools/third_party/websockets/compliance/test_server.py29
5 files changed, 150 insertions, 0 deletions
diff --git a/testing/web-platform/tests/tools/third_party/websockets/compliance/README.rst b/testing/web-platform/tests/tools/third_party/websockets/compliance/README.rst
new file mode 100644
index 0000000000..8570f9176d
--- /dev/null
+++ b/testing/web-platform/tests/tools/third_party/websockets/compliance/README.rst
@@ -0,0 +1,50 @@
+Autobahn Testsuite
+==================
+
+General information and installation instructions are available at
+https://github.com/crossbario/autobahn-testsuite.
+
+To improve performance, you should compile the C extension first::
+
+ $ python setup.py build_ext --inplace
+
+Running the test suite
+----------------------
+
+All commands below must be run from the directory containing this file.
+
+To test the server::
+
+ $ PYTHONPATH=.. python test_server.py
+ $ wstest -m fuzzingclient
+
+To test the client::
+
+ $ wstest -m fuzzingserver
+ $ PYTHONPATH=.. python test_client.py
+
+Run the first command in a shell. Run the second command in another shell.
+It should take about ten minutes to complete — wstest is the bottleneck.
+Then kill the first one with Ctrl-C.
+
+The test client or server shouldn't display any exceptions. The results are
+stored in reports/clients/index.html.
+
+Note that the Autobahn software only supports Python 2, while ``websockets``
+only supports Python 3; you need two different environments.
+
+Conformance notes
+-----------------
+
+Some test cases are more strict than the RFC. Given the implementation of the
+library and the test echo client or server, ``websockets`` gets a "Non-Strict"
+in these cases.
+
+In 3.2, 3.3, 4.1.3, 4.1.4, 4.2.3, 4.2.4, and 5.15 ``websockets`` notices the
+protocol error and closes the connection before it has had a chance to echo
+the previous frame.
+
+In 6.4.3 and 6.4.4, even though it uses an incremental decoder, ``websockets``
+doesn't notice the invalid utf-8 fast enough to get a "Strict" pass. These
+tests are more strict than the RFC.
+
diff --git a/testing/web-platform/tests/tools/third_party/websockets/compliance/fuzzingclient.json b/testing/web-platform/tests/tools/third_party/websockets/compliance/fuzzingclient.json
new file mode 100644
index 0000000000..202ff49a03
--- /dev/null
+++ b/testing/web-platform/tests/tools/third_party/websockets/compliance/fuzzingclient.json
@@ -0,0 +1,11 @@
+
+{
+ "options": {"failByDrop": false},
+ "outdir": "./reports/servers",
+
+ "servers": [{"agent": "websockets", "url": "ws://localhost:8642", "options": {"version": 18}}],
+
+ "cases": ["*"],
+ "exclude-cases": [],
+ "exclude-agent-cases": {}
+}
diff --git a/testing/web-platform/tests/tools/third_party/websockets/compliance/fuzzingserver.json b/testing/web-platform/tests/tools/third_party/websockets/compliance/fuzzingserver.json
new file mode 100644
index 0000000000..1bdb42723e
--- /dev/null
+++ b/testing/web-platform/tests/tools/third_party/websockets/compliance/fuzzingserver.json
@@ -0,0 +1,12 @@
+
+{
+ "url": "ws://localhost:8642",
+
+ "options": {"failByDrop": false},
+ "outdir": "./reports/clients",
+ "webport": 8080,
+
+ "cases": ["*"],
+ "exclude-cases": [],
+ "exclude-agent-cases": {}
+}
diff --git a/testing/web-platform/tests/tools/third_party/websockets/compliance/test_client.py b/testing/web-platform/tests/tools/third_party/websockets/compliance/test_client.py
new file mode 100644
index 0000000000..1ed4d711e9
--- /dev/null
+++ b/testing/web-platform/tests/tools/third_party/websockets/compliance/test_client.py
@@ -0,0 +1,48 @@
+import json
+import logging
+import urllib.parse
+
+import asyncio
+import websockets
+
+
+logging.basicConfig(level=logging.WARNING)
+
+# Uncomment this line to make only websockets more verbose.
+# logging.getLogger('websockets').setLevel(logging.DEBUG)
+
+
+SERVER = "ws://127.0.0.1:8642"
+AGENT = "websockets"
+
+
+async def get_case_count(server):
+ uri = f"{server}/getCaseCount"
+ async with websockets.connect(uri) as ws:
+ msg = ws.recv()
+ return json.loads(msg)
+
+
+async def run_case(server, case, agent):
+ uri = f"{server}/runCase?case={case}&agent={agent}"
+ async with websockets.connect(uri, max_size=2 ** 25, max_queue=1) as ws:
+ async for msg in ws:
+ await ws.send(msg)
+
+
+async def update_reports(server, agent):
+ uri = f"{server}/updateReports?agent={agent}"
+ async with websockets.connect(uri):
+ pass
+
+
+async def run_tests(server, agent):
+ cases = await get_case_count(server)
+ for case in range(1, cases + 1):
+ print(f"Running test case {case} out of {cases}", end="\r")
+ await run_case(server, case, agent)
+ print(f"Ran {cases} test cases ")
+ await update_reports(server, agent)
+
+
+asyncio.run(run_tests(SERVER, urllib.parse.quote(AGENT)))
diff --git a/testing/web-platform/tests/tools/third_party/websockets/compliance/test_server.py b/testing/web-platform/tests/tools/third_party/websockets/compliance/test_server.py
new file mode 100644
index 0000000000..92f895d926
--- /dev/null
+++ b/testing/web-platform/tests/tools/third_party/websockets/compliance/test_server.py
@@ -0,0 +1,29 @@
+import logging
+
+import asyncio
+import websockets
+
+
+logging.basicConfig(level=logging.WARNING)
+
+# Uncomment this line to make only websockets more verbose.
+# logging.getLogger('websockets').setLevel(logging.DEBUG)
+
+
+HOST, PORT = "127.0.0.1", 8642
+
+
+async def echo(ws):
+ async for msg in ws:
+ await ws.send(msg)
+
+
+async def main():
+ with websockets.serve(echo, HOST, PORT, max_size=2 ** 25, max_queue=1):
+ try:
+ await asyncio.Future()
+ except KeyboardInterrupt:
+ pass
+
+
+asyncio.run(main())