From cdbfe6787bdee89dc7e1b26c342dac5fa5943f74 Mon Sep 17 00:00:00 2001 From: Lain Pavot Date: Mon, 19 Dec 2022 17:40:48 +0100 Subject: [PATCH] Fixes #15224 - tools token are created with a size of 10 chars when interactivetools_shorten_url is true --- lib/galaxy/managers/interactivetool.py | 1 + lib/galaxy/model/__init__.py | 7 +++++-- test/integration/test_interactivetools_api.py | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/managers/interactivetool.py b/lib/galaxy/managers/interactivetool.py index 971d2bb5f414..2c264ef12265 100644 --- a/lib/galaxy/managers/interactivetool.py +++ b/lib/galaxy/managers/interactivetool.py @@ -163,6 +163,7 @@ def create_entry_points(self, job, tool, entry_points=None, flush=True): entry_url=entry["url"], name=entry["name"], requires_domain=entry["requires_domain"], + short_token=self.app.config.interactivetools_shorten_url, ) self.sa_session.add(ep) if flush: diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index ca9405a6451e..ff69892c6eea 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -2340,12 +2340,15 @@ class InteractiveToolEntryPoint(Base, Dictifiable, RepresentById): dict_collection_visible_keys = ["id", "name", "active", "created_time", "modified_time"] dict_element_visible_keys = ["id", "name", "active", "created_time", "modified_time"] - def __init__(self, requires_domain=True, configured=False, deleted=False, **kwd): + def __init__(self, requires_domain=True, configured=False, deleted=False, short_token=False, **kwd): super().__init__(**kwd) self.requires_domain = requires_domain self.configured = configured self.deleted = deleted - self.token = self.token or uuid4().hex + if short_token: + self.token = (self.token or uuid4().hex)[:10] + else: + self.token = self.token or uuid4().hex self.info = self.info or {} @property diff --git a/test/integration/test_interactivetools_api.py b/test/integration/test_interactivetools_api.py index ff239d2877dc..3a60e55214df 100644 --- a/test/integration/test_interactivetools_api.py +++ b/test/integration/test_interactivetools_api.py @@ -147,6 +147,14 @@ def handle_galaxy_config_kwds(cls, config): disable_dependency_resolution(config) +class InteractiveToolsShortURLIntegrationTestCase(BaseInteractiveToolsIntegrationTestCase, RunsInterativeToolTests): + @classmethod + def handle_galaxy_config_kwds(cls, config): + super().handle_galaxy_config_kwds(config) + config["interactivetools_shorten_url"] = True + config["job_config_file"] = DOCKERIZED_JOB_CONFIG_FILE + + class InteractiveToolsRemoteProxyIntegrationTestCase(BaseInteractiveToolsIntegrationTestCase, RunsInterativeToolTests): """ $ cd gx-it-proxy