diff --git a/letsencrypt/cli.py b/letsencrypt/cli.py index 6f4facc3e..957ada7af 100644 --- a/letsencrypt/cli.py +++ b/letsencrypt/cli.py @@ -169,7 +169,7 @@ def _determine_account(args, config): def _init_le_client(args, config, authenticator, installer): - config.deterimine_user_agent(authenticator, installer) + config.determine_user_agent(authenticator, installer) if authenticator is not None: # if authenticator was given, then we will need account... acc, acme = _determine_account(args, config) diff --git a/letsencrypt/configuration.py b/letsencrypt/configuration.py index a3fd33d69..345cf75b4 100644 --- a/letsencrypt/configuration.py +++ b/letsencrypt/configuration.py @@ -11,6 +11,7 @@ from acme import challenges from letsencrypt import constants from letsencrypt import errors from letsencrypt import interfaces +from letsencrypt import le_util class NamespaceConfig(object): @@ -84,17 +85,19 @@ class NamespaceConfig(object): return challenges.HTTP01Response.PORT def determine_user_agent(self, authenticator, installer): - # The user agent string isn't knowable until the authenticator and - # installer have been chosen. + """ + Set a user_agent string in the config based on the choice of plugins. + (this wasn't knowable at construction time) + """ - if self.user_agent is None: + if self.namespace.user_agent is None: ua = "LetsEncryptPythonClient/{0} ({1}) Authenticator/{2} Installer/{3}" ua = ua.format(letsencrypt.__version__, le_util.get_os_info(), authenticator.name if authenticator else "none", installer.name if installer else "none") - self.user_agent=ua + self.namespace.user_agent = ua else: - assert isinstance(self.user_agent, str), "User Agent not a string?" + assert isinstance(self.namespace.user_agent, str), "User Agent not a string?" class RenewerConfiguration(object): diff --git a/letsencrypt/le_util.py b/letsencrypt/le_util.py index 4a780e36b..112c90a6e 100644 --- a/letsencrypt/le_util.py +++ b/letsencrypt/le_util.py @@ -224,8 +224,8 @@ def get_os_info(): ).communicate()[0] elif os_type.startswith('freebsd'): # eg "9.3-RC3-p1" - os_ver = os_ver.parititon("-")[0] - os_ver = os_ver.parititon(".")[0] + os_ver = os_ver.partition("-")[0] + os_ver = os_ver.partition(".")[0] elif platform.win32_ver()[1]: os_ver = platform.win32_ver()[1] else: diff --git a/letsencrypt/tests/client_test.py b/letsencrypt/tests/client_test.py index 4a61194f3..3caea4f05 100644 --- a/letsencrypt/tests/client_test.py +++ b/letsencrypt/tests/client_test.py @@ -71,7 +71,7 @@ class ClientTest(unittest.TestCase): def test_init_acme_verify_ssl(self): self.acme_client.assert_called_once_with( - directory=mock.ANY, key=mock.ANY, verify_ssl=True) + directory=mock.ANY, key=mock.ANY, ua=mock.ANY, verify_ssl=True) def _mock_obtain_certificate(self): self.client.auth_handler = mock.MagicMock()