mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 00:22:28 +02:00
Add test case and fix to properly handle configs with no smtpd_tls_* vars.
This commit is contained in:
@@ -300,13 +300,17 @@ class PostfixConfigGenerator:
|
|||||||
'smtpd_tls_cert_file': None,
|
'smtpd_tls_cert_file': None,
|
||||||
}
|
}
|
||||||
for num, line in enumerate(self.cf):
|
for num, line in enumerate(self.cf):
|
||||||
print 'Line is: %s' % line
|
|
||||||
num, found_var, found_value = parse_line((num, line))
|
num, found_var, found_value = parse_line((num, line))
|
||||||
if found_var in cert_materials.keys():
|
if found_var in cert_materials.keys():
|
||||||
cert_materials[found_var] = found_value
|
cert_materials[found_var] = found_value
|
||||||
return [(cert_materials['smtpd_tls_cert_file'],
|
|
||||||
cert_materials['smtpd_tls_key_file'],
|
if not all(cert_materials.values()):
|
||||||
self.fn),]
|
cert_material_tuples = []
|
||||||
|
else:
|
||||||
|
cert_material_tuples = [(cert_materials['smtpd_tls_cert_file'],
|
||||||
|
cert_materials['smtpd_tls_key_file'],
|
||||||
|
self.fn),]
|
||||||
|
return cert_material_tuples
|
||||||
|
|
||||||
def save(self, title=None, temporary=False):
|
def save(self, title=None, temporary=False):
|
||||||
"""Saves all changes to the configuration files.
|
"""Saves all changes to the configuration files.
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ class TestPostfixConfigGenerator(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.fopen_names_only_config = GetFakeOpen(names_only_config)
|
self.fopen_names_only_config = GetFakeOpen(names_only_config)
|
||||||
self.fopen_certs_only_config = GetFakeOpen(certs_only_config)
|
self.fopen_certs_only_config = GetFakeOpen(certs_only_config)
|
||||||
|
self.fopen_no_certs_only_config = self.fopen_names_only_config
|
||||||
|
|
||||||
#self.config = Config.Config()
|
#self.config = Config.Config()
|
||||||
self.config = None
|
self.config = None
|
||||||
self.postfix_dir = 'tests/'
|
self.postfix_dir = 'tests/'
|
||||||
@@ -75,6 +77,15 @@ class TestPostfixConfigGenerator(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
self.assertEqual(return_vals, postfix_config_gen.get_all_certs_keys())
|
self.assertEqual(return_vals, postfix_config_gen.get_all_certs_keys())
|
||||||
|
|
||||||
|
def testGetAllCertsAndKeys_With_None(self):
|
||||||
|
postfix_config_gen = pcg.PostfixConfigGenerator(
|
||||||
|
self.config,
|
||||||
|
self.postfix_dir,
|
||||||
|
fixup=True,
|
||||||
|
fopen=self.fopen_no_certs_only_config
|
||||||
|
)
|
||||||
|
self.assertEqual([], postfix_config_gen.get_all_certs_keys())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user