mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 19:31:51 +02:00
Cleanup test_obtain_certificate_from_csr
This commit is contained in:
@@ -134,31 +134,13 @@ class ClientTest(unittest.TestCase):
|
|||||||
|
|
||||||
self.acme.fetch_chain.assert_called_once_with(mock.sentinel.certr)
|
self.acme.fetch_chain.assert_called_once_with(mock.sentinel.certr)
|
||||||
|
|
||||||
# FIXME move parts of this to crypto_util tests...
|
|
||||||
@mock.patch("certbot.client.logger")
|
@mock.patch("certbot.client.logger")
|
||||||
def test_obtain_certificate_from_csr(self, mock_logger):
|
def test_obtain_certificate_from_csr(self, mock_logger):
|
||||||
self._mock_obtain_certificate()
|
self._mock_obtain_certificate()
|
||||||
from certbot import cli
|
|
||||||
test_csr = le_util.CSR(form="der", file=None, data=CSR_SAN)
|
test_csr = le_util.CSR(form="der", file=None, data=CSR_SAN)
|
||||||
mock_parsed_args = mock.MagicMock()
|
auth_handler = self.client.auth_handler
|
||||||
# The CLI should believe that this is a certonly request, because
|
|
||||||
# a CSR would not be allowed with other kinds of requests!
|
|
||||||
mock_parsed_args.verb = "certonly"
|
|
||||||
with mock.patch("certbot.cli.crypto_util.le_util.CSR") as mock_CSR:
|
|
||||||
mock_CSR.return_value = test_csr
|
|
||||||
mock_parsed_args.domains = self.eg_domains[:]
|
|
||||||
mock_parsed_args.allow_subset_of_names = False
|
|
||||||
mock_parsed_args.csr = (mock.MagicMock(), mock.MagicMock())
|
|
||||||
mock_parser = mock.MagicMock(cli.HelpfulArgumentParser)
|
|
||||||
cli.HelpfulArgumentParser.handle_csr(mock_parser, mock_parsed_args)
|
|
||||||
|
|
||||||
# Now provoke an inconsistent domains error...
|
|
||||||
mock_parsed_args.domains.append("hippopotamus.io")
|
|
||||||
self.assertRaises(errors.ConfigurationError,
|
|
||||||
cli.HelpfulArgumentParser.handle_csr, mock_parser, mock_parsed_args)
|
|
||||||
|
|
||||||
authzr = self.client.auth_handler.get_authorizations(self.eg_domains, False)
|
|
||||||
|
|
||||||
|
authzr = auth_handler.get_authorizations(self.eg_domains, False)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
(mock.sentinel.certr, mock.sentinel.chain),
|
(mock.sentinel.certr, mock.sentinel.chain),
|
||||||
self.client.obtain_certificate_from_csr(
|
self.client.obtain_certificate_from_csr(
|
||||||
@@ -175,9 +157,7 @@ class ClientTest(unittest.TestCase):
|
|||||||
self.eg_domains,
|
self.eg_domains,
|
||||||
test_csr,
|
test_csr,
|
||||||
authzr=None))
|
authzr=None))
|
||||||
|
auth_handler.get_authorizations.assert_called_with(self.eg_domains)
|
||||||
self.client.auth_handler.get_authorizations.assert_called_with(
|
|
||||||
self.eg_domains)
|
|
||||||
|
|
||||||
# Test for no auth_handler
|
# Test for no auth_handler
|
||||||
self.client.auth_handler = None
|
self.client.auth_handler = None
|
||||||
|
|||||||
Reference in New Issue
Block a user