Skip to content

Commit

Permalink
server: run function permissions tests in CI
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 750b44d
  • Loading branch information
codingkarthik authored and hasura-bot committed Feb 18, 2021
1 parent 8996bcf commit 77b3bb5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions .circleci/server-test-names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ws-init-cookie-read-cors-disabled
ws-graphql-api-disabled
ws-metadata-api-disabled
remote-schema-permissions
function-permissions
query-caching
query-logs
webhook-request-context
Expand Down
8 changes: 5 additions & 3 deletions .circleci/test-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -662,16 +662,18 @@ case "$SERVER_TEST_TO_RUN" in

function-permissions)
echo -e "\n$(time_elapsed): <########## TEST GRAPHQL-ENGINE WITH FUNCTION PERMISSIONS ENABLED ########>\n"
TEST_TYPE="remote-schema-permissions"
TEST_TYPE="function-permissions"
export HASURA_GRAPHQL_INFER_FUNCTION_PERMISSIONS=false
export HASURA_GRAPHQL_ADMIN_SECRET="HGE$RANDOM$RANDOM"

run_hge_with_args serve
wait_for_port 8080

pytest -n 1 -vv --hge-urls "$HGE_URL" --pg-urls "$HASURA_GRAPHQL_DATABASE_URL" --hge-key="$HASURA_GRAPHQL_ADMIN_SECRET" --test_function_permissions test_graphql_queries.py::TestGraphQLQueryFunctionPermissions
pytest -n 1 -vv --hge-urls "$HGE_URL" --pg-urls "$HASURA_GRAPHQL_DATABASE_URL" --hge-key="$HASURA_GRAPHQL_ADMIN_SECRET" --test_function_permissions test_graphql_mutations.py::TestGraphQLMutationFunctions
pytest -n 1 -vv --hge-urls "$HGE_URL" --pg-urls "$HASURA_GRAPHQL_DATABASE_URL" --hge-key="$HASURA_GRAPHQL_ADMIN_SECRET" --test-function-permissions test_graphql_queries.py::TestGraphQLQueryFunctionPermissions
pytest -n 1 -vv --hge-urls "$HGE_URL" --pg-urls "$HASURA_GRAPHQL_DATABASE_URL" --hge-key="$HASURA_GRAPHQL_ADMIN_SECRET" --test-function-permissions test_graphql_mutations.py::TestGraphQLMutationFunctions

unset HASURA_GRAPHQL_INFER_FUNCTION_PERMISSIONS
unset HASURA_GRAPHQL_ADMIN_SECRET

kill_hge_servers
;;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type: pg_create_function_permission
args:
function: add_to_score_by_user_id
role: anonymous
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type: pg_drop_function_permission
args:
function: add_to_score_by_user_id
role: anonymous
4 changes: 4 additions & 0 deletions server/tests-py/test_graphql_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,8 @@ def test_functions_as_mutations_permissions(self, hge_ctx, transport):
assert st_code == 200, resp

def test_single_row_function_as_mutation(self, hge_ctx, transport):
st_code, resp = hge_ctx.v1metadataq_f(self.dir() + '/create_function_permission_add_to_score_by_user_id.yaml')
assert st_code == 200, resp
check_query_f(hge_ctx, self.dir() + '/single_row_function_as_mutation.yaml', transport)
st_code, resp = hge_ctx.v1metadataq_f(self.dir() + '/drop_function_permission_add_to_score_by_user_id.yaml')
assert st_code == 200, resp

0 comments on commit 77b3bb5

Please sign in to comment.