Merge "Fix broken cert revocation"
This commit is contained in:
commit
96b39341d5
|
@ -276,7 +276,9 @@ def ssh_encrypt_text(ssh_public_key, text):
|
|||
def revoke_cert(project_id, file_name):
|
||||
"""Revoke a cert by file name."""
|
||||
start = os.getcwd()
|
||||
if not os.chdir(ca_folder(project_id)):
|
||||
try:
|
||||
os.chdir(ca_folder(project_id))
|
||||
except OSError:
|
||||
raise exception.ProjectNotFound(project_id=project_id)
|
||||
try:
|
||||
# NOTE(vish): potential race condition here
|
||||
|
|
|
@ -136,12 +136,12 @@ class RevokeCertsTest(test.TestCase):
|
|||
|
||||
@mock.patch.object(utils, 'execute',
|
||||
side_effect=processutils.ProcessExecutionError)
|
||||
@mock.patch.object(os, 'chdir', return_value=True)
|
||||
@mock.patch.object(os, 'chdir', return_value=None)
|
||||
def test_revoke_cert_process_execution_error(self, *args, **kargs):
|
||||
self.assertRaises(exception.RevokeCertFailure, crypto.revoke_cert,
|
||||
2, 'test_file')
|
||||
|
||||
@mock.patch.object(os, 'chdir', return_value=False)
|
||||
@mock.patch.object(os, 'chdir', mock.Mock(side_effect=OSError))
|
||||
def test_revoke_cert_project_not_found_chdir_fails(self, *args, **kargs):
|
||||
self.assertRaises(exception.ProjectNotFound, crypto.revoke_cert,
|
||||
2, 'test_file')
|
||||
|
|
Loading…
Reference in New Issue