diff options
author | Brad Warren <bmw@users.noreply.github.com> | 2018-03-17 04:44:23 +0300 |
---|---|---|
committer | ohemorange <ebportnoy@gmail.com> | 2018-03-17 04:44:23 +0300 |
commit | 0131c649d057a513a6bdc0b4b6eac7ea0bd9a9e8 (patch) | |
tree | 91b4a7b6f75cd28fb72f9dbe0ab88680c98533e5 | |
parent | eda458b2dab2153eb56f6843c7a345d09a0a1f36 (diff) |
Fix acme.client.Client.__init__ (#5747) (#5748)
* fixes #5738
* add test to prevent regressions
(cherry picked from commit ba6bdb50998bd55aeef7972a5c839560e02142f3)
-rw-r--r-- | acme/acme/client.py | 5 | ||||
-rw-r--r-- | acme/acme/client_test.py | 10 |
2 files changed, 13 insertions, 2 deletions
diff --git a/acme/acme/client.py b/acme/acme/client.py index 9e2478afe..19615b087 100644 --- a/acme/acme/client.py +++ b/acme/acme/client.py @@ -259,11 +259,12 @@ class Client(ClientBase): """ # pylint: disable=too-many-arguments self.key = key - self.net = ClientNetwork(key, alg=alg, verify_ssl=verify_ssl) if net is None else net + if net is None: + net = ClientNetwork(key, alg=alg, verify_ssl=verify_ssl) if isinstance(directory, six.string_types): directory = messages.Directory.from_json( - self.net.get(directory).json()) + net.get(directory).json()) super(Client, self).__init__(directory=directory, net=net, acme_version=1) diff --git a/acme/acme/client_test.py b/acme/acme/client_test.py index 00b9e19dd..be08c2919 100644 --- a/acme/acme/client_test.py +++ b/acme/acme/client_test.py @@ -299,6 +299,16 @@ class ClientTest(ClientTestBase): directory=uri, key=KEY, alg=jose.RS256, net=self.net) self.net.get.assert_called_once_with(uri) + @mock.patch('acme.client.ClientNetwork') + def test_init_without_net(self, mock_net): + mock_net.return_value = mock.sentinel.net + alg = jose.RS256 + from acme.client import Client + self.client = Client( + directory=self.directory, key=KEY, alg=alg) + mock_net.called_once_with(KEY, alg=alg, verify_ssl=True) + self.assertEqual(self.client.net, mock.sentinel.net) + def test_register(self): # "Instance of 'Field' has no to_json/update member" bug: # pylint: disable=no-member |