mirror of
https://github.com/certbot/certbot.git
synced 2026-06-04 14:26:10 -04:00
Fix Postfix Installer __init__()
This commit is contained in:
parent
d97a15861b
commit
481fb8413b
2 changed files with 23 additions and 19 deletions
|
|
@ -28,14 +28,13 @@ class Installer(plugins_common.Plugin):
|
|||
"Postfix main.cf file to modify instead of using the "
|
||||
"default configuration paths")
|
||||
|
||||
def __init__(self,
|
||||
postfix_dir,
|
||||
fixup=False):
|
||||
self.fixup = fixup
|
||||
self.postfix_dir = postfix_dir
|
||||
self.policy_file = os.path.join(postfix_dir,
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Installer, self).__init__(*args, **kwargs)
|
||||
self.fixup = False
|
||||
self.postfix_dir = self.conf("config-dir")
|
||||
self.policy_file = os.path.join(self.postfix_dir,
|
||||
"starttls_everywhere_policy")
|
||||
self.ca_file = os.path.join(postfix_dir, "starttls_everywhere_CAfile")
|
||||
self.ca_file = os.path.join(self.postfix_dir, "starttls_everywhere_CAfile")
|
||||
|
||||
self.additions = []
|
||||
self.deletions = []
|
||||
|
|
|
|||
|
|
@ -35,10 +35,7 @@ class TestPostfixConfigGenerator(unittest.TestCase):
|
|||
sorted_names = ['fubard.org', 'mail.fubard.org']
|
||||
with mock.patch('certbot_postfix.installer.open') as mock_open:
|
||||
mock_open.return_value = six.StringIO(names_only_config)
|
||||
postfix_config_gen = installer.Installer(
|
||||
self.postfix_dir,
|
||||
fixup=True,
|
||||
)
|
||||
postfix_config_gen = self._create_installer()
|
||||
self.assertEqual(sorted_names, postfix_config_gen.get_all_names())
|
||||
|
||||
def testGetAllCertAndKeys(self):
|
||||
|
|
@ -47,21 +44,29 @@ class TestPostfixConfigGenerator(unittest.TestCase):
|
|||
'tests/main.cf'),]
|
||||
with mock.patch('certbot_postfix.installer.open') as mock_open:
|
||||
mock_open.return_value = six.StringIO(certs_only_config)
|
||||
postfix_config_gen = installer.Installer(
|
||||
self.postfix_dir,
|
||||
fixup=True,
|
||||
)
|
||||
postfix_config_gen = self._create_installer()
|
||||
self.assertEqual(return_vals, postfix_config_gen.get_all_certs_keys())
|
||||
|
||||
def testGetAllCertsAndKeys_With_None(self):
|
||||
with mock.patch('certbot_postfix.installer.open') as mock_open:
|
||||
mock_open.return_value = six.StringIO(names_only_config)
|
||||
postfix_config_gen = installer.Installer(
|
||||
self.postfix_dir,
|
||||
fixup=True,
|
||||
)
|
||||
postfix_config_gen = self._create_installer()
|
||||
self.assertEqual([], postfix_config_gen.get_all_certs_keys())
|
||||
|
||||
|
||||
def _create_installer(self):
|
||||
"""Creates and returns a new Postfix Installer.
|
||||
|
||||
:returns: a new Postfix installer
|
||||
:rtype: certbot_postfix.installer.Installer
|
||||
|
||||
"""
|
||||
config = mock.MagicMock(postfix_config_dir=self.postfix_dir)
|
||||
name = "postfix"
|
||||
|
||||
from certbot_postfix import installer
|
||||
return installer.Installer(config, name)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in a new issue