Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions analysisstore/client/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ 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.port = config.get('port')
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,
'data_reference_header': self.insert_data_reference_header,
Expand All @@ -27,7 +30,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: # if not using ssl, connect to specified port
url = 'http://{}:{}/'.format(self.host, self.port)
else: # if using ssl, just use https protocol
url = f'https://{self.host}/'
return url
Comment thread
vshekar marked this conversation as resolved.

@property
def aheader_url(self):
Expand Down
3 changes: 2 additions & 1 deletion analysisstore/client/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

host = 'localhost'
port = 8999
use_ssl = False

top_dir = '~/analysisstore'
top_dir = '~/analysisstore'
12 changes: 12 additions & 0 deletions analysisstore/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
mongo_host="localhost",
mongo_port=27017,
testing=True,
use_ssl=True,
log_file_prefix="testing",
)

Expand Down Expand Up @@ -47,3 +48,14 @@ 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["host"],
"use_ssl": testing_config["use_ssl"],
"port": testing_config["port"],
}
)
return c
9 changes: 9 additions & 0 deletions analysisstore/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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://{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):
m_uid = str(uuid.uuid4())
test_dict = {"name": "test_doc", "uid": m_uid}
Expand Down
5 changes: 2 additions & 3 deletions analysisstore/test/test_conn_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +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"] = testing_config["use_ssl"]
client = AnalysisClient(config)
Comment thread
vshekar marked this conversation as resolved.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ pyyaml
requests
tornado
ujson
setuptools<81
Loading