From e5f8fe7243dfd41289cb937f62ad88e1cc85e0bb Mon Sep 17 00:00:00 2001 From: Luna Date: Wed, 30 Jun 2021 18:42:20 -0300 Subject: [PATCH] add test for gateway message validation error --- tests/test_websocket.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_websocket.py b/tests/test_websocket.py index ed49838..a197cc2 100644 --- a/tests/test_websocket.py +++ b/tests/test_websocket.py @@ -103,6 +103,25 @@ async def test_ready(test_cli_user): await _close(conn) +@pytest.mark.asyncio +async def test_broken_identify(test_cli_user): + conn = await gw_start(test_cli_user.cli) + + # get the hello frame but ignore it + await _json(conn) + + await _json_send(conn, {"op": OP.IDENTIFY, "d": {"token": True}}) + + # try to get a ready + try: + await _json(conn) + raise AssertionError("Received a JSON message but expected close") + except websockets.ConnectionClosed as exc: + assert exc.code == 4002 + finally: + await _close(conn) + + @pytest.mark.asyncio async def test_ready_fields(test_cli_user): conn = await gw_start(test_cli_user.cli)