1
0
mirror of https://github.com/certbot/certbot.git synced 2026-01-21 19:01:07 +03:00

Tests for the 'revoke' verb

This commit is contained in:
Brad Warren
2015-11-13 10:06:49 -08:00
committed by Peter Eckersley
parent e8cf095ef3
commit eea9aa752a

View File

@@ -406,6 +406,29 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
self.assertTrue(
date in mock_get_utility().add_message.call_args[0][0])
@mock.patch('letsencrypt.cli.acme_client')
def test_revoke_with_key(self, mock_acme_client):
server = 'foo.bar'
self._call(['--cert-path', CERT, '--key-path', KEY,
'--server', server, 'revoke'])
with open(KEY) as f:
mock_acme_client.Client.assert_called_once_with(
server, key=jose.JWK.load(f.read()))
with open(CERT) as f:
mock_acme_client.Client().revoke.assert_called_once_with(
jose.ComparableX509(crypto_util.pyopenssl_load_certificate(
f.read())[0]))
@mock.patch('letsencrypt.cli._determine_account')
def test_revoke_without_key(self, mock_determine_account):
mock_determine_account.return_value = (mock.MagicMock(), None)
_, _, _, client = self._call(['--cert-path', CERT, 'revoke'])
with open(CERT) as f:
# pylint: disable=protected-access
client._acme_from_config_key().revoke.assert_called_once_with(
jose.ComparableX509(crypto_util.pyopenssl_load_certificate(
f.read())[0]))
@mock.patch('letsencrypt.cli.sys')
def test_handle_exception(self, mock_sys):
# pylint: disable=protected-access