Remove check for bay state on ca-sign and ca-show
The ca-sign and ca-show are usable in all bay states. Fixes Bug: 1533714 Change-Id: I08d83236372de8e82bb09d4fccf211df2f3e70cf
This commit is contained in:
parent
e9452a6e7c
commit
6449f7f327
@ -30,16 +30,6 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
|
||||
'--bay xxx')
|
||||
self.assertTrue(mock_cert_get.called)
|
||||
|
||||
@mock.patch('magnumclient.v1.bays.BayManager.get')
|
||||
@mock.patch('magnumclient.v1.certificates.CertificateManager.get')
|
||||
def test_ca_show_with_wrong_status(self, mock_cert_get, mock_bay_get):
|
||||
mockbay = mock.MagicMock()
|
||||
mockbay.status = "FAILED"
|
||||
mock_bay_get.return_value = mockbay
|
||||
self._test_arg_success('ca-show '
|
||||
'--bay xxx')
|
||||
self.assertFalse(mock_cert_get.called)
|
||||
|
||||
@mock.patch('os.path.isfile')
|
||||
@mock.patch('magnumclient.v1.bays.BayManager.get')
|
||||
@mock.patch('magnumclient.v1.certificates.CertificateManager.create')
|
||||
@ -58,26 +48,6 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
|
||||
'--bay xxx')
|
||||
self.assertTrue(mock_cert_create.called)
|
||||
|
||||
@mock.patch('os.path.isfile')
|
||||
@mock.patch('magnumclient.v1.bays.BayManager.get')
|
||||
@mock.patch('magnumclient.v1.certificates.CertificateManager.create')
|
||||
def test_ca_sign_with_wrong_status(
|
||||
self, mock_cert_create, mock_bay_get, mock_isfile):
|
||||
mock_isfile.return_value = True
|
||||
mockbay = mock.MagicMock()
|
||||
mockbay.status = "FAILED"
|
||||
mock_bay_get.return_value = mockbay
|
||||
|
||||
fake_csr = 'fake-csr'
|
||||
file_mock = mock.mock_open(read_data=fake_csr)
|
||||
with mock.patch.object(certificates_shell, 'open', file_mock):
|
||||
self._test_arg_success('ca-sign '
|
||||
'--csr path/csr.pem '
|
||||
'--bay xxx')
|
||||
self.assertFalse(mock_isfile.called)
|
||||
self.assertFalse(file_mock.called)
|
||||
self.assertFalse(mock_cert_create.called)
|
||||
|
||||
@mock.patch('os.path.isfile')
|
||||
@mock.patch('magnumclient.v1.bays.BayManager.get')
|
||||
@mock.patch('magnumclient.v1.certificates.CertificateManager.create')
|
||||
|
@ -28,12 +28,6 @@ def _show_cert(certificate):
|
||||
def do_ca_show(cs, args):
|
||||
"""Show details about the CA certificate for a bay."""
|
||||
bay = cs.bays.get(args.bay)
|
||||
if bay.status not in ['CREATE_COMPLETE', 'UPDATE_COMPLETE']:
|
||||
print('Bay status for %s is: %s. We can not create a %s there'
|
||||
' until the status is CREATE_COMPLETE or UPDATE_COMPLETE.' %
|
||||
(bay.uuid, bay.status, 'certificate'))
|
||||
return
|
||||
|
||||
opts = {
|
||||
'bay_uuid': bay.uuid
|
||||
}
|
||||
@ -52,12 +46,6 @@ def do_ca_show(cs, args):
|
||||
def do_ca_sign(cs, args):
|
||||
"""Generate the CA certificate for a bay."""
|
||||
bay = cs.bays.get(args.bay)
|
||||
if bay.status not in ['CREATE_COMPLETE', 'UPDATE_COMPLETE']:
|
||||
print('Bay status for %s is: %s. We can not create a %s there'
|
||||
' until the status is CREATE_COMPLETE or UPDATE_COMPLETE.' %
|
||||
(bay.uuid, bay.status, 'certificate'))
|
||||
return
|
||||
|
||||
opts = {
|
||||
'bay_uuid': bay.uuid
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user