-
Notifications
You must be signed in to change notification settings - Fork 991
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configuration tests for the last few upload enhancements.
- Loading branch information
Showing
5 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
test/integration/test_check_upload_content_configuration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
"""Integration tests for check_upload_content configuraiton option.""" | ||
|
||
from base import integration_util | ||
from base.populators import DatasetPopulator | ||
|
||
|
||
class BaseCheckUploadContentConfigurationTestCase(integration_util.IntegrationTestCase): | ||
|
||
framework_tool_and_types = True | ||
|
||
def setUp(self): | ||
super(BaseCheckUploadContentConfigurationTestCase, self).setUp() | ||
self.dataset_populator = DatasetPopulator(self.galaxy_interactor) | ||
self.history_id = self.dataset_populator.new_history() | ||
|
||
|
||
class NonAdminsCannotPasteFilePathTestCase(BaseCheckUploadContentConfigurationTestCase): | ||
|
||
@classmethod | ||
def handle_galaxy_config_kwds(cls, config): | ||
config["allow_path_paste"] = True | ||
|
||
def test(self): | ||
payload = self.dataset_populator.upload_payload( | ||
self.history_id, 'file:///Users/john/workspace/galaxy/test-data/1.RData', ext="binary" | ||
) | ||
create_response = self._post( "tools", data=payload ) | ||
# Ideally this would be 403 but the tool API endpoint isn't using | ||
# the newer API decorator that handles those details. | ||
assert create_response.status_code >= 400 | ||
|
||
|
||
class AdminsCanPasteFilePathsTestCase(BaseCheckUploadContentConfigurationTestCase): | ||
|
||
require_admin_user = True | ||
|
||
@classmethod | ||
def handle_galaxy_config_kwds(cls, config): | ||
config["allow_path_paste"] = True | ||
|
||
def test(self): | ||
payload = self.dataset_populator.upload_payload( | ||
self.history_id, 'file:///Users/john/workspace/galaxy/test-data/random-file', | ||
) | ||
create_response = self._post( "tools", data=payload ) | ||
# Ideally this would be 403 but the tool API endpoint isn't using | ||
# the newer API decorator that handles those details. | ||
assert create_response.status_code == 200 | ||
|
||
|
||
class DefaultBinaryContentFiltersTestCase(BaseCheckUploadContentConfigurationTestCase): | ||
|
||
require_admin_user = True | ||
|
||
@classmethod | ||
def handle_galaxy_config_kwds(cls, config): | ||
config["allow_path_paste"] = True | ||
|
||
def test_random_binary_allowed(self): | ||
dataset = self.dataset_populator.new_dataset( | ||
self.history_id, 'file:///Users/john/workspace/galaxy/test-data/random-file', file_type="auto", wait=True | ||
) | ||
dataset = self.dataset_populator.get_history_dataset_details(self.history_id, dataset=dataset) | ||
assert dataset["file_ext"] == "data", dataset | ||
|
||
def test_gzipped_html_content_blocked_by_default(self): | ||
dataset = self.dataset_populator.new_dataset( | ||
self.history_id, 'file:///Users/john/workspace/galaxy/test-data/bad.html.gz', file_type="auto", wait=True | ||
) | ||
dataset = self.dataset_populator.get_history_dataset_details(self.history_id, dataset=dataset) | ||
assert dataset["file_size"] == 0 | ||
|
||
|
||
class DisableContentCheckingTestCase(BaseCheckUploadContentConfigurationTestCase): | ||
|
||
require_admin_user = True | ||
|
||
@classmethod | ||
def handle_galaxy_config_kwds(cls, config): | ||
config["allow_path_paste"] = True | ||
config["check_upload_content"] = False | ||
|
||
def test_gzipped_html_content_now_allowed(self): | ||
self.dataset_populator.new_dataset( | ||
self.history_id, 'file:///Users/john/workspace/galaxy/test-data/bad.html.gz', file_type="auto", wait=True | ||
) | ||
dataset = self.dataset_populator.get_history_dataset_details(self.history_id, dataset=dataset) | ||
# Same file was empty above! | ||
assert dataset["file_size"] != 0 | ||
|
||
|
||
class AutoDecompressTestCase(BaseCheckUploadContentConfigurationTestCase): | ||
|
||
require_admin_user = True | ||
|
||
@classmethod | ||
def handle_galaxy_config_kwds(cls, config): | ||
config["allow_path_paste"] = True | ||
|
||
def test_auto_decompress_off(self): | ||
dataset = self.dataset_populator.new_dataset( | ||
self.history_id, 'file:///Users/john/workspace/galaxy/test-data/1.sam.gz', file_type="auto", auto_decompress=False, wait=True | ||
) | ||
dataset = self.dataset_populator.get_history_dataset_details(self.history_id, dataset=dataset) | ||
assert dataset["file_ext"] == "data", dataset | ||
|
||
def test_auto_decompress_on(self): | ||
dataset = self.dataset_populator.new_dataset( | ||
self.history_id, 'file:///Users/john/workspace/galaxy/test-data/1.sam.gz', file_type="auto", wait=True | ||
) | ||
dataset = self.dataset_populator.get_history_dataset_details(self.history_id, dataset=dataset) | ||
assert dataset["file_ext"] == "sam", dataset |