add test for gateway message validation error

This commit is contained in:
Luna 2021-06-30 18:42:20 -03:00
parent ba62403674
commit e5f8fe7243
1 changed files with 19 additions and 0 deletions

View File

@ -103,6 +103,25 @@ async def test_ready(test_cli_user):
await _close(conn) 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 @pytest.mark.asyncio
async def test_ready_fields(test_cli_user): async def test_ready_fields(test_cli_user):
conn = await gw_start(test_cli_user.cli) conn = await gw_start(test_cli_user.cli)