diff --git a/SAS/TMSS/docker-compose-scu199.yml b/SAS/TMSS/docker-compose-scu199.yml index 8e175a4b869e00fa65ddd8619e16ce238cb8798b..f2aa2b2c357fe81ae4724db31d79b31ed8702762 100644 --- a/SAS/TMSS/docker-compose-scu199.yml +++ b/SAS/TMSS/docker-compose-scu199.yml @@ -6,7 +6,7 @@ services: restart: on-failure env_file: - ./.env - command: bash -c 'source /opt/lofar/lofarinit.sh && tmss_test_environment -p 8008' + command: bash -c 'source /opt/lofar/lofarinit.sh && ALLOWED_HOSTS=* tmss_test_environment -H 0.0.0.0 -p 8008' ports: - "8008:8008" testprovider: diff --git a/SAS/TMSS/test/test_utils.py b/SAS/TMSS/test/test_utils.py index 5633744e750120c86f404b7b41fb5a6416d70bd5..34e44c6f384073421611136ed7c6d8e7c24b39c2 100644 --- a/SAS/TMSS/test/test_utils.py +++ b/SAS/TMSS/test/test_utils.py @@ -113,16 +113,17 @@ class TMSSPostgresTestMixin(PostgresTestMixin): class TMSSDjangoServerInstance(): ''' Creates a running django TMSS server at the requested port with the requested database credentials. ''' - def __init__(self, db_dbcreds_id: str="TMSS", ldap_dbcreds_id: str="TMSS_LDAP", port: int=8000): + def __init__(self, db_dbcreds_id: str="TMSS", ldap_dbcreds_id: str="TMSS_LDAP", host: str='127.0.0.1', port: int=8000): self._db_dbcreds_id = db_dbcreds_id self._ldap_dbcreds_id = ldap_dbcreds_id + self.host = host self.port = port self._server_process = None @property def address(self): ''':returns the address and port of the django server''' - return "127.0.0.1:%d" % self.port + return "%s:%d" % (self.host, self.port) @property def url(self): @@ -240,11 +241,12 @@ class TMSSDjangoServerInstance(): class TMSSTestEnvironment: '''Create and run a test django TMSS server against a newly created test database and a test ldap server (and cleanup automagically)''' - def __init__(self, preferred_django_port: int=8000): + def __init__(self, host: str='127.0.0.1', preferred_django_port: int=8000): self.ldap_server = TestLDAPServer(user='test', password='test') self.database = TMSSTestDatabaseInstance() self.django_server = TMSSDjangoServerInstance(db_dbcreds_id=self.database.dbcreds_id, ldap_dbcreds_id=self.ldap_server.dbcreds_id, + host=host, port=find_free_port(preferred_django_port)) def start(self): @@ -310,13 +312,15 @@ def main_test_environment(): parser = OptionParser('%prog [options]', description='setup/run/teardown a full TMSS test environment including a fresh and isolated database, LDAP server and DJANGO REST server.') + parser.add_option("-H", "--host", dest="host", type="string", default='127.0.0.1', + help="expose the TMSS Django REST API via this host. [default=%default]") parser.add_option("-p", "--port", dest="port", type="int", default=find_free_port(8000), help="try to use this port for the DJANGO REST API. If not available, then a random free port is used and logged. [default=%default]") (options, args) = parser.parse_args() logging.basicConfig(format = '%(asctime)s %(levelname)s %(message)s', level = logging.INFO) - with TMSSTestEnvironment(preferred_django_port=options.port) as instance: + with TMSSTestEnvironment(host=options.host, preferred_django_port=options.port) as instance: # print some nice info for the user to use the test servers... # use print instead of log for clean lines. for h in logging.root.handlers: