コード例 #1
0
 def test_more_info(self):
     with create_installer(self.config) as installer:
         installer.prepare()
         output = installer.more_info()
         self.assertTrue("Postfix" in output)
         self.assertTrue(self.tempdir in output)
         self.assertTrue(DEFAULT_MAIN_CF["mail_version"] in output)
コード例 #2
0
ファイル: installer_test.py プロジェクト: certbot/certbot
 def test_more_info(self):
     with create_installer(self.config) as installer:
         installer.prepare()
         output = installer.more_info()
         self.assertTrue("Postfix" in output)
         self.assertTrue(self.tempdir in output)
         self.assertTrue(DEFAULT_MAIN_CF["mail_version"] in output)
コード例 #3
0
ファイル: installer_test.py プロジェクト: certbot/certbot
 def test_get_all_names(self):
     config = {"mydomain": "example.org",
               "myhostname": "mail.example.org",
               "myorigin": "example.org"}
     with create_installer(self.config, main_cf=_main_cf_with(config)) as installer:
         installer.prepare()
         result = installer.get_all_names()
         self.assertEqual(result, set(config.values()))
コード例 #4
0
ファイル: installer_test.py プロジェクト: certbot/certbot
 def test_tls_and_server_only(self, mock_util):
     mock_util().yesno.return_value = True
     with create_installer(self.config) as installer:
         installer.prepare()
         installer.conf = lambda x: True
         installer.postconf.set = mock.Mock()
         installer.deploy_cert("example.com", "cert_path", "key_path",
                               "chain_path", "fullchain_path")
         self.assertEqual(installer.postconf.set.call_count, 3)
コード例 #5
0
 def test_tls_and_server_only(self, mock_util):
     mock_util().yesno.return_value = True
     with create_installer(self.config) as installer:
         installer.prepare()
         installer.conf = lambda x: True
         installer.postconf.set = mock.Mock()
         installer.deploy_cert("example.com", "cert_path", "key_path",
                               "chain_path", "fullchain_path")
         self.assertEqual(installer.postconf.set.call_count, 3)
コード例 #6
0
 def test_get_all_names(self):
     config = {
         "mydomain": "example.org",
         "myhostname": "mail.example.org",
         "myorigin": "example.org"
     }
     with create_installer(self.config,
                           main_cf=_main_cf_with(config)) as installer:
         installer.prepare()
         result = installer.get_all_names()
         self.assertEqual(result, set(config.values()))
コード例 #7
0
ファイル: installer_test.py プロジェクト: certbot/certbot
 def test_deploy_twice(self, mock_util):
     # Deploying twice on the same installer shouldn't do anything!
     mock_util().yesno.return_value = True
     with create_installer(self.config) as installer:
         installer.prepare()
         from certbot_postfix.postconf import ConfigMain
         with mock.patch.object(ConfigMain, "set", wraps=installer.postconf.set) as fake_set:
             installer.deploy_cert("example.com", "cert_path", "key_path",
                                   "chain_path", "fullchain_path")
             self.assertEqual(fake_set.call_count, 15)
             fake_set.reset_mock()
             installer.deploy_cert("example.com", "cert_path", "key_path",
                                   "chain_path", "fullchain_path")
             self.assertFalse(fake_set.called)
コード例 #8
0
ファイル: installer_test.py プロジェクト: certbot/certbot
 def test_deploy_already_secure(self, mock_util):
     # Should not overwrite "more-secure" parameters
     mock_util().yesno.return_value = True
     more_secure = {
         "smtpd_tls_security_level": "encrypt",
         "smtpd_tls_protocols": "!SSLv3, !SSLv2, !TLSv1",
         "smtpd_tls_eecdh_grade": "strong"
     }
     with create_installer(self.config,\
         main_cf=_main_cf_with(more_secure)) as installer:
         installer.prepare()
         installer.deploy_cert("example.com", "cert_path", "key_path",
                               "chain_path", "fullchain_path")
         for param in more_secure:
             self.assertFalse(param in installer.postconf.get_changes())
コード例 #9
0
 def test_deploy_already_secure(self, mock_util):
     # Should not overwrite "more-secure" parameters
     mock_util().yesno.return_value = True
     more_secure = {
         "smtpd_tls_security_level": "encrypt",
         "smtpd_tls_protocols": "!SSLv3, !SSLv2, !TLSv1",
         "smtpd_tls_eecdh_grade": "strong"
     }
     with create_installer(self.config,\
         main_cf=_main_cf_with(more_secure)) as installer:
         installer.prepare()
         installer.deploy_cert("example.com", "cert_path", "key_path",
                               "chain_path", "fullchain_path")
         for param in more_secure:
             self.assertFalse(param in installer.postconf.get_changes())
コード例 #10
0
 def test_deploy_twice(self, mock_util):
     # Deploying twice on the same installer shouldn't do anything!
     mock_util().yesno.return_value = True
     with create_installer(self.config) as installer:
         installer.prepare()
         from certbot_postfix.postconf import ConfigMain
         with mock.patch.object(ConfigMain,
                                "set",
                                wraps=installer.postconf.set) as fake_set:
             installer.deploy_cert("example.com", "cert_path", "key_path",
                                   "chain_path", "fullchain_path")
             self.assertEqual(fake_set.call_count, 15)
             fake_set.reset_mock()
             installer.deploy_cert("example.com", "cert_path", "key_path",
                                   "chain_path", "fullchain_path")
             self.assertFalse(fake_set.called)
コード例 #11
0
ファイル: installer_test.py プロジェクト: certbot/certbot
    def test_deploy(self, mock_util):
        mock_util().yesno.return_value = True
        from certbot_postfix import constants
        with create_installer(self.config) as installer:
            installer.prepare()

            # pylint: disable=protected-access
            installer.deploy_cert("example.com", "cert_path", "key_path",
                                  "chain_path", "fullchain_path")
            changes = installer.postconf.get_changes()
            expected = {} # type: Dict[str, Tuple[str, ...]]
            expected.update(constants.TLS_SERVER_VARS)
            expected.update(constants.DEFAULT_SERVER_VARS)
            expected.update(constants.DEFAULT_CLIENT_VARS)
            self.assertEqual(changes["smtpd_tls_key_file"], "key_path")
            self.assertEqual(changes["smtpd_tls_cert_file"], "cert_path")
            for name, value in six.iteritems(expected):
                self.assertEqual(changes[name], value[0])
コード例 #12
0
    def test_deploy(self, mock_util):
        mock_util().yesno.return_value = True
        from certbot_postfix import constants
        with create_installer(self.config) as installer:
            installer.prepare()

            # pylint: disable=protected-access
            installer.deploy_cert("example.com", "cert_path", "key_path",
                                  "chain_path", "fullchain_path")
            changes = installer.postconf.get_changes()
            expected = {}  # type: Dict[str, Tuple[str, ...]]
            expected.update(constants.TLS_SERVER_VARS)
            expected.update(constants.DEFAULT_SERVER_VARS)
            expected.update(constants.DEFAULT_CLIENT_VARS)
            self.assertEqual(changes["smtpd_tls_key_file"], "key_path")
            self.assertEqual(changes["smtpd_tls_cert_file"], "cert_path")
            for name, value in six.iteritems(expected):
                self.assertEqual(changes[name], value[0])
コード例 #13
0
ファイル: installer_test.py プロジェクト: certbot/certbot
 def test_supported_enhancements(self):
     with create_installer(self.config) as installer:
         installer.prepare()
         self.assertEqual(installer.supported_enhancements(), [])
コード例 #14
0
ファイル: installer_test.py プロジェクト: certbot/certbot
 def test_enhance(self):
     with create_installer(self.config) as installer:
         installer.prepare()
         self.assertRaises(errors.PluginError,
                           installer.enhance,
                           "example.org", "redirect")
コード例 #15
0
 def test_supported_enhancements(self):
     with create_installer(self.config) as installer:
         installer.prepare()
         self.assertEqual(installer.supported_enhancements(), [])
コード例 #16
0
 def test_enhance(self):
     with create_installer(self.config) as installer:
         installer.prepare()
         self.assertRaises(errors.PluginError, installer.enhance,
                           "example.org", "redirect")