Files
galaxy/lib/galaxy_test/api/test_unprivileged_tools_api_surface.py
mvdbeek a7acbc2655 Exclude private user-defined tools from the public dynamic tools index
DynamicToolManager.list_tools backs the public, unauthenticated
GET /api/dynamic_tools endpoint but filtered only on active, not
public. Any anonymous caller could list every user's private
GalaxyUserTool rows, including the full stored representation
(shell_command and all). Filter on DynamicTool.public == true() so
the index only ever returns admin-installed dynamic tools.
2026-09-29 20:46:12 +02:00

22 lines
858 B
Python

from galaxy.tool_util_models import UserToolSource
from galaxy_test.base.populators import (
DatasetPopulator,
TOOL_WITH_SHELL_COMMAND,
)
from ._framework import ApiTestCase
class TestUnprivilegedToolsApiSurface(ApiTestCase):
def setUp(self):
super().setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
def test_public_dynamic_tools_index_excludes_private_udt(self):
with self.dataset_populator.user_tool_execute_permissions():
dynamic_tool = self.dataset_populator.create_unprivileged_tool(UserToolSource(**TOOL_WITH_SHELL_COMMAND))
response = self._get("dynamic_tools", anon=True)
assert response.status_code == 200, response.text
listed_uuids = {t["uuid"] for t in response.json()}
assert dynamic_tool["uuid"] not in listed_uuids, response.text