mirror of
https://github.com/certbot/certbot.git
synced 2026-06-05 06:42:10 -04:00
Add test case and fix to properly handle configs with no smtpd_tls_* vars.
This commit is contained in:
parent
c6baa82ee4
commit
7edceec8ac
2 changed files with 19 additions and 4 deletions
|
|
@ -300,13 +300,17 @@ class PostfixConfigGenerator:
|
|||
'smtpd_tls_cert_file': None,
|
||||
}
|
||||
for num, line in enumerate(self.cf):
|
||||
print 'Line is: %s' % line
|
||||
num, found_var, found_value = parse_line((num, line))
|
||||
if found_var in cert_materials.keys():
|
||||
cert_materials[found_var] = found_value
|
||||
return [(cert_materials['smtpd_tls_cert_file'],
|
||||
cert_materials['smtpd_tls_key_file'],
|
||||
self.fn),]
|
||||
|
||||
if not all(cert_materials.values()):
|
||||
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):
|
||||
"""Saves all changes to the configuration files.
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ class TestPostfixConfigGenerator(unittest.TestCase):
|
|||
def setUp(self):
|
||||
self.fopen_names_only_config = GetFakeOpen(names_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 = None
|
||||
self.postfix_dir = 'tests/'
|
||||
|
|
@ -75,6 +77,15 @@ class TestPostfixConfigGenerator(unittest.TestCase):
|
|||
)
|
||||
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__':
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in a new issue