Add basic test for get_all_certs_keys IInstaller interface method.

This commit is contained in:
Daniel Wilcox 2016-04-28 12:27:49 -07:00
parent cc83e9ba52
commit e75bafa439

View file

@ -24,6 +24,12 @@ mydomain = fubard.org
myorigin = fubard.org"""
certs_only_config = """
smtpd_tls_cert_file = /etc/letsencrypt/live/www.fubard.org/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/www.fubard.org/privkey.pem
"""
def GetFakeOpen(fake_file_contents):
fake_file = io.StringIO()
# cast this to unicode for py2
@ -40,6 +46,7 @@ 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.config = Config.Config()
self.config = None
self.postfix_dir = 'tests/'
@ -57,6 +64,18 @@ class TestPostfixConfigGenerator(unittest.TestCase):
)
self.assertEqual(sorted_names, postfix_config_gen.get_all_names())
def testGetAllCertAndKeys(self):
return_vals = ('/etc/letsencrypt/live/www.fubard.org/fullchain.pem',
'/etc/letsencrypt/live/www.fubard.org/privkey.pem',
None)
postfix_config_gen = pcg.PostfixConfigGenerator(
self.config,
self.postfix_dir,
fixup=True,
fopen=self.fopen_certs_only_config
)
self.assertEqual(return_vals, postfix_config_gen.get_all_certs_keys())
if __name__ == '__main__':
unittest.main()