graphql-engine/server/tests-py/test_compat.py
Samir Talwar 3cb9bab9f1 server/tests-py: Provide the admin secret to the HGE server.
When we run the HGE server inside the test harness, it needs to run with
an admin secret for some tests to make sense. This tags each test that
requires an admin secret with `pytest.mark.admin_secret`, which then
generates a UUID and injects that into both the server and the test case
(if required).

It also simplifies the way the test harness picks up an existing admin
secret, allowing it to use the environment variable instead of requiring
it via a parameter.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6120
GitOrigin-RevId: 55c5b9e8c99bdad9c8304098444ddb9516749a2c
2022-09-29 17:20:07 +00:00

23 lines
577 B
Python

import pytest
def v1qCompat(hge_ctx, q):
h = {'X-Hasura-Access-Key': hge_ctx.hge_key}
resp = hge_ctx.http.post(
hge_ctx.hge_url + "/v1/query",
json=q,
headers=h
)
return resp.status_code, resp.json()
@pytest.mark.admin_secret
class TestGraphQLCompatAccessKey():
export_metadata = {
"type" : "export_metadata",
"args" : {}
}
def test_compact_access_key_export_metadata(self, hge_ctx):
code, resp = v1qCompat(hge_ctx, self.export_metadata)
assert code == 200, resp