Exemplo n.º 1
0
 def test_introspection_query(self, hge_ctx):
     conf = get_conf_f(self.dir() + '/introspection_query.yaml')
     headers = {}
     admin_secret = hge_ctx.hge_key
     if admin_secret:
         headers['X-Hasura-Admin-Secret'] = admin_secret
     code, resp, _ = hge_ctx.anyq(conf['url'], conf['query'], headers)
     assert code == 200, resp
     assert 'data' in resp, resp
Exemplo n.º 2
0
 def with_admin_secret(self, hge_ctx, f):
     conf = get_conf_f(f)
     admin_secret = hge_ctx.hge_key
     headers = {}
     if admin_secret:
         headers['X-Hasura-Admin-Secret'] = hge_ctx.hge_key
     status_code, resp_json, _ = hge_ctx.anyq(conf['url'], conf['query'], headers)
     assert status_code == 200, resp_json
     # Comparing only with generated 'sql' since the 'plan' is not consistent
     # across all Postgres versions
     resp_sql = resp_json[0]['sql']
     exp_sql = conf['response'][0]['sql']
     assert resp_sql == exp_sql, resp_json
Exemplo n.º 3
0
def check_query_secret(hge_ctx, f):
    conf = get_conf_f(f)
    admin_secret = hge_ctx.hge_key

    def add_secret(c):
        if admin_secret is not None:
            if 'headers' in c:
                c['headers']['x-hasura-admin-secret'] = admin_secret
            else:
                c['headers'] = {'x-hasura-admin-secret': admin_secret}
        return c

    if isinstance(conf, list):
        for _, sconf in enumerate(conf):
            check_query(hge_ctx, add_secret(sconf), add_auth=False)
    else:
        check_query(hge_ctx, add_secret(conf), add_auth=False)
def check_query_admin_secret(hge_ctx, f, transport='http'):
    conf = get_conf_f(f)
    admin_secret = hge_ctx.hge_key
    if admin_secret:
        conf['headers']['x-hasura-admin-secret'] = admin_secret
    check_query(hge_ctx, conf, transport, False)