From 080d79167bf8d35997428d05b7a3a71dabbc3387 Mon Sep 17 00:00:00 2001 From: Jun Aishima Date: Wed, 19 Mar 2025 16:59:24 -0400 Subject: [PATCH 01/10] if use_ssl flag is specified, use https * or else use http and port number --- analysisstore/client/commands.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/analysisstore/client/commands.py b/analysisstore/client/commands.py index caf94ea..186845b 100644 --- a/analysisstore/client/commands.py +++ b/analysisstore/client/commands.py @@ -14,6 +14,7 @@ class AnalysisClient: def __init__(self, config): self.host = config['host'] self.port = config['port'] + self.use_ssl = config['use_ssl'] self._insert_dict = {'analysis_header': self.insert_analysis_header, 'analysis_tail': self.insert_analysis_tail, 'data_reference_header': self.insert_data_reference_header, @@ -27,7 +28,11 @@ def __init__(self, config): @property def _host_url(self): """URL to the tornado instance""" - return 'http://{}:{}/'.format(self.host, self.port) + if not self.use_ssl: + url = 'http://{}:{}/'.format(self.host, self.port) + else: + url = f'https://{self.host}' + return url @property def aheader_url(self): From a182e1fb94e655c8497239dd52114cfd59bdb7b0 Mon Sep 17 00:00:00 2001 From: Jun Aishima Date: Wed, 19 Mar 2025 17:16:54 -0400 Subject: [PATCH 02/10] fix missing slash --- analysisstore/client/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analysisstore/client/commands.py b/analysisstore/client/commands.py index 186845b..acbf078 100644 --- a/analysisstore/client/commands.py +++ b/analysisstore/client/commands.py @@ -31,7 +31,7 @@ def _host_url(self): if not self.use_ssl: url = 'http://{}:{}/'.format(self.host, self.port) else: - url = f'https://{self.host}' + url = f'https://{self.host}/' return url @property From 5d0d6603ca0673fdb0a9bab0b840f4f23b4382fa Mon Sep 17 00:00:00 2001 From: Jun Aishima Date: Thu, 20 Mar 2025 08:43:03 -0400 Subject: [PATCH 03/10] allow setting one of port and use_ssl config parameters * also add to tests --- analysisstore/client/commands.py | 12 ++++++++---- analysisstore/test/test_conn_pool.py | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/analysisstore/client/commands.py b/analysisstore/client/commands.py index acbf078..ee54470 100644 --- a/analysisstore/client/commands.py +++ b/analysisstore/client/commands.py @@ -13,8 +13,12 @@ class AnalysisClient: """Client used to pass messages between analysisstore server and apps""" def __init__(self, config): self.host = config['host'] - self.port = config['port'] - self.use_ssl = config['use_ssl'] + self.port = config.get('port') + self.use_ssl = config.get('use_ssl') + if self.port is None and self.use_ssl is None: + raise KeyError("one of port or use_ssl must be defined") + if self.port and self.use_ssl: + raise KeyError("only one of port or use_ssl must be defined") self._insert_dict = {'analysis_header': self.insert_analysis_header, 'analysis_tail': self.insert_analysis_tail, 'data_reference_header': self.insert_data_reference_header, @@ -28,9 +32,9 @@ def __init__(self, config): @property def _host_url(self): """URL to the tornado instance""" - if not self.use_ssl: + if not self.use_ssl: # if not using ssl, connect to specified port url = 'http://{}:{}/'.format(self.host, self.port) - else: + else: # if using ssl, just use https protocol url = f'https://{self.host}/' return url diff --git a/analysisstore/test/test_conn_pool.py b/analysisstore/test/test_conn_pool.py index 7d18207..813631f 100644 --- a/analysisstore/test/test_conn_pool.py +++ b/analysisstore/test/test_conn_pool.py @@ -10,3 +10,5 @@ def test_client_badconf(): conn = AnalysisClient(config) conn.host == testing_config["host"] conn.port == testing_config["port"] + config["use_ssl"] = True + pytest.raises(KeyError, AnalysisClient, config) From bff3c48286e39e31e9edfa351a346ed3f404ab14 Mon Sep 17 00:00:00 2001 From: Jun Aishima Date: Tue, 25 Mar 2025 09:59:59 -0400 Subject: [PATCH 04/10] simplify logic of use_ssl and service_port flags for client * enable both to be set, but only one will be used --- analysisstore/client/commands.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/analysisstore/client/commands.py b/analysisstore/client/commands.py index ee54470..b11c614 100644 --- a/analysisstore/client/commands.py +++ b/analysisstore/client/commands.py @@ -15,9 +15,9 @@ def __init__(self, config): self.host = config['host'] self.port = config.get('port') self.use_ssl = config.get('use_ssl') - if self.port is None and self.use_ssl is None: + if self.port is None and self.use_ssl in (None, False): raise KeyError("one of port or use_ssl must be defined") - if self.port and self.use_ssl: + if self.port is not None and self.use_ssl is not None: raise KeyError("only one of port or use_ssl must be defined") self._insert_dict = {'analysis_header': self.insert_analysis_header, 'analysis_tail': self.insert_analysis_tail, From 6ef46f32fa07b87742c5ab88f22f3d1bad72ad66 Mon Sep 17 00:00:00 2001 From: Jun Aishima Date: Tue, 25 Mar 2025 10:03:31 -0400 Subject: [PATCH 05/10] add default use_ssl flag --- analysisstore/client/commands.py | 4 +--- analysisstore/client/conf.py | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/analysisstore/client/commands.py b/analysisstore/client/commands.py index b11c614..edfe943 100644 --- a/analysisstore/client/commands.py +++ b/analysisstore/client/commands.py @@ -16,9 +16,7 @@ def __init__(self, config): self.port = config.get('port') self.use_ssl = config.get('use_ssl') if self.port is None and self.use_ssl in (None, False): - raise KeyError("one of port or use_ssl must be defined") - if self.port is not None and self.use_ssl is not None: - raise KeyError("only one of port or use_ssl must be defined") + raise KeyError("at least one of port or use_ssl must be defined") self._insert_dict = {'analysis_header': self.insert_analysis_header, 'analysis_tail': self.insert_analysis_tail, 'data_reference_header': self.insert_data_reference_header, diff --git a/analysisstore/client/conf.py b/analysisstore/client/conf.py index c655fc4..caacddd 100644 --- a/analysisstore/client/conf.py +++ b/analysisstore/client/conf.py @@ -1,5 +1,6 @@ host = 'localhost' port = 8999 +use_ssl = False -top_dir = '~/analysisstore' \ No newline at end of file +top_dir = '~/analysisstore' From 52459286aee76eb5ff670e11f5a458293aa74b95 Mon Sep 17 00:00:00 2001 From: Jun Aishima Date: Tue, 25 Mar 2025 10:04:14 -0400 Subject: [PATCH 06/10] test configurations with use_ssl flag --- analysisstore/test/conftest.py | 9 +++++++++ analysisstore/test/test_conn_pool.py | 7 ++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/analysisstore/test/conftest.py b/analysisstore/test/conftest.py index 655b565..ade8779 100644 --- a/analysisstore/test/conftest.py +++ b/analysisstore/test/conftest.py @@ -18,6 +18,7 @@ mongo_host="localhost", mongo_port=27017, testing=True, + use_ssl=True, log_file_prefix="testing", ) @@ -47,3 +48,11 @@ def astore_client(): {"host": testing_config["mongo_host"], "port": testing_config["service_port"]} ) return c + +@pytest.fixture(scope="function") +def astore_client_ssl(): + c = AnalysisClient( + {"host": testing_config["mongo_host"], "use_ssl": testing_config["use_ssl"], + "port": testing_config["port"]} + ) + return c diff --git a/analysisstore/test/test_conn_pool.py b/analysisstore/test/test_conn_pool.py index 813631f..74bfffe 100644 --- a/analysisstore/test/test_conn_pool.py +++ b/analysisstore/test/test_conn_pool.py @@ -7,8 +7,5 @@ def test_client_badconf(): config = {"host": "localhost"} pytest.raises(KeyError, AnalysisClient, config) config["port"] = testing_config["port"] - conn = AnalysisClient(config) - conn.host == testing_config["host"] - conn.port == testing_config["port"] - config["use_ssl"] = True - pytest.raises(KeyError, AnalysisClient, config) + config["use_ssl"] = testing_config["use_ssl"] + client = AnalysisClient(config) From fdff5b6c35a4dbf431da8cec6c8ecffa75afd847 Mon Sep 17 00:00:00 2001 From: Jun Aishima Date: Tue, 25 Mar 2025 10:20:18 -0400 Subject: [PATCH 07/10] add test for using SSL flag --- analysisstore/test/test_client.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/analysisstore/test/test_client.py b/analysisstore/test/test_client.py index e4cf615..678fea5 100644 --- a/analysisstore/test/test_client.py +++ b/analysisstore/test/test_client.py @@ -26,6 +26,15 @@ def test_urls(astore_client): astore_client.dref_header_url == base_test_url + "data_reference_header" +def test_ssl(astore_client_ssl): + base_test_url = f"https://{testing_config['host']}/" + astore_client_ssl._host_url == base_test_url + astore_client_ssl.aheader_url == base_test_url + "analysis_header" + astore_client_ssl.atail_url == base_test_url + "analysis_tail" + astore_client_ssl.dref_url == base_test_url + "data_reference" + astore_client_ssl.dref_header_url == base_test_url + "data_reference_header" + + def test_doc_or_uid_to_uid(astore_server, astore_client): m_uid = str(uuid.uuid4()) test_dict = {"name": "test_doc", "uid": m_uid} From 28f9f946e1291a746a89b0ee100abde65d1f4bcd Mon Sep 17 00:00:00 2001 From: Shekar V Date: Fri, 4 Sep 2026 12:19:55 -0400 Subject: [PATCH 08/10] Apply batched suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- analysisstore/client/commands.py | 4 ++-- analysisstore/test/conftest.py | 7 +++++-- analysisstore/test/test_client.py | 12 ++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/analysisstore/client/commands.py b/analysisstore/client/commands.py index edfe943..1ca34bb 100644 --- a/analysisstore/client/commands.py +++ b/analysisstore/client/commands.py @@ -14,8 +14,8 @@ class AnalysisClient: def __init__(self, config): self.host = config['host'] self.port = config.get('port') - self.use_ssl = config.get('use_ssl') - if self.port is None and self.use_ssl in (None, False): + self.use_ssl = config.get('use_ssl', False) + if self.port is None and not self.use_ssl: raise KeyError("at least one of port or use_ssl must be defined") self._insert_dict = {'analysis_header': self.insert_analysis_header, 'analysis_tail': self.insert_analysis_tail, diff --git a/analysisstore/test/conftest.py b/analysisstore/test/conftest.py index ade8779..23e113f 100644 --- a/analysisstore/test/conftest.py +++ b/analysisstore/test/conftest.py @@ -52,7 +52,10 @@ def astore_client(): @pytest.fixture(scope="function") def astore_client_ssl(): c = AnalysisClient( - {"host": testing_config["mongo_host"], "use_ssl": testing_config["use_ssl"], - "port": testing_config["port"]} + { + "host": testing_config["host"], + "use_ssl": testing_config["use_ssl"], + "port": testing_config["port"], + } ) return c diff --git a/analysisstore/test/test_client.py b/analysisstore/test/test_client.py index 678fea5..492b3fc 100644 --- a/analysisstore/test/test_client.py +++ b/analysisstore/test/test_client.py @@ -27,12 +27,12 @@ def test_urls(astore_client): def test_ssl(astore_client_ssl): - base_test_url = f"https://{testing_config['host']}/" - astore_client_ssl._host_url == base_test_url - astore_client_ssl.aheader_url == base_test_url + "analysis_header" - astore_client_ssl.atail_url == base_test_url + "analysis_tail" - astore_client_ssl.dref_url == base_test_url + "data_reference" - astore_client_ssl.dref_header_url == base_test_url + "data_reference_header" + base_test_url = f"https://{astore_client_ssl.host}/" + assert astore_client_ssl._host_url == base_test_url + assert astore_client_ssl.aheader_url == base_test_url + "analysis_header" + assert astore_client_ssl.atail_url == base_test_url + "analysis_tail" + assert astore_client_ssl.dref_url == base_test_url + "data_reference" + assert astore_client_ssl.dref_header_url == base_test_url + "data_reference_header" def test_doc_or_uid_to_uid(astore_server, astore_client): From a785259db972ea3a721a1bcc2b8e700ec1edb2a6 Mon Sep 17 00:00:00 2001 From: Shekar V Date: Fri, 4 Sep 2026 12:34:04 -0400 Subject: [PATCH 09/10] Add setuptools dependency with version constraint To allow newer versions of python tests to pass --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 45dbdec..25f5773 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ pyyaml requests tornado ujson +setuptools<81 From 7542555d2ef1f5e8f81bcba3c6483196ac29facf Mon Sep 17 00:00:00 2001 From: Shekar V Date: Fri, 4 Sep 2026 12:39:57 -0400 Subject: [PATCH 10/10] Modify conda install to limit setuptools version Updated conda install command to restrict setuptools version. This is to allow conda tests to pass on newer python versions --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 9cab370..8008bb9 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -53,7 +53,7 @@ jobs: if: matrix.dependencies == 'conda' run: | set -vxeo pipefail - conda install -y -c conda-forge six mongoquery doct jsonschema mock pymongo pytest pyyaml requests tornado ujson + conda install -y -c conda-forge six mongoquery doct jsonschema mock pymongo pytest pyyaml requests tornado ujson 'setuptools<81' pip install mongomock - name: Install the package