Maintenance will be performed on git.ligo.org, chat.ligo.org, containers.ligo.org, and docs.ligo.org on Tuesday 26 May 2020 starting at approximately 10am CDT. It is expected to take around 30 minutes and will involve a short period of downtime, around 5 minutes, towards the end of the maintenance period. Please address any questions, comments, or concerns to uwm-help@cgca.uwm.edu.

Commit f5e79527 authored by Tanner Prestegard's avatar Tanner Prestegard

Fix other unit tests which were broken by certificate reloading changes

parent 27ada653
......@@ -13,7 +13,9 @@ def test_provide_x509_cert_and_key():
cert_file = '/tmp/cert_file'
key_file = '/tmp/key_file'
with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'):
load_cert_func = 'ligo.gracedb.rest.GraceDb._load_certificate'
with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'), \
mock.patch(load_cert_func):
# Initialize client
g = GraceDb(cred=(cert_file, key_file))
......@@ -29,7 +31,9 @@ def test_provide_x509_proxy():
# Set up combined proxy file
proxy_file = '/tmp/proxy_file'
with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'):
load_cert_func = 'ligo.gracedb.rest.GraceDb._load_certificate'
with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'), \
mock.patch(load_cert_func):
# Initialize client
g = GraceDb(cred=proxy_file)
......@@ -76,7 +80,9 @@ def test_provide_all_creds():
password = 'pw'
# Initialize client
with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'):
load_cert_func = 'ligo.gracedb.rest.GraceDb._load_certificate'
with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'), \
mock.patch(load_cert_func):
g = GraceDb(cred=(cert_file, key_file), username=username,
password=password)
......@@ -94,7 +100,9 @@ def test_x509_credentials_lookup():
key_file = '/tmp/key_file'
# Initialize client
load_cert_func = 'ligo.gracedb.rest.GraceDb._load_certificate'
with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'), \
mock.patch(load_cert_func), \
mock.patch('ligo.gracedb.rest.GraceDb._find_x509_credentials') \
as mock_find_x509:
mock_find_x509.return_value = (cert_file, key_file)
......@@ -114,7 +122,9 @@ def test_x509_lookup_cert_key_from_envvars():
key_file = '/tmp/key_file'
# Initialize client
load_cert_func = 'ligo.gracedb.rest.GraceDb._load_certificate'
with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'), \
mock.patch(load_cert_func), \
mock.patch.dict('ligo.gracedb.rest.os.environ',
{'X509_USER_CERT': cert_file, 'X509_USER_KEY': key_file}):
g = GraceDb()
......@@ -132,7 +142,9 @@ def test_x509_lookup_proxy_from_envvars():
proxy_file = '/tmp/proxy_file'
# Initialize client
load_cert_func = 'ligo.gracedb.rest.GraceDb._load_certificate'
with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'), \
mock.patch(load_cert_func), \
mock.patch.dict('ligo.gracedb.rest.os.environ', {'X509_USER_PROXY': proxy_file}):
g = GraceDb()
......@@ -221,7 +233,9 @@ def test_fail_if_noauth(creds_found):
key_file = '/tmp/key_file'
# Initialize client
load_cert_func = 'ligo.gracedb.rest.GraceDb._load_certificate'
with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'), \
mock.patch(load_cert_func), \
mock.patch('ligo.gracedb.rest.GraceDb._find_x509_credentials') as mock_find_x509, \
mock.patch('ligo.gracedb.rest.safe_netrc') as mock_netrc:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment