Always enable inherited roles tests

### Description

The inherited roles integration tests were behind a flag, and its corresponding fixture, presumably to avoid enabling the option globally. However, #2288 introduced a new test using inherited roles that was not gated behind the flag, which fails when run with `dev.sh`. However, that test works on CI... because inherited roles are globally enabled there.

Consequently, this PR:
- globally enables inherited roles in dev.sh
- removes the flag and the associated fixture

https://github.com/hasura/graphql-engine-mono/pull/2358

Co-authored-by: Vishnu Bharathi <4211715+scriptnull@users.noreply.github.com>
GitOrigin-RevId: ebfa6754873324bed15b2cc5e37ec2d8008e8f8d
This commit is contained in:
Antoine Leblanc 2021-09-16 07:24:00 +01:00 committed by hasura-bot
parent fe035125f4
commit 9bae641ac4
7 changed files with 9 additions and 32 deletions

View File

@ -742,9 +742,9 @@ case "$SERVER_TEST_TO_RUN" in
run_hge_with_args serve
wait_for_port 8080
pytest -n 1 --hge-urls "$HGE_URL" --pg-urls "$HASURA_GRAPHQL_DATABASE_URL" --hge-key="$HASURA_GRAPHQL_ADMIN_SECRET" --test-inherited-roles -k TestGraphQLInheritedRolesSchema
pytest -n 1 --hge-urls "$HGE_URL" --pg-urls "$HASURA_GRAPHQL_DATABASE_URL" --hge-key="$HASURA_GRAPHQL_ADMIN_SECRET" --test-inherited-roles -k TestGraphQLInheritedRolesPostgres
pytest --hge-urls "$HGE_URL" --pg-urls "$HASURA_GRAPHQL_DATABASE_URL" --hge-key="$HASURA_GRAPHQL_ADMIN_SECRET" --test-inherited-roles --enable-remote-schema-permissions --test-function-permissions test_roles_inheritance.py
pytest -n 1 --hge-urls "$HGE_URL" --pg-urls "$HASURA_GRAPHQL_DATABASE_URL" --hge-key="$HASURA_GRAPHQL_ADMIN_SECRET" -k TestGraphQLInheritedRolesSchema
pytest -n 1 --hge-urls "$HGE_URL" --pg-urls "$HASURA_GRAPHQL_DATABASE_URL" --hge-key="$HASURA_GRAPHQL_ADMIN_SECRET" -k TestGraphQLInheritedRolesPostgres
pytest --hge-urls "$HGE_URL" --pg-urls "$HASURA_GRAPHQL_DATABASE_URL" --hge-key="$HASURA_GRAPHQL_ADMIN_SECRET" --enable-remote-schema-permissions --test-function-permissions test_roles_inheritance.py
unset HASURA_GRAPHQL_ADMIN_SECRET
unset HASURA_GRAPHQL_ENABLE_REMOTE_SCHEMA_PERMISSIONS
@ -1175,7 +1175,7 @@ admin_users = postgres' > pgbouncer/pgbouncer.ini
# start inherited roles test
echo -e "\n$(time_elapsed): <########## TEST INHERITED-ROLES WITH SQL SERVER BACKEND ###########################################>\n"
pytest -n 1 --hge-urls "$HGE_URL" --pg-urls "$HASURA_GRAPHQL_DATABASE_URL" --test-inherited-roles -k TestGraphQLInheritedRolesMSSQL --backend mssql
pytest -n 1 --hge-urls "$HGE_URL" --pg-urls "$HASURA_GRAPHQL_DATABASE_URL" -k TestGraphQLInheritedRolesMSSQL --backend mssql
# end inherited roles test

View File

@ -484,6 +484,7 @@ elif [ "$MODE" = "test" ]; then
# are defined.
export HASURA_GRAPHQL_PG_SOURCE_URL_1=${HASURA_GRAPHQL_PG_SOURCE_URL_1-$PG_DB_URL}
export HASURA_GRAPHQL_PG_SOURCE_URL_2=${HASURA_GRAPHQL_PG_SOURCE_URL_2-$PG_DB_URL}
export HASURA_GRAPHQL_EXPERIMENTAL_FEATURES="inherited_roles"
# Using --metadata-database-url flag to test multiple backends
# HASURA_GRAPHQL_PG_SOURCE_URL_* For a couple multi-source pytests:

View File

@ -160,13 +160,6 @@ This option may result in test failures if the schema has to change between the
help="Flag to indicate if the graphql-engine has enabled remote schema permissions",
)
parser.addoption(
"--test-inherited-roles",
action="store_true",
default=False,
help="Flag to specify if the inherited roles tests are to be run"
)
parser.addoption(
"--redis-url",
metavar="REDIS_URL",
@ -349,12 +342,6 @@ use_function_permission_fixtures = pytest.mark.usefixtures(
'functions_permissions_fixtures'
)
@pytest.fixture(scope='class')
def inherited_role_fixtures(hge_ctx):
if not hge_ctx.inherited_roles_tests:
pytest.skip('These tests are meant to be run with --test-inherited-roles set')
return
@pytest.fixture(scope='class')
def pro_tests_fixtures(hge_ctx):
if not hge_ctx.pro_tests:
@ -646,8 +633,3 @@ def is_master(config):
node or not running xdist at all.
"""
return not hasattr(config, 'slaveinput')
use_inherited_roles_fixtures = pytest.mark.usefixtures(
"inherited_role_fixtures",
"per_class_tests_db_state"
)

View File

@ -641,7 +641,6 @@ class HGECtx:
self.hge_scale_url = config.getoption('--test-hge-scale-url')
self.avoid_err_msg_checks = config.getoption('--avoid-error-message-checks')
self.inherited_roles_tests = config.getoption('--test-inherited-roles')
self.pro_tests = config.getoption('--pro-tests')
self.ws_client = GQLWsClient(self, '/v1/graphql')

View File

@ -1,6 +1,6 @@
import pytest
from validate import check_query_f, check_query, get_conf_f
from conftest import use_inherited_roles_fixtures, use_function_permission_fixtures
from conftest import use_function_permission_fixtures
# Marking all tests in this module that server upgrade tests can be run

View File

@ -1,6 +1,5 @@
import pytest
from validate import check_query_f, check_query, get_conf_f
from conftest import use_inherited_roles_fixtures
from context import PytestConf
# Mark that all tests in this module can be run as server upgrade tests
@ -660,7 +659,7 @@ class TestGraphqlQueryPermissions:
# be common across all the backends, to add DB specific tests
# look for the TestGraphQLInheritedRoles<backend> test classes
@pytest.mark.parametrize('transport', ['http', 'websocket'])
@use_inherited_roles_fixtures
@usefixtures('per_class_tests_db_state')
class TestGraphQLInheritedRolesSchema:
@classmethod
@ -724,7 +723,7 @@ class TestGraphQLInheritedRolesSchema:
check_query_f(hge_ctx, self.dir() + '/inherited_role_parent_is_another_inherited_role.yaml')
@pytest.mark.parametrize('transport', ['http', 'websocket'])
@use_inherited_roles_fixtures
@usefixtures('per_class_tests_db_state')
class TestGraphQLInheritedRolesPostgres:
@classmethod
@ -741,7 +740,7 @@ class TestGraphQLInheritedRolesPostgres:
@pytest.mark.parametrize('transport', ['http', 'websocket'])
@pytest.mark.parametrize('backend', ['mssql'])
@usefixtures('per_backend_tests', 'inherited_role_fixtures', 'per_class_tests_db_state')
@usefixtures('per_backend_tests', 'per_class_tests_db_state')
class TestGraphQLInheritedRolesMSSQL:
@classmethod

View File

@ -1,4 +1,3 @@
import pytest
from validate import check_query_f, check_query
@ -7,9 +6,6 @@ from context import PytestConf
from conftest import use_action_fixtures, use_function_permission_fixtures
if not PytestConf.config.getoption('--test-inherited-roles'):
pytest.skip('--test-inherited-roles is missing, skipping role inheritance tests', allow_module_level=True)
if not PytestConf.config.getoption('--enable-remote-schema-permissions'):
pytest.skip('--enable-remote-schema-permissions is missing, skipping role inheritance tests', allow_module_level=True)