mirror of
https://github.com/certbot/certbot.git
synced 2026-06-07 15:52:08 -04:00
Use byte literals in a python 2 and 3 compatible way
This commit is contained in:
parent
ff26c3e623
commit
7b1f6d483c
2 changed files with 8 additions and 6 deletions
|
|
@ -266,7 +266,7 @@ class ApacheConfigurator(common.Installer):
|
|||
logger.warning("Unable to read ssl_module file; not disabling session tickets.")
|
||||
return None
|
||||
# looks like: OpenSSL 1.0.2s 28 May 2019
|
||||
matches = re.findall(rb"OpenSSL ([0-9]\.[^ ]+) ", contents)
|
||||
matches = re.findall(b"OpenSSL ([0-9]\.[^ ]+) ", contents)
|
||||
if not matches:
|
||||
logger.warning("Could not find OpenSSL version; not disabling session tickets.")
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -1784,7 +1784,7 @@ class InstallSslOptionsConfTest(util.ApacheTest):
|
|||
"hash of {0} when it is updated.".format(one_file))
|
||||
|
||||
def test_openssl_version(self):
|
||||
some_string_contents = """
|
||||
some_string_contents = b"""
|
||||
SSLOpenSSLConfCmd
|
||||
OpenSSL configuration command
|
||||
SSLv3 not supported by this version of OpenSSL
|
||||
|
|
@ -1798,7 +1798,7 @@ class InstallSslOptionsConfTest(util.ApacheTest):
|
|||
self.config.parser.modules['ssl_module'] = '/fake/path'
|
||||
with mock.patch("certbot_apache._internal.configurator."
|
||||
"ApacheConfigurator._open_module_file") as mock_omf:
|
||||
mock_omf.return_value = some_string_contents.encode('UTF-8')
|
||||
mock_omf.return_value = some_string_contents
|
||||
self.assertEqual(self.config.openssl_version(), "1.0.2g")
|
||||
|
||||
def test_current_version(self):
|
||||
|
|
@ -1819,7 +1819,9 @@ class InstallSslOptionsConfTest(util.ApacheTest):
|
|||
|
||||
self.config._openssl_version = None
|
||||
self.config.parser.modules['ssl_module'] = None
|
||||
self.assertEqual(self.config.openssl_version(), None)
|
||||
with mock.patch("certbot_apache._internal.configurator.logger.warning") as mock_log:
|
||||
self.assertEqual(self.config.openssl_version(), None)
|
||||
self.assertTrue("Could not find ssl_module" in mock_log.call_args[0][0])
|
||||
|
||||
self.config.parser.modules['ssl_module'] = "/fake/path"
|
||||
with mock.patch("certbot_apache._internal.configurator.logger.warning") as mock_log:
|
||||
|
|
@ -1827,10 +1829,10 @@ class InstallSslOptionsConfTest(util.ApacheTest):
|
|||
self.assertEqual(self.config.openssl_version(), None)
|
||||
self.assertTrue("Unable to read" in mock_log.call_args[0][0])
|
||||
|
||||
contents_missing_openssl = "these contents won't match the regex"
|
||||
contents_missing_openssl = b"these contents won't match the regex"
|
||||
with mock.patch("certbot_apache._internal.configurator."
|
||||
"ApacheConfigurator._open_module_file") as mock_omf:
|
||||
mock_omf.return_value = contents_missing_openssl.encode('UTF-8')
|
||||
mock_omf.return_value = contents_missing_openssl
|
||||
with mock.patch("certbot_apache._internal.configurator.logger.warning") as mock_log:
|
||||
# Check that correct logger.warning was printed
|
||||
self.assertEqual(self.config.openssl_version(), None)
|
||||
|
|
|
|||
Loading…
Reference in a new issue