mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Update integration test
Test boolean expression with group names containing spaces and surrounded by single quotes
This commit is contained in:
@@ -6,10 +6,12 @@ import shutil
|
||||
from tempfile import mkdtemp
|
||||
from typing import ClassVar
|
||||
|
||||
from .driver_util import GalaxyTestDriver
|
||||
from galaxy_test.driver.driver_util import GalaxyTestDriver
|
||||
|
||||
REQUIRED_ROLE = "user@bx.psu.edu"
|
||||
REQUIRED_GROUP = "fs_test_group"
|
||||
REQUIRED_ROLE_EXPRESSION = "user@bx.psu.edu"
|
||||
GROUP_A = "fs_test_group"
|
||||
GROUP_B = "group name with spaces"
|
||||
REQUIRED_GROUP_EXPRESSION = f"{GROUP_A} or '{GROUP_B}'"
|
||||
|
||||
|
||||
def get_posix_file_source_config(root_dir: str, roles: str, groups: str, include_test_data_dir: bool) -> str:
|
||||
@@ -36,7 +38,9 @@ def get_posix_file_source_config(root_dir: str, roles: str, groups: str, include
|
||||
|
||||
|
||||
def create_file_source_config_file_on(temp_dir, root_dir, include_test_data_dir):
|
||||
file_contents = get_posix_file_source_config(root_dir, REQUIRED_ROLE, REQUIRED_GROUP, include_test_data_dir)
|
||||
file_contents = get_posix_file_source_config(
|
||||
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:
|
||||
f.write(file_contents)
|
||||
|
||||
@@ -6,10 +6,13 @@
|
||||
from galaxy_test.base import api_asserts
|
||||
from galaxy_test.base.populators import DatasetPopulator
|
||||
from galaxy_test.driver import integration_util
|
||||
from galaxy_test.driver.integration_setup import PosixFileSourceSetup
|
||||
|
||||
REQUIRED_ROLE = "user@bx.psu.edu"
|
||||
REQUIRED_GROUP = "fs_test_group"
|
||||
from galaxy_test.driver.integration_setup import (
|
||||
GROUP_A,
|
||||
GROUP_B,
|
||||
PosixFileSourceSetup,
|
||||
REQUIRED_GROUP_EXPRESSION,
|
||||
REQUIRED_ROLE_EXPRESSION,
|
||||
)
|
||||
|
||||
|
||||
class PosixFileSourceIntegrationTestCase(PosixFileSourceSetup, integration_util.IntegrationTestCase):
|
||||
@@ -32,8 +35,8 @@ class PosixFileSourceIntegrationTestCase(PosixFileSourceSetup, integration_util.
|
||||
assert plugins[0]["type"] == "posix"
|
||||
assert plugins[0]["uri_root"] == "gxfiles://posix_test"
|
||||
assert plugins[0]["writable"] is True
|
||||
assert plugins[0]["requires_roles"] == REQUIRED_ROLE
|
||||
assert plugins[0]["requires_groups"] == REQUIRED_GROUP
|
||||
assert plugins[0]["requires_roles"] == REQUIRED_ROLE_EXPRESSION
|
||||
assert plugins[0]["requires_groups"] == REQUIRED_GROUP_EXPRESSION
|
||||
|
||||
def test_allow_admin_access(self):
|
||||
data = {"target": "gxfiles://posix_test"}
|
||||
@@ -42,15 +45,22 @@ class PosixFileSourceIntegrationTestCase(PosixFileSourceSetup, integration_util.
|
||||
|
||||
def test_user_access(self):
|
||||
data = {"target": "gxfiles://posix_test"}
|
||||
group_id = self._create_group(REQUIRED_GROUP)
|
||||
group_a_id = self._create_group(GROUP_A)
|
||||
group_b_id = self._create_group(GROUP_B)
|
||||
|
||||
# User has role but not group
|
||||
list_response = self.galaxy_interactor.get("remote_files", data)
|
||||
self._assert_access_forbidden_response(list_response)
|
||||
|
||||
# User has role and group
|
||||
# User has role and group A
|
||||
user_id = self.dataset_populator.user_id()
|
||||
self._add_user_to_group(group_id, user_id)
|
||||
self._add_user_to_group(group_a_id, user_id)
|
||||
list_response = self.galaxy_interactor.get("remote_files", data)
|
||||
self._assert_list_response_matches_fixtures(list_response)
|
||||
|
||||
# Remove User from group A and add to group B
|
||||
self._remove_user_from_group(group_a_id, user_id)
|
||||
self._add_user_to_group(group_b_id, user_id)
|
||||
list_response = self.galaxy_interactor.get("remote_files", data)
|
||||
self._assert_list_response_matches_fixtures(list_response)
|
||||
|
||||
@@ -68,6 +78,10 @@ class PosixFileSourceIntegrationTestCase(PosixFileSourceSetup, integration_util.
|
||||
update_response = self._put(f"groups/{group_id}/users/{user_id}", admin=True)
|
||||
self._assert_status_code_is_ok(update_response)
|
||||
|
||||
def _remove_user_from_group(self, group_id, user_id):
|
||||
update_response = self._delete(f"groups/{group_id}/users/{user_id}", admin=True)
|
||||
self._assert_status_code_is_ok(update_response)
|
||||
|
||||
def _assert_list_response_matches_fixtures(self, list_response):
|
||||
api_asserts.assert_status_code_is_ok(list_response)
|
||||
remote_files = list_response.json()
|
||||
|
||||
Reference in New Issue
Block a user