Skip to content

Commit

Permalink
Refactor test cases to remove unused TestSecretsInExtraUserPreference…
Browse files Browse the repository at this point in the history
…s class and add credentials parsing test
  • Loading branch information
arash77 committed Dec 2, 2024
1 parent a6b4da5 commit e07c413
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 25 deletions.
50 changes: 25 additions & 25 deletions test/integration/test_vault_extra_prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,28 @@ def _get_dbuser(self, app, user):
return get_user_by_email(app.model.session, user["email"])


class TestSecretsInExtraUserPreferences(
integration_util.IntegrationTestCase, integration_util.ConfiguresDatabaseVault, TestsTools
):
dataset_populator: DatasetPopulator

@classmethod
def handle_galaxy_config_kwds(cls, config):
super().handle_galaxy_config_kwds(config)
cls._configure_database_vault(config)
config["user_preferences_extra_conf_path"] = os.path.join(
os.path.dirname(__file__), "user_preferences_extra_conf.yml"
)

def setUp(self):
super().setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)

@skip_without_tool("secret_tool")
def test_secrets_tool(self, history_id):
user = self._setup_user(TEST_USER_EMAIL)
url = self._api_url(f"users/{user['id']}/information/inputs", params=dict(key=self.master_api_key))
put(url, data=json.dumps({"secret_tool|api_key": "test"}))
run_response = self._run("secret", history_id, assert_ok=True)
outputs = run_response["outputs"]
assert outputs[0]["extra_files"][0]["value"] == "test"
# class TestSecretsInExtraUserPreferences(
# integration_util.IntegrationTestCase, integration_util.ConfiguresDatabaseVault, TestsTools
# ):
# dataset_populator: DatasetPopulator

# @classmethod
# def handle_galaxy_config_kwds(cls, config):
# super().handle_galaxy_config_kwds(config)
# cls._configure_database_vault(config)
# config["user_preferences_extra_conf_path"] = os.path.join(
# os.path.dirname(__file__), "user_preferences_extra_conf.yml"
# )

# def setUp(self):
# super().setUp()
# self.dataset_populator = DatasetPopulator(self.galaxy_interactor)

# @skip_without_tool("secret_tool")
# def test_secrets_tool(self, history_id):
# user = self._setup_user(TEST_USER_EMAIL)
# url = self._api_url(f"users/{user['id']}/information/inputs", params=dict(key=self.master_api_key))
# put(url, data=json.dumps({"secret_tool|api_key": "test"}))
# run_response = self._run("secret", history_id, assert_ok=True)
# outputs = run_response["outputs"]
# assert outputs[0]["extra_files"][0]["value"] == "test"
15 changes: 15 additions & 0 deletions test/unit/tool_util/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
<resource type="cuda_device_count_min">1</resource>
<resource type="cuda_device_count_max">2</resource>
<resource type="shm_size">67108864</resource>
<credentials name="Apollo" reference="gmod.org/apollo" required="true" label="Apollo credential set" description="Please provide credentials for Apollo">
<variable name="server" inject_as_env="apollo_url" label="Your Apollo server" />
<secret name="username" inject_as_env="apollo_user" label="Your Apollo username" />
<secret name="password" inject_as_env="apollo_pass" label="Your Apollo password" />
</credentials>
</requirements>
<outputs>
<data name="out1" format="bam" from_work_dir="out1.bam" />
Expand Down Expand Up @@ -359,6 +364,16 @@ def test_requirements(self):
assert resource_requirements[6].resource_type == "shm_size"
assert not resource_requirements[0].runtime_required

def test_credentials(self):
*_, credentials = self._tool_source.parse_requirements_and_containers()
assert credentials[0].name == "Apollo"
assert credentials[0].reference == "gmod.org/apollo"
assert credentials[0].required
assert len(credentials[0].secrets_and_variables) == 3
assert credentials[0].secrets_and_variables[0].type == "variable"
assert credentials[0].secrets_and_variables[1].type == "secret"
assert credentials[0].secrets_and_variables[2].type == "secret"

def test_outputs(self):
outputs, output_collections = self._tool_source.parse_outputs(object())
assert len(outputs) == 1, outputs
Expand Down

0 comments on commit e07c413

Please sign in to comment.