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
This commit is contained in:
Puru Gupta 2023-07-20 16:13:14 +05:30 committed by hasura-bot
parent a2276b8171
commit b5cd05cebd

View File

@ -102,7 +102,7 @@ class TestSubscriptionCtrl(object):
@pytest.mark.requires_an_admin_secret @pytest.mark.requires_an_admin_secret
class TestSubscriptionBasicNoAuth: 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 # sends empty header so that there is not authentication present in the test
init_msg = { init_msg = {
'type': 'connection_init', 'type': 'connection_init',
@ -113,6 +113,17 @@ class TestSubscriptionBasicNoAuth:
ev = ws_client.get_conn_close_state() ev = ws_client.get_conn_close_state()
assert ev == True, ev 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') @pytest.mark.backend('mssql', 'postgres')
@usefixtures('per_class_tests_db_state', 'ws_conn_init') @usefixtures('per_class_tests_db_state', 'ws_conn_init')
@pytest.mark.admin_secret @pytest.mark.admin_secret