Compare commits
2 Commits
test-drop-
...
test-fullc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54b2e41dde | ||
|
|
b6d696b755 |
@@ -306,6 +306,7 @@ class Client:
|
||||
orderr.alternative_fullchains_pem,
|
||||
self.config.preferred_chain,
|
||||
not self.config.dry_run)
|
||||
logger.info("orderr.fullchain_pem: %s, fullchain: %s", orderr.fullchain_pem, fullchain)
|
||||
cert, chain = crypto_util.cert_and_chain_from_fullchain(fullchain)
|
||||
return cert.encode(), chain.encode()
|
||||
|
||||
|
||||
@@ -619,6 +619,7 @@ def cert_and_chain_from_fullchain(fullchain_pem):
|
||||
# TODO: This will silently skip over any "explanatory text" in between boundaries,
|
||||
# which is prohibited by RFC8555.
|
||||
certs = CERT_PEM_REGEX.findall(fullchain_pem.encode())
|
||||
logger.info("regex match: %s", certs)
|
||||
if len(certs) < 2:
|
||||
raise errors.Error("failed to parse fullchain into cert and chain: " +
|
||||
"less than 2 certificates in chain")
|
||||
|
||||
@@ -390,13 +390,13 @@ def get_python_os_info(pretty=False):
|
||||
os_type, os_ver, _ = info
|
||||
os_type = os_type.lower()
|
||||
if os_type.startswith('linux') and _USE_DISTRO:
|
||||
info = distro.linux_distribution(pretty)
|
||||
distro_name, distro_version = distro.name() if pretty else distro.id(), distro.version()
|
||||
# On arch, distro.linux_distribution() is reportedly ('','',''),
|
||||
# so handle it defensively
|
||||
if info[0]:
|
||||
os_type = info[0]
|
||||
if info[1]:
|
||||
os_ver = info[1]
|
||||
if distro_name:
|
||||
os_type = distro_name
|
||||
if distro_version:
|
||||
os_ver = distro_version
|
||||
elif os_type.startswith('darwin'):
|
||||
try:
|
||||
proc = subprocess.run(
|
||||
|
||||
@@ -527,13 +527,13 @@ class OsInfoTest(unittest.TestCase):
|
||||
import certbot.util as cbutil
|
||||
with mock.patch('platform.system_alias',
|
||||
return_value=('linux', '42', '42')):
|
||||
m_distro.name.return_value = ""
|
||||
m_distro.linux_distribution.return_value = ("something", "1.0", "codename")
|
||||
cbutil.get_python_os_info(pretty=True)
|
||||
m_distro.version.return_value = "1.0"
|
||||
# empty value on first call for fallback to "get_python_os_info" in get_os_info_ua
|
||||
m_distro.name.side_effect = ["", "something", "something"]
|
||||
self.assertEqual(cbutil.get_os_info_ua(),
|
||||
" ".join(cbutil.get_python_os_info(pretty=True)))
|
||||
|
||||
m_distro.name.return_value = "whatever"
|
||||
m_distro.name.side_effect = ["whatever"]
|
||||
self.assertEqual(cbutil.get_os_info_ua(), "whatever")
|
||||
|
||||
@mock.patch("certbot.util.distro")
|
||||
@@ -541,11 +541,13 @@ class OsInfoTest(unittest.TestCase):
|
||||
def test_get_os_info(self, m_distro):
|
||||
import certbot.util as cbutil
|
||||
with mock.patch("platform.system") as mock_platform:
|
||||
m_distro.linux_distribution.return_value = ("name", "version", 'x')
|
||||
m_distro.id.return_value = "name"
|
||||
m_distro.version.return_value = "version"
|
||||
mock_platform.return_value = "linux"
|
||||
self.assertEqual(cbutil.get_os_info(), ("name", "version"))
|
||||
|
||||
m_distro.linux_distribution.return_value = ("something", "else")
|
||||
m_distro.id.return_value = "something"
|
||||
m_distro.version.return_value = "else"
|
||||
self.assertEqual(cbutil.get_os_info(), ("something", "else"))
|
||||
|
||||
def test_non_systemd_os_info(self):
|
||||
@@ -577,14 +579,16 @@ class OsInfoTest(unittest.TestCase):
|
||||
@unittest.skipUnless(sys.platform.startswith("linux"), "requires Linux")
|
||||
def test_python_os_info_notfound(self, m_distro):
|
||||
import certbot.util as cbutil
|
||||
m_distro.linux_distribution.return_value = ('', '', '')
|
||||
m_distro.id.return_value = ""
|
||||
m_distro.version.return_value = ""
|
||||
self.assertEqual(cbutil.get_python_os_info()[0], "linux")
|
||||
|
||||
@mock.patch("certbot.util.distro")
|
||||
@unittest.skipUnless(sys.platform.startswith("linux"), "requires Linux")
|
||||
def test_python_os_info_custom(self, m_distro):
|
||||
import certbot.util as cbutil
|
||||
m_distro.linux_distribution.return_value = ('testdist', '42', '')
|
||||
m_distro.id.return_value = "testdist"
|
||||
m_distro.version.return_value = "42"
|
||||
self.assertEqual(cbutil.get_python_os_info(), ("testdist", "42"))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user