2020-02-13 12:14:02 +03:00
|
|
|
import pytest
|
2019-04-30 11:34:08 +03:00
|
|
|
import os
|
2022-01-17 10:39:59 +03:00
|
|
|
from ruamel.yaml import YAML
|
|
|
|
|
|
|
|
yaml=YAML(typ='safe', pure=True)
|
2019-04-30 11:34:08 +03:00
|
|
|
|
2020-02-13 12:14:02 +03:00
|
|
|
@pytest.mark.usefixtures('per_method_tests_db_state')
|
|
|
|
class TestPGDump:
|
2019-04-30 11:34:08 +03:00
|
|
|
|
|
|
|
def test_pg_dump_for_public_schema(self, hge_ctx):
|
|
|
|
query_file = self.dir() + '/pg_dump_public.yaml'
|
2022-10-20 08:56:11 +03:00
|
|
|
with open(query_file, 'r') as stream:
|
|
|
|
q = yaml.load(stream)
|
|
|
|
headers = q['headers'] or {}
|
|
|
|
if hge_ctx.hge_key is not None:
|
|
|
|
headers['x-hasura-admin-secret'] = hge_ctx.hge_key
|
|
|
|
resp = hge_ctx.http.post(hge_ctx.hge_url + q['url'], json=q['query'], headers=headers)
|
|
|
|
body = resp.text
|
|
|
|
assert resp.status_code == q['status']
|
|
|
|
print(body)
|
|
|
|
print(q['expected_response'])
|
|
|
|
assert body == q['expected_response']
|
2019-04-30 11:34:08 +03:00
|
|
|
|
2021-07-16 19:08:23 +03:00
|
|
|
def test_pg_dump_for_public_schema_for_user_role(self, hge_ctx):
|
2022-10-20 08:56:11 +03:00
|
|
|
query_file = self.dir() + '/pg_dump_public.yaml'
|
|
|
|
with open(query_file, 'r') as stream:
|
|
|
|
q = yaml.load(stream)
|
|
|
|
headers = q['headers'] or {}
|
|
|
|
if hge_ctx.hge_key is not None:
|
|
|
|
headers['x-hasura-admin-secret'] = hge_ctx.hge_key
|
|
|
|
headers['X-Hasura-Role'] = 'user'
|
|
|
|
resp = hge_ctx.http.post(hge_ctx.hge_url + q['url'], json=q['query'], headers=headers)
|
|
|
|
body = resp.text
|
|
|
|
assert resp.status_code == 400, body
|
2021-07-16 19:08:23 +03:00
|
|
|
|
2019-04-30 11:34:08 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "pgdump"
|