Implement get_all_names.

This commit is contained in:
Daniel Wilcox 2016-03-29 14:31:27 -07:00
parent fee9c86233
commit fd1cef3fa0
2 changed files with 10 additions and 1 deletions

View file

@ -171,6 +171,15 @@ class PostfixConfigGenerator:
"""Returns all names that may be authenticated.
:rtype: `list` of `str`
"""
var_names = ('myhostname', 'mydomain', 'myorigin')
names_found = set()
for num, line in enumerate(self.cf):
num, found_var, found_value = parse_line((num, line))
if found_var in var_names:
names_found.add(found_value)
name_list = list(names_found)
name_list.sort()
return name_list
def deploy_cert(self, domain, _cert_path, key_path, _chain_path, fullchain_path):
"""Deploy certificate.

View file

@ -48,7 +48,7 @@ class TestPostfixConfigGenerator(unittest.TestCase):
pass
def testGetAllNames(self):
sorted_names = ('fubard.org', 'mail.fubard.org')
sorted_names = ['fubard.org', 'mail.fubard.org']
postfix_config_gen = pcg.PostfixConfigGenerator(
self.config,
self.postfix_dir,