mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 03:52:02 +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:
|
if config.user_agent is None:
|
||||||
ua = ("CertbotACMEClient/{0} ({1}; {2}{8}) Authenticator/{3} Installer/{4} "
|
ua = ("CertbotACMEClient/{0} ({1}; {2}{8}) Authenticator/{3} Installer/{4} "
|
||||||
"({5}; flags: {6}) Py/{7}")
|
"({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,
|
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 "")
|
"; " + config.user_agent_comment if config.user_agent_comment else "")
|
||||||
else:
|
else:
|
||||||
ua = config.user_agent
|
ua = config.user_agent
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"""Tests for certbot.client."""
|
"""Tests for certbot.client."""
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
@@ -16,6 +17,38 @@ KEY = test_util.load_vector("rsa512_key.pem")
|
|||||||
CSR_SAN = test_util.load_vector("csr-san_512.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):
|
class RegisterTest(test_util.ConfigTestCase):
|
||||||
"""Tests for certbot.client.register."""
|
"""Tests for certbot.client.register."""
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -153,7 +153,8 @@ kill $!
|
|||||||
cd ~-
|
cd ~-
|
||||||
|
|
||||||
# get a snapshot of the CLI help for the docs
|
# 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
|
jws --help > acme/docs/jws-help.txt
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|||||||
Reference in New Issue
Block a user