Skip to content

Commit

Permalink
modify the tests to include the claims_namespace_path
Browse files Browse the repository at this point in the history
  • Loading branch information
codingkarthik committed Apr 10, 2020
1 parent bc6c31f commit 4976874
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .circleci/test-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,21 @@ kill_hge_servers

unset HASURA_GRAPHQL_JWT_SECRET

##########
echo -e "\n$(time_elapsed): <########## TEST GRAPHQL-ENGINE WITH ADMIN SECRET AND JWT (with claims_namespace_path) #####################################>\n"
TEST_TYPE="jwt"

init_jwt

export HASURA_GRAPHQL_JWT_SECRET="$(jq -n --arg key "$(cat $OUTPUT_FOLDER/ssl/jwt_public.key)" '{ type: "RS512", key: $key , claims_namespace_path: "$.hasuraClaims"}')"

start_multiple_hge_servers

run_pytest_parallel --hge-key="$HASURA_GRAPHQL_ADMIN_SECRET" --hge-jwt-key-file="$OUTPUT_FOLDER/ssl/jwt_private.key" --hge-jwt-conf="$HASURA_GRAPHQL_JWT_SECRET" --hge-jwt-claims-ns-path="$.hasuraClaims"

kill_hge_servers

unset HASURA_GRAPHQL_JWT_SECRET

# test with CORS modes

Expand Down
4 changes: 4 additions & 0 deletions server/tests-py/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def pytest_addoption(parser):
"--hge-jwt-conf", metavar="HGE_JWT_CONF", help="The JWT conf", required=False
)

parser.addoption(
"--hge-jwt-claims-ns-path", metavar="HGE_JWT_CLAIMS_NS_PATH", help="The JWT conf claims namespace path", required=False
)

parser.addoption(
"--test-cors", action="store_true",
required=False,
Expand Down
5 changes: 5 additions & 0 deletions server/tests-py/test_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def get_claims_fmt(raw_conf):

def mk_claims(conf, claims):
claims_fmt = get_claims_fmt(conf)
claims_namespace_path = PytestConf.config.getoption(--hge-jwt-claims-ns-path)
if claims_namespace_path == '$.hasuraClaims':
claims = {
"hasuraClaims":claims
}
if claims_fmt == 'json':
return claims
elif claims_fmt == 'stringified_json':
Expand Down

0 comments on commit 4976874

Please sign in to comment.