mirror of
https://github.com/certbot/certbot.git
synced 2026-06-07 07:42:08 -04:00
commit
e166c4159e
3 changed files with 29 additions and 32 deletions
|
|
@ -156,14 +156,6 @@ class GetAuthorizationsTest(unittest.TestCase):
|
|||
self.assertRaises(errors.AuthorizationError,
|
||||
self.handler.get_authorizations, ["0"])
|
||||
|
||||
def _get_exp_response(self, domain, path, challs):
|
||||
# pylint: disable=no-self-use
|
||||
exp_resp = [None] * len(challs)
|
||||
for i in path:
|
||||
exp_resp[i] = TRANSLATE[challs[i].typ] + str(domain)
|
||||
|
||||
return exp_resp
|
||||
|
||||
def _validate_all(self, unused_1, unused_2):
|
||||
for dom in self.handler.authzr.keys():
|
||||
azr = self.handler.authzr[dom]
|
||||
|
|
@ -443,19 +435,5 @@ def gen_dom_authzr(domain, unused_new_authzr_uri, challs):
|
|||
[messages2.STATUS_PENDING]*len(challs))
|
||||
|
||||
|
||||
def gen_path(required, challs):
|
||||
"""Generate a combination by picking ``required`` from ``challs``.
|
||||
|
||||
:param required: Required types of challenges (subclasses of
|
||||
:class:`~acme.challenges.Challenge`).
|
||||
:param challs: Sequence of ACME challenge messages, corresponding to
|
||||
:attr:`acme.messages.Challenge.challenges`.
|
||||
|
||||
:return: :class:`list` of :class:`int`
|
||||
|
||||
"""
|
||||
return [challs.index(chall) for chall in required]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main() # pragma: no cover
|
||||
|
|
|
|||
|
|
@ -12,10 +12,11 @@ class CLITest(unittest.TestCase):
|
|||
def _call(cls, args):
|
||||
from letsencrypt import cli
|
||||
args = ['--text'] + args
|
||||
with mock.patch("letsencrypt.cli.sys.stdout") as stdout:
|
||||
with mock.patch("letsencrypt.cli.sys.stderr") as stderr:
|
||||
ret = cli.main(args)
|
||||
return ret, stdout, stderr
|
||||
with mock.patch('letsencrypt.cli.sys.stdout') as stdout:
|
||||
with mock.patch('letsencrypt.cli.sys.stderr') as stderr:
|
||||
with mock.patch('letsencrypt.cli.client') as client:
|
||||
ret = cli.main(args)
|
||||
return ret, stdout, stderr, client
|
||||
|
||||
def test_no_flags(self):
|
||||
self.assertRaises(SystemExit, self._call, [])
|
||||
|
|
@ -23,6 +24,18 @@ class CLITest(unittest.TestCase):
|
|||
def test_help(self):
|
||||
self.assertRaises(SystemExit, self._call, ['--help'])
|
||||
|
||||
def test_rollback(self):
|
||||
_, _, _, client = self._call(['rollback'])
|
||||
client.rollback.assert_called_once()
|
||||
|
||||
_, _, _, client = self._call(['rollback', '--checkpoints', '123'])
|
||||
client.rollback.assert_called_once_with(
|
||||
mock.ANY, 123, mock.ANY, mock.ANY)
|
||||
|
||||
def test_config_changes(self):
|
||||
_, _, _, client = self._call(['config_changes'])
|
||||
client.view_config_changes.assert_called_once()
|
||||
|
||||
def test_plugins(self):
|
||||
flags = ['--init', '--prepare', '--authenticators', '--installers']
|
||||
for args in itertools.chain(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import datetime
|
|||
import httplib
|
||||
import os
|
||||
import pkg_resources
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import M2Crypto
|
||||
|
|
@ -49,6 +51,8 @@ class NetworkTest(unittest.TestCase):
|
|||
self.identifier = messages2.Identifier(
|
||||
typ=messages2.IDENTIFIER_FQDN, value='example.com')
|
||||
|
||||
self.config = mock.Mock(accounts_dir=tempfile.mkdtemp())
|
||||
|
||||
# Registration
|
||||
self.contact = ('mailto:cert-admin@example.com', 'tel:+12025551212')
|
||||
reg = messages2.Registration(
|
||||
|
|
@ -79,6 +83,9 @@ class NetworkTest(unittest.TestCase):
|
|||
uri='https://www.letsencrypt-demo.org/acme/cert/1',
|
||||
cert_chain_uri='https://www.letsencrypt-demo.org/ca')
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.config.accounts_dir)
|
||||
|
||||
def _mock_post_get(self):
|
||||
# pylint: disable=protected-access
|
||||
self.net._post = mock.MagicMock(return_value=self.response)
|
||||
|
|
@ -93,7 +100,7 @@ class NetworkTest(unittest.TestCase):
|
|||
return self.value
|
||||
@classmethod
|
||||
def from_json(cls, value):
|
||||
return cls(value)
|
||||
pass # pragma: no cover
|
||||
# pylint: disable=protected-access
|
||||
jws = self.net._wrap_in_jws(MockJSONDeSerializable('foo'))
|
||||
self.assertEqual(jose.JWS.json_loads(jws).payload, '"foo"')
|
||||
|
|
@ -200,8 +207,8 @@ class NetworkTest(unittest.TestCase):
|
|||
def test_register_from_account(self):
|
||||
self.net.register = mock.Mock()
|
||||
acc = account.Account(
|
||||
mock.Mock(accounts_dir='mock_dir'), 'key',
|
||||
email='cert-admin@example.com', phone='+12025551212')
|
||||
self.config, 'key', email='cert-admin@example.com',
|
||||
phone='+12025551212')
|
||||
|
||||
self.net.register_from_account(acc)
|
||||
|
||||
|
|
@ -210,9 +217,8 @@ class NetworkTest(unittest.TestCase):
|
|||
def test_register_from_account_partial_info(self):
|
||||
self.net.register = mock.Mock()
|
||||
acc = account.Account(
|
||||
mock.Mock(accounts_dir='mock_dir'), 'key',
|
||||
email='cert-admin@example.com')
|
||||
acc2 = account.Account(mock.Mock(accounts_dir='mock_dir'), 'key')
|
||||
self.config, 'key', email='cert-admin@example.com')
|
||||
acc2 = account.Account(self.config, 'key')
|
||||
|
||||
self.net.register_from_account(acc)
|
||||
self.net.register.assert_called_with(
|
||||
|
|
|
|||
Loading…
Reference in a new issue