mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 17:31:56 +03:00
60f81023db
This teaches `hge_server` how to run more tests, thanks to `hge_env`. It also simplifies the logic a bit more. I have also modified _run.sh_ and _docker-compose.yml_ so we can run multiple test suites, one after another. PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6105 GitOrigin-RevId: eff009362eb6bb90c07cedaf96dfe6ec9336ff32
90 lines
3.3 KiB
Python
90 lines
3.3 KiB
Python
import pytest
|
|
|
|
from conftest import use_action_fixtures
|
|
from context import PytestConf
|
|
from remote_server import NodeGraphQL
|
|
from validate import check_query_f
|
|
|
|
pytestmark = [
|
|
pytest.mark.hge_env('HASURA_GRAPHQL_ENABLE_REMOTE_SCHEMA_PERMISSIONS', 'true'),
|
|
]
|
|
|
|
@pytest.fixture(scope='class')
|
|
@pytest.mark.early
|
|
def graphql_service(hge_fixture_env: dict[str, str]):
|
|
svc = NodeGraphQL(["node", "remote_schemas/nodejs/remote_schema_perms.js"], port=4020)
|
|
svc.start()
|
|
hge_fixture_env['GRAPHQL_SERVICE_1'] = svc.url
|
|
yield svc
|
|
svc.stop()
|
|
|
|
@pytest.mark.usefixtures('per_class_db_schema_for_mutation_tests', 'per_method_db_data_for_mutation_tests')
|
|
class TestGraphQLMutationRolesInheritance:
|
|
|
|
@classmethod
|
|
def dir(cls):
|
|
return 'queries/graphql_mutation/roles_inheritance/'
|
|
|
|
setup_metadata_api_version = "v2"
|
|
|
|
def test_inheritance_from_single_parent(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + 'inheritance_from_single_parent.yaml')
|
|
|
|
def test_inheritance_when_mutation_permissions_conflict(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + 'resolve_inconsistent_permission.yaml')
|
|
|
|
def test_mutation_permission_inheritance_for_nested_roles(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + 'inherited_mutation_permission_for_nested_roles.yaml')
|
|
|
|
def test_defined_permission_should_override_inherited_permission(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + 'override_inherited_permission.yaml')
|
|
|
|
@pytest.mark.usefixtures('graphql_service', 'per_class_tests_db_state')
|
|
class TestRemoteSchemaPermissionsInheritance:
|
|
|
|
@classmethod
|
|
def dir(cls):
|
|
return "queries/remote_schemas/permissions/inheritance/"
|
|
|
|
setup_metadata_api_version = "v2"
|
|
|
|
def test_inheritance_from_multiple_parents_having_no_conflicts(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + 'multiple_parents_inheritance.yaml')
|
|
|
|
def test_conflicting_parent_permissions(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + 'conflicting_parent_permissions.yaml')
|
|
|
|
def test_override_inherited_permission(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + 'override_inherited_permission.yaml')
|
|
|
|
@use_action_fixtures
|
|
class TestActionsPermissionInheritance:
|
|
|
|
@classmethod
|
|
def dir(cls):
|
|
return "queries/actions/roles_inheritance/"
|
|
|
|
setup_metadata_api_version = "2"
|
|
|
|
def test_inheritance_from_multiple_parents(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + 'multiple_parents_inheritance.yaml')
|
|
|
|
def test_override_inherited_permission(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + 'override_inherited_permission.yaml')
|
|
|
|
@pytest.mark.usefixtures('per_class_db_schema_for_mutation_tests', 'per_method_db_data_for_mutation_tests')
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_INFER_FUNCTION_PERMISSIONS', 'false')
|
|
class TestCustomFunctionPermissionsInheritance:
|
|
|
|
@classmethod
|
|
def dir(cls):
|
|
return "queries/graphql_mutation/functions/permissions/roles_inheritance/"
|
|
|
|
setup_metadata_api_version = "2"
|
|
|
|
def test_inheritance_from_multiple_parents(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + 'multiple_parents_inheritance.yaml')
|
|
|
|
def test_override_inherited_permission(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + 'override_inherited_permission.yaml')
|