From efcd0090da49c9649b835d1bd5e3350f17b19fcc Mon Sep 17 00:00:00 2001 From: sagi Date: Wed, 25 May 2016 21:20:13 +0000 Subject: [PATCH] Add a specific must-staple test --- certbot/tests/client_test.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/certbot/tests/client_test.py b/certbot/tests/client_test.py index e1aea1b64..ae66ab5d0 100644 --- a/certbot/tests/client_test.py +++ b/certbot/tests/client_test.py @@ -304,6 +304,25 @@ class ClientTest(unittest.TestCase): installer.rollback_checkpoints.assert_called_once_with() self.assertEqual(installer.restart.call_count, 1) + @mock.patch("certbot.client.enhancements") + def test_must_staple(self, mock_enhancements): + # Testing our wanted behaviour: Enable OCSP Stapling when the + # --must-staple flag is on. [Without having the --staple-ocsp flag on] + config = ConfigHelper(must_staple=True, staple=False) + self.assertRaises(errors.Error, + self.client.enhance_config, ["foo.bar"], config) + + mock_enhancements.ask.return_value = True + installer = mock.MagicMock() + self.client.installer = installer + installer.supported_enhancements.return_value = ["staple-ocsp"] + + self.client.enhance_config(["foo.bar"], config) + installer.enhance.assert_called_once_with("foo.bar", "staple-ocsp", None) + self.assertEqual(installer.save.call_count, 1) + installer.restart.assert_called_once_with() + + @mock.patch("certbot.client.enhancements") def test_enhance_config(self, mock_enhancements): config = ConfigHelper(redirect=True, hsts=False, uir=False, must_staple=False)