mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-25 00:13:11 +03:00
8bd34b4a51
spec: https://github.com/hasura/graphql-engine-mono/pull/2278 Briefly: - extend metadata so that allowlist entries get a new scope field - update `add_collection_to_allowlist` to accept this new scope field, and adds `update_scope_of_collection_in_allowlist` to change the scope - scope can be global or role-based; a collection is available for every role if it is global, and available to every listed role if it is role-based - graphql-engine-oss is aware of role-based allowlist metadata; collections with non-global scope are treated as if they weren't in the allowlist To run the tests: - `cabal run graphql-engine-tests -- unit --match Allowlist` - py-tests against pro: - launch `graphql-engine-pro` with `HASURA_GRAPHQL_ADMIN_SECRET` and `HASURA_GRAPHQL_ENABLE_ALLOWLIST` - `pytest test_allowlist_queries.py --hge-urls=... --pg-urls=... --hge-key=... --test-allowlist-queries --pro-tests` PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2477 Co-authored-by: Anon Ray <616387+ecthiender@users.noreply.github.com> Co-authored-by: Robert <132113+robx@users.noreply.github.com> GitOrigin-RevId: 01f8026fbe59d8701e2de30986511a452fce1a99
62 lines
2.0 KiB
Python
62 lines
2.0 KiB
Python
import pytest
|
|
import time
|
|
import jsondiff
|
|
from context import PytestConf
|
|
from ruamel.yaml import YAML
|
|
|
|
yaml=YAML(typ='safe', pure=True)
|
|
|
|
|
|
if not PytestConf.config.getoption("--test-hge-scale-url"):
|
|
pytest.skip("--test-hge-scale-url flag is missing, skipping tests", allow_module_level=True)
|
|
|
|
|
|
class TestHorizontalScaleBasic():
|
|
servers = {}
|
|
|
|
@pytest.fixture(autouse=True, scope='class')
|
|
def transact(self, hge_ctx):
|
|
self.servers['1'] = hge_ctx.hge_url
|
|
self.servers['2'] = hge_ctx.hge_scale_url
|
|
yield
|
|
# teardown
|
|
st_code, resp = hge_ctx.v1q_f(self.dir() + '/teardown.yaml')
|
|
assert st_code == 200, resp
|
|
|
|
def test_horizontal_scale_basic(self, hge_ctx):
|
|
with open(self.dir() + "/steps.yaml") as c:
|
|
conf = yaml.load(c)
|
|
|
|
assert isinstance(conf, list) == True, 'Not a list'
|
|
for _, step in enumerate(conf):
|
|
# execute operation
|
|
response = hge_ctx.http.post(
|
|
self.servers[step['operation']['server']] + "/v1/query",
|
|
json=step['operation']['query']
|
|
)
|
|
st_code = response.status_code
|
|
resp = response.json()
|
|
assert st_code == 200, resp
|
|
|
|
# wait for 20 sec
|
|
time.sleep(20)
|
|
# validate data
|
|
response = hge_ctx.http.post(
|
|
self.servers[step['validate']['server']] + "/v1alpha1/graphql",
|
|
json=step['validate']['query']
|
|
)
|
|
st_code = response.status_code
|
|
resp = response.json()
|
|
assert st_code == 200, resp
|
|
|
|
if 'response' in step['validate']:
|
|
assert resp == step['validate']['response'], yaml.dump({
|
|
'response': resp,
|
|
'expected': step['validate']['response'],
|
|
'diff': jsondiff.diff(step['validate']['response'], resp)
|
|
})
|
|
|
|
@classmethod
|
|
def dir(cls):
|
|
return 'queries/horizontal_scale/basic'
|