Relax file source access requirements in tests

By default the user must have the required role and groups. To simplify the setup of other tests, by default `PosixFileSourceSetup` will not require groups unless explicitly specified in the test.
This way we are always testing the default `test user` access through the role.
This commit is contained in:
davelopez
2022-12-08 13:33:08 +01:00
parent 400332cad0
commit 2e81952877
2 changed files with 30 additions and 4 deletions
+21 -4
View File
@@ -37,9 +37,15 @@ def get_posix_file_source_config(root_dir: str, roles: str, groups: str, include
return rval
def create_file_source_config_file_on(temp_dir, root_dir, include_test_data_dir):
def create_file_source_config_file_on(
temp_dir,
root_dir,
include_test_data_dir,
required_role_expression,
required_group_expression,
):
file_contents = get_posix_file_source_config(
root_dir, REQUIRED_ROLE_EXPRESSION, REQUIRED_GROUP_EXPRESSION, include_test_data_dir
root_dir, required_role_expression, required_group_expression, include_test_data_dir
)
file_path = os.path.join(temp_dir, "file_sources_conf_posix.yml")
with open(file_path, "w") as f:
@@ -53,14 +59,25 @@ class PosixFileSourceSetup:
include_test_data_dir: ClassVar[bool] = False
@classmethod
def handle_galaxy_config_kwds(cls, config, clazz_=None):
def handle_galaxy_config_kwds(
cls,
config,
clazz_=None,
# Require role for access but do not require groups by default on every test to simplify them
required_role_expression=REQUIRED_ROLE_EXPRESSION,
required_group_expression="",
):
temp_dir = os.path.realpath(mkdtemp())
clazz_ = clazz_ or cls
clazz_._test_driver.temp_directories.append(temp_dir)
clazz_.root_dir = os.path.join(temp_dir, "root")
file_sources_config_file = create_file_source_config_file_on(
temp_dir, clazz_.root_dir, clazz_.include_test_data_dir
temp_dir,
clazz_.root_dir,
clazz_.include_test_data_dir,
required_role_expression,
required_group_expression,
)
config["file_sources_config_file"] = file_sources_config_file
@@ -16,6 +16,15 @@ from galaxy_test.driver.integration_setup import (
class PosixFileSourceIntegrationTestCase(PosixFileSourceSetup, integration_util.IntegrationTestCase):
@classmethod
def handle_galaxy_config_kwds(cls, config):
PosixFileSourceSetup.handle_galaxy_config_kwds(
config,
cls,
required_role_expression=REQUIRED_ROLE_EXPRESSION,
required_group_expression=REQUIRED_GROUP_EXPRESSION,
)
def setUp(self):
super().setUp()
self._write_file_fixtures()