Commit f5e79527 authored by Tanner Prestegard's avatar Tanner Prestegard

Fix other unit tests which were broken by certificate reloading changes

parent 27ada653
......@@ -12,8 +12,10 @@ def test_provide_x509_cert_and_key():
# Set up cert and key files
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))
......@@ -28,8 +30,10 @@ def test_provide_x509_proxy():
"""Test client instantiation with provided combined proxy file"""
# 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