def test_bad_config_file(self):
     from letsencrypt import renewer
     with open(
             os.path.join(self.defaults["renewal_configs_dir"], "bad.conf"),
             "w") as f:
         f.write("incomplete = configfile\n")
     renewer.main(self.defaults)
Exemple #2
0
 def test_bad_config_file(self):
     from letsencrypt import renewer
     with open(os.path.join(self.cli_config.renewal_configs_dir,
                            "bad.conf"), "w") as f:
         f.write("incomplete = configfile\n")
     renewer.main(self.defaults, args=[
         '--config-dir', self.cli_config.config_dir])
Exemple #3
0
 def test_bad_config_file(self):
     from letsencrypt import renewer
     with open(os.path.join(self.cli_config.renewal_configs_dir,
                            "bad.conf"), "w") as f:
         f.write("incomplete = configfile\n")
     renewer.main(self.defaults, args=[
         '--config-dir', self.cli_config.config_dir])
Exemple #4
0
 def test_bad_config_file(self):
     from letsencrypt import renewer
     with open(
             os.path.join(self.cli_config.renewal_configs_dir, "bad.conf"),
             "w") as f:
         f.write("incomplete = configfile\n")
     renewer.main(cli_args=self._common_cli_args())
 def test_bad_config_file(self):
     from letsencrypt import renewer
     os.unlink(os.path.join(self.cli_config.renewal_configs_dir,
                            "example.org.conf"))
     with open(os.path.join(self.cli_config.renewal_configs_dir,
                            "bad.conf"), "w") as f:
         f.write("incomplete = configfile\n")
     renewer.main(cli_args=self._common_cli_args())
Exemple #6
0
 def test_main(self, mock_renew, mock_rc, mock_notify):
     """Test for main() function."""
     from letsencrypt import renewer
     mock_rc_instance = mock.MagicMock()
     mock_rc_instance.should_autodeploy.return_value = True
     mock_rc_instance.should_autorenew.return_value = True
     mock_rc_instance.latest_common_version.return_value = 10
     mock_rc.return_value = mock_rc_instance
     with open(os.path.join(self.cli_config.renewal_configs_dir, "README"),
               "w") as f:
         f.write("This is a README file to make sure that the renewer is")
         f.write("able to correctly ignore files that don't end in .conf.")
     with open(
             os.path.join(self.cli_config.renewal_configs_dir,
                          "example.org.conf"), "w") as f:
         # This isn't actually parsed in this test; we have a separate
         # test_initialization that tests the initialization, assuming
         # that configobj can correctly parse the config file.
         f.write("cert = cert.pem\nprivkey = privkey.pem\n")
         f.write("chain = chain.pem\nfullchain = fullchain.pem\n")
     with open(
             os.path.join(self.cli_config.renewal_configs_dir,
                          "example.com.conf"), "w") as f:
         f.write("cert = cert.pem\nprivkey = privkey.pem\n")
         f.write("chain = chain.pem\nfullchain = fullchain.pem\n")
     renewer.main(self.defaults,
                  args=['--config-dir', self.cli_config.config_dir])
     self.assertEqual(mock_rc.call_count, 2)
     self.assertEqual(mock_rc_instance.update_all_links_to.call_count, 2)
     self.assertEqual(mock_notify.notify.call_count, 4)
     self.assertEqual(mock_renew.call_count, 2)
     # If we have instances that don't need any work done, no work should
     # be done (call counts associated with processing deployments or
     # renewals should not increase).
     mock_happy_instance = mock.MagicMock()
     mock_happy_instance.should_autodeploy.return_value = False
     mock_happy_instance.should_autorenew.return_value = False
     mock_happy_instance.latest_common_version.return_value = 10
     mock_rc.return_value = mock_happy_instance
     renewer.main(self.defaults,
                  args=['--config-dir', self.cli_config.config_dir])
     self.assertEqual(mock_rc.call_count, 4)
     self.assertEqual(mock_happy_instance.update_all_links_to.call_count, 0)
     self.assertEqual(mock_notify.notify.call_count, 4)
     self.assertEqual(mock_renew.call_count, 2)
Exemple #7
0
 def test_main(self, mock_renew, mock_rc, mock_notify):
     """Test for main() function."""
     from letsencrypt import renewer
     mock_rc_instance = mock.MagicMock()
     mock_rc_instance.should_autodeploy.return_value = True
     mock_rc_instance.should_autorenew.return_value = True
     mock_rc_instance.latest_common_version.return_value = 10
     mock_rc.return_value = mock_rc_instance
     with open(os.path.join(self.cli_config.renewal_configs_dir,
                            "README"), "w") as f:
         f.write("This is a README file to make sure that the renewer is")
         f.write("able to correctly ignore files that don't end in .conf.")
     with open(os.path.join(self.cli_config.renewal_configs_dir,
                            "example.org.conf"), "w") as f:
         # This isn't actually parsed in this test; we have a separate
         # test_initialization that tests the initialization, assuming
         # that configobj can correctly parse the config file.
         f.write("cert = cert.pem\nprivkey = privkey.pem\n")
         f.write("chain = chain.pem\nfullchain = fullchain.pem\n")
     with open(os.path.join(self.cli_config.renewal_configs_dir,
                            "example.com.conf"), "w") as f:
         f.write("cert = cert.pem\nprivkey = privkey.pem\n")
         f.write("chain = chain.pem\nfullchain = fullchain.pem\n")
     renewer.main(self.defaults, args=[
         '--config-dir', self.cli_config.config_dir])
     self.assertEqual(mock_rc.call_count, 2)
     self.assertEqual(mock_rc_instance.update_all_links_to.call_count, 2)
     self.assertEqual(mock_notify.notify.call_count, 4)
     self.assertEqual(mock_renew.call_count, 2)
     # If we have instances that don't need any work done, no work should
     # be done (call counts associated with processing deployments or
     # renewals should not increase).
     mock_happy_instance = mock.MagicMock()
     mock_happy_instance.should_autodeploy.return_value = False
     mock_happy_instance.should_autorenew.return_value = False
     mock_happy_instance.latest_common_version.return_value = 10
     mock_rc.return_value = mock_happy_instance
     renewer.main(self.defaults, args=[
         '--config-dir', self.cli_config.config_dir])
     self.assertEqual(mock_rc.call_count, 4)
     self.assertEqual(mock_happy_instance.update_all_links_to.call_count, 0)
     self.assertEqual(mock_notify.notify.call_count, 4)
     self.assertEqual(mock_renew.call_count, 2)
 def test_bad_config_file(self):
     from letsencrypt import renewer
     with open(os.path.join(self.defaults["renewal_configs_dir"],
                            "bad.conf"), "w") as f:
         f.write("incomplete = configfile\n")
     renewer.main(self.defaults)