mirror of
https://github.com/certbot/certbot.git
synced 2026-07-28 08:45:19 +02:00
Improve UA default in docs (#6120)
* Use less informative UA values in docs. * set CERTBOT_DOCS during release
This commit is contained in:
+10
-2
@@ -65,9 +65,17 @@ def determine_user_agent(config):
|
||||
if config.user_agent is None:
|
||||
ua = ("CertbotACMEClient/{0} ({1}; {2}{8}) Authenticator/{3} Installer/{4} "
|
||||
"({5}; flags: {6}) Py/{7}")
|
||||
ua = ua.format(certbot.__version__, cli.cli_command, util.get_os_info_ua(),
|
||||
if os.environ.get("CERTBOT_DOCS") == "1":
|
||||
cli_command = "certbot(-auto)"
|
||||
os_info = "OS_NAME OS_VERSION"
|
||||
python_version = "major.minor.patchlevel"
|
||||
else:
|
||||
cli_command = cli.cli_command
|
||||
os_info = util.get_os_info_ua()
|
||||
python_version = platform.python_version()
|
||||
ua = ua.format(certbot.__version__, cli_command, os_info,
|
||||
config.authenticator, config.installer, config.verb,
|
||||
ua_flags(config), platform.python_version(),
|
||||
ua_flags(config), python_version,
|
||||
"; " + config.user_agent_comment if config.user_agent_comment else "")
|
||||
else:
|
||||
ua = config.user_agent
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"""Tests for certbot.client."""
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
@@ -16,6 +17,38 @@ KEY = test_util.load_vector("rsa512_key.pem")
|
||||
CSR_SAN = test_util.load_vector("csr-san_512.pem")
|
||||
|
||||
|
||||
class DetermineUserAgentTest(test_util.ConfigTestCase):
|
||||
"""Tests for certbot.client.determine_user_agent."""
|
||||
|
||||
def _call(self):
|
||||
from certbot.client import determine_user_agent
|
||||
return determine_user_agent(self.config)
|
||||
|
||||
@mock.patch.dict(os.environ, {"CERTBOT_DOCS": "1"})
|
||||
def test_docs_value(self):
|
||||
self._test(expect_doc_values=True)
|
||||
|
||||
@mock.patch.dict(os.environ, {})
|
||||
def test_real_values(self):
|
||||
self._test(expect_doc_values=False)
|
||||
|
||||
def _test(self, expect_doc_values):
|
||||
ua = self._call()
|
||||
|
||||
if expect_doc_values:
|
||||
doc_value_check = self.assertIn
|
||||
real_value_check = self.assertNotIn
|
||||
else:
|
||||
doc_value_check = self.assertNotIn
|
||||
real_value_check = self.assertIn
|
||||
|
||||
doc_value_check("certbot(-auto)", ua)
|
||||
doc_value_check("OS_NAME OS_VERSION", ua)
|
||||
doc_value_check("major.minor.patchlevel", ua)
|
||||
real_value_check(util.get_os_info_ua(), ua)
|
||||
real_value_check(platform.python_version(), ua)
|
||||
|
||||
|
||||
class RegisterTest(test_util.ConfigTestCase):
|
||||
"""Tests for certbot.client.register."""
|
||||
|
||||
|
||||
+2
-1
@@ -153,7 +153,8 @@ kill $!
|
||||
cd ~-
|
||||
|
||||
# get a snapshot of the CLI help for the docs
|
||||
certbot --help all > docs/cli-help.txt
|
||||
# We set CERTBOT_DOCS to use dummy values in example user-agent string.
|
||||
CERTBOT_DOCS=1 certbot --help all > docs/cli-help.txt
|
||||
jws --help > acme/docs/jws-help.txt
|
||||
|
||||
cd ..
|
||||
|
||||
Reference in New Issue
Block a user