Add credential integration test tool and configuration

This commit is contained in:
Arash
2026-03-16 11:52:56 +01:00
parent 921fc99ce5
commit 72cd9d4eeb
3 changed files with 60 additions and 0 deletions
+7
View File
@@ -12,6 +12,7 @@ from galaxy.tool_util.verify.interactor import (
UseLegacyApiT,
)
from galaxy_test.api._framework import ApiTestCase
from galaxy_test.driver import integration_util
from galaxy_test.driver.driver_util import GalaxyTestDriver
SKIPTEST = os.path.join(os.path.dirname(__file__), "known_broken_tools.txt")
@@ -64,6 +65,12 @@ class TestFrameworkTools(ApiTestCase):
conda_auto_init = True
conda_auto_install = True
@classmethod
def handle_galaxy_config_kwds(cls, config):
"""Configure vault for credential testing."""
super().handle_galaxy_config_kwds(config)
config["vault_config_file"] = integration_util.VAULT_CONF
@pytest.mark.parametrize("testcase", cases(), ids=idfn)
def test_tool(self, testcase: ToolTest):
use_legacy_api = os.environ.get("GALAXY_TEST_USE_LEGACY_TOOL_API", DEFAULT_USE_LEGACY_API)
@@ -0,0 +1,52 @@
<tool id="credentials_test" name="Credentials Test Tool" version="1.0.0" profile="25.1">
<description>Test tool for validating credential injection</description>
<requirements>
<credentials name="test_service" version="1.0">
<variable name="TEST_USERNAME" inject_as_env="TEST_USERNAME"/>
<secret name="TEST_PASSWORD" inject_as_env="TEST_PASSWORD"/>
</credentials>
</requirements>
<command><![CDATA[
echo "Username: \$TEST_USERNAME" > '$output' &&
echo "Password length: \${#TEST_PASSWORD}" >> '$output'
]]></command>
<inputs>
<param name="input_text" type="text" value="default" label="Input text"/>
</inputs>
<outputs>
<data name="output" format="txt"/>
</outputs>
<tests>
<test>
<credentials name="test_service">
<variable name="TEST_USERNAME" value="test_user"/>
<secret name="TEST_PASSWORD" value="test_password_123"/>
</credentials>
<param name="input_text" value="test_value"/>
<output name="output">
<assert_contents>
<has_text text="Username: test_user"/>
<has_text text="Password length: 17"/>
</assert_contents>
</output>
</test>
<test>
<credentials name="test_service">
<variable name="TEST_USERNAME" value="another_user"/>
<secret name="TEST_PASSWORD" value="secret"/>
</credentials>
<param name="input_text" value="another_test"/>
<output name="output">
<assert_contents>
<has_text text="Username: another_user"/>
<has_text text="Password length: 6"/>
</assert_contents>
</output>
</test>
</tests>
<help><![CDATA[
This is a test tool to validate that credentials are properly injected as environment variables during tool execution.
The tool echoes the TEST_USERNAME environment variable and the length of the TEST_PASSWORD to verify they were set.
]]></help>
</tool>
@@ -334,6 +334,7 @@
<tool file="configfile_user_defined.yml" />
<tool file="from_work_dir_glob.xml" />
<tool file="secret_tool.xml" />
<tool file="credentials_test.xml" />
<!-- Tools without tool test but useful for hand-crafted, artisanal test cases. -->
<tool file="cat_data_and_sleep.xml" />