From b5cd05cebdb2cdc8cbdb56325deaaaa3120896c1 Mon Sep 17 00:00:00 2001 From: Puru Gupta Date: Thu, 20 Jul 2023 16:13:14 +0530 Subject: [PATCH] server: add tests for invalid auth when using `graphql-ws` protocol PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9905 GitOrigin-RevId: 394849866b33039ee9c2bdfc3c33ba13b88f03fa --- server/tests-py/test_subscriptions.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server/tests-py/test_subscriptions.py b/server/tests-py/test_subscriptions.py index 3eecd345ea8..1fc609694d9 100644 --- a/server/tests-py/test_subscriptions.py +++ b/server/tests-py/test_subscriptions.py @@ -102,7 +102,7 @@ class TestSubscriptionCtrl(object): @pytest.mark.requires_an_admin_secret class TestSubscriptionBasicNoAuth: - def test_closed_connection(self, ws_client): + def test_closed_connection_apollo(self, ws_client): # sends empty header so that there is not authentication present in the test init_msg = { 'type': 'connection_init', @@ -113,6 +113,17 @@ class TestSubscriptionBasicNoAuth: ev = ws_client.get_conn_close_state() assert ev == True, ev + def test_closed_connection_graphql_ws(self, ws_client_graphql_ws): + # sends empty header so that there is not authentication present in the test + init_msg = { + 'type': 'connection_init', + 'payload':{'headers':{}} + } + ws_client_graphql_ws.send(init_msg) + time.sleep(2) + ev = ws_client_graphql_ws.get_conn_close_state() + assert ev == True, ev + @pytest.mark.backend('mssql', 'postgres') @usefixtures('per_class_tests_db_state', 'ws_conn_init') @pytest.mark.admin_secret