Fix other unit tests which were broken by certificate reloading changes

parent 27ada653
...@@ -13,7 +13,9 @@ def test_provide_x509_cert_and_key(): ...@@ -13,7 +13,9 @@ def test_provide_x509_cert_and_key():
cert_file = '/tmp/cert_file' cert_file = '/tmp/cert_file'
key_file = '/tmp/key_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 # Initialize client
g = GraceDb(cred=(cert_file, key_file)) g = GraceDb(cred=(cert_file, key_file))
...@@ -29,7 +31,9 @@ def test_provide_x509_proxy(): ...@@ -29,7 +31,9 @@ def test_provide_x509_proxy():
# Set up combined proxy file # Set up combined proxy file
proxy_file = '/tmp/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 # Initialize client
g = GraceDb(cred=proxy_file) g = GraceDb(cred=proxy_file)
...@@ -76,7 +80,9 @@ def test_provide_all_creds(): ...@@ -76,7 +80,9 @@ def test_provide_all_creds():
password = 'pw' password = 'pw'
# Initialize client # 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, g = GraceDb(cred=(cert_file, key_file), username=username,
password=password) password=password)
...@@ -94,7 +100,9 @@ def test_x509_credentials_lookup(): ...@@ -94,7 +100,9 @@ def test_x509_credentials_lookup():
key_file = '/tmp/key_file' key_file = '/tmp/key_file'
# Initialize client # Initialize client
load_cert_func = 'ligo.gracedb.rest.GraceDb._load_certificate'
with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'), \ with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'), \
mock.patch(load_cert_func), \
mock.patch('ligo.gracedb.rest.GraceDb._find_x509_credentials') \ mock.patch('ligo.gracedb.rest.GraceDb._find_x509_credentials') \
as mock_find_x509: as mock_find_x509:
mock_find_x509.return_value = (cert_file, key_file) mock_find_x509.return_value = (cert_file, key_file)
...@@ -114,7 +122,9 @@ def test_x509_lookup_cert_key_from_envvars(): ...@@ -114,7 +122,9 @@ def test_x509_lookup_cert_key_from_envvars():
key_file = '/tmp/key_file' key_file = '/tmp/key_file'
# Initialize client # Initialize client
load_cert_func = 'ligo.gracedb.rest.GraceDb._load_certificate'
with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'), \ with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'), \
mock.patch(load_cert_func), \
mock.patch.dict('ligo.gracedb.rest.os.environ', mock.patch.dict('ligo.gracedb.rest.os.environ',
{'X509_USER_CERT': cert_file, 'X509_USER_KEY': key_file}): {'X509_USER_CERT': cert_file, 'X509_USER_KEY': key_file}):
g = GraceDb() g = GraceDb()
...@@ -132,7 +142,9 @@ def test_x509_lookup_proxy_from_envvars(): ...@@ -132,7 +142,9 @@ def test_x509_lookup_proxy_from_envvars():
proxy_file = '/tmp/proxy_file' proxy_file = '/tmp/proxy_file'
# Initialize client # Initialize client
load_cert_func = 'ligo.gracedb.rest.GraceDb._load_certificate'
with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'), \ 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}): mock.patch.dict('ligo.gracedb.rest.os.environ', {'X509_USER_PROXY': proxy_file}):
g = GraceDb() g = GraceDb()
...@@ -221,7 +233,9 @@ def test_fail_if_noauth(creds_found): ...@@ -221,7 +233,9 @@ def test_fail_if_noauth(creds_found):
key_file = '/tmp/key_file' key_file = '/tmp/key_file'
# Initialize client # Initialize client
load_cert_func = 'ligo.gracedb.rest.GraceDb._load_certificate'
with mock.patch('ligo.gracedb.rest.GraceDb.set_up_connector'), \ 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.GraceDb._find_x509_credentials') as mock_find_x509, \
mock.patch('ligo.gracedb.rest.safe_netrc') as mock_netrc: 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