mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
I want to be able to use this class in galaxy.model and it doesn't have any dependnecies on "web" stuff so I'd like to move it out of galaxy.model and into galaxy.security. galaxy.model shouldn't have dependencies on galaxy.web (and doesn't after the recent 976f5ad367), so this pre-emptively ensures it doesn't require these dependencies for https://github.com/galaxyproject/galaxy/pull/7367.
This has the benefit of also eliminating any galaxy.web dependencies from the generic test base file (test/base/testcase.py) which has long been a goal of mine as well.
There are places we legimately use ID encoding and decoding for security (i.e. job files API) but for the most part it doesn't provide security for API endpoints and this causes confusion repeatedly, so I've started the process of renaming the contained class SecurityHelper to something I feel makes it clearer this is just about encoding and decoding IDs.
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
from __future__ import print_function
|
|
|
|
import logging
|
|
import os
|
|
import unittest
|
|
|
|
from galaxy.security import idencoding
|
|
from galaxy.tools.verify.test_data import TestDataResolver
|
|
from .driver_util import GalaxyTestDriver, setup_keep_outdir, target_url_parts
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
class FunctionalTestCase(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
self.security = idencoding.IdEncodingHelper(id_secret='changethisinproductiontoo')
|
|
self.history_id = os.environ.get('GALAXY_TEST_HISTORY_ID', None)
|
|
self.host, self.port, self.url = target_url_parts()
|
|
self.test_data_resolver = TestDataResolver()
|
|
self.keepOutdir = setup_keep_outdir()
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
"""Configure and start Galaxy for a test."""
|
|
cls._test_driver = None
|
|
|
|
if not os.environ.get("GALAXY_TEST_ENVIRONMENT_CONFIGURED"):
|
|
cls._test_driver = GalaxyTestDriver()
|
|
cls._test_driver.setup(config_object=cls)
|
|
|
|
@classmethod
|
|
def tearDownClass(cls):
|
|
"""Shutdown Galaxy server and cleanup temp directory."""
|
|
if cls._test_driver:
|
|
cls._test_driver.tear_down()
|
|
|
|
def get_filename(self, filename):
|
|
# No longer used by tool tests - drop if isn't used else where.
|
|
return self.test_data_resolver.get_filename(filename)
|