Files
Alireza Heidari 6241b5071d Add another_galaxy_servers config option
List the Galaxy servers that the "Import from Another Galaxy" upload method offers to choose items from, defaulting to usegalaxy.eu, usegalaxy.org and usegalaxy.org.au. Each entry takes a label and an http(s) URL, validated like subdomain_switcher, and the list is exposed to all users through the configuration API. Users can still type the URL of any other Galaxy.
2026-11-16 13:30:31 +01:00

87 lines
3.1 KiB
Python

from galaxy_test.base.api_asserts import (
assert_has_keys,
assert_not_has_keys,
)
from galaxy_test.base.api_util import TEST_USER
from galaxy_test.base.decorators import requires_admin
from ._framework import ApiTestCase
TEST_KEYS_FOR_ALL_USERS = [
"curated_workflows_source",
"enable_unique_workflow_defaults",
"ftp_upload_site",
"wiki_url",
"support_url",
"logo_url",
"terms_url",
"allow_user_dataset_purge",
"subdomain_switcher",
"another_galaxy_servers",
"enable_command_palette",
"command_palette_disabled_providers",
]
DEFAULT_ANOTHER_GALAXY_SERVERS = [
{"label": "usegalaxy.eu", "url": "https://usegalaxy.eu"},
{"label": "usegalaxy.org", "url": "https://usegalaxy.org"},
{"label": "usegalaxy.org.au", "url": "https://usegalaxy.org.au"},
]
TEST_KEYS_FOR_ADMIN_ONLY = [
"library_import_dir",
"user_library_import_dir",
"allow_library_path_paste",
"allow_user_deletion",
"tool_shed_urls",
]
class TestConfigurationApi(ApiTestCase):
def test_whoami(self):
response = self._get("whoami")
self._assert_status_code_is(response, 200)
assert response.json()["email"] == TEST_USER
def test_normal_user_configuration(self):
config = self._get_configuration()
assert_has_keys(config, *TEST_KEYS_FOR_ALL_USERS)
assert_not_has_keys(config, *TEST_KEYS_FOR_ADMIN_ONLY)
assert config["subdomain_switcher"] == []
assert config["another_galaxy_servers"] == DEFAULT_ANOTHER_GALAXY_SERVERS
def test_anonymous_user_configuration(self):
with self._different_user(anon=True):
config = self._get_configuration()
assert_has_keys(config, "subdomain_switcher", "another_galaxy_servers")
assert config["subdomain_switcher"] == []
assert config["another_galaxy_servers"] == DEFAULT_ANOTHER_GALAXY_SERVERS
@requires_admin
def test_admin_user_configuration(self):
config = self._get_configuration(admin=True)
assert_has_keys(config, *TEST_KEYS_FOR_ALL_USERS)
assert_has_keys(config, *TEST_KEYS_FOR_ADMIN_ONLY)
def test_short_term_storage_effective_duration(self):
config = self._get_configuration()
assert config["short_term_storage_effective_duration"] == 86400
with self._different_user(anon=True):
config = self._get_configuration()
assert config["short_term_storage_effective_duration"] == 86400
def test_normal_user_decode_id(self):
decode_response = self._get("configuration/decode/badhombre", admin=False)
self._assert_status_code_is(decode_response, 403)
def _get_configuration(self, data=None, admin=False):
data = data or {}
response = self._get("configuration", data=data, admin=admin)
self._assert_status_code_is(response, 200)
configuration = response.json()
return configuration
def test_version(self):
response = self._get("version")
self._assert_status_code_is(response, 200)
data = response.json()
assert "version_major" in data
assert "version_minor" in data