diff --git a/certbot-apache/certbot_apache/_internal/prefetch_ocsp.py b/certbot-apache/certbot_apache/_internal/prefetch_ocsp.py index e9ddb8069..066fe7038 100644 --- a/certbot-apache/certbot_apache/_internal/prefetch_ocsp.py +++ b/certbot-apache/certbot_apache/_internal/prefetch_ocsp.py @@ -38,7 +38,7 @@ import time from acme.magic_typing import Dict # pylint: disable=unused-import, no-name-in-module from certbot import errors -from certbot._internal import ocsp +from certbot import ocsp from certbot.plugins.enhancements import OCSPPrefetchEnhancement from certbot.compat import filesystem diff --git a/certbot-apache/tests/ocsp_prefetch_test.py b/certbot-apache/tests/ocsp_prefetch_test.py index 2eee50a38..0e2e9e162 100644 --- a/certbot-apache/tests/ocsp_prefetch_test.py +++ b/certbot-apache/tests/ocsp_prefetch_test.py @@ -186,9 +186,9 @@ class OCSPPrefetchTest(util.ApacheTest): fh.write("MOCKRESPONSE") return False - ocsp_path = "certbot._internal.ocsp.RevocationChecker.ocsp_revoked_by_paths" + ocsp_path = "certbot.ocsp.RevocationChecker.ocsp_revoked_by_paths" with mock.patch(ocsp_path, side_effect=ocsp_req_mock): - with mock.patch('certbot._internal.ocsp.RevocationChecker.ocsp_times') as mock_times: + with mock.patch('certbot.ocsp.RevocationChecker.ocsp_times') as mock_times: produced_at = datetime.today() - timedelta(days=1) this_update = datetime.today() - timedelta(days=2) next_update = datetime.today() + timedelta(days=2) @@ -201,7 +201,7 @@ class OCSPPrefetchTest(util.ApacheTest): self.assertTrue(odbm[list(odbm.keys())[0]].endswith(b'MOCKRESPONSE')) with mock.patch(ocsp_path, side_effect=ocsp_req_mock) as mock_ocsp: - with mock.patch('certbot._internal.ocsp.RevocationChecker.ocsp_times') as mock_times: + with mock.patch('certbot.ocsp.RevocationChecker.ocsp_times') as mock_times: produced_at = datetime.today() - timedelta(days=1) this_update = datetime.today() - timedelta(days=2) next_update = datetime.today() + timedelta(days=2) @@ -216,7 +216,7 @@ class OCSPPrefetchTest(util.ApacheTest): fh.write("MOCKRESPONSE") return True - ocsp_path = "certbot._internal.ocsp.RevocationChecker.ocsp_revoked_by_paths" + ocsp_path = "certbot.ocsp.RevocationChecker.ocsp_revoked_by_paths" with mock.patch(ocsp_path, side_effect=ocsp_req_mock): self.call_mocked_py2(self.config.enable_ocsp_prefetch, self.lineage, ["ocspvhost.com"]) @@ -264,7 +264,7 @@ class OCSPPrefetchTest(util.ApacheTest): @mock.patch("certbot_apache._internal.prefetch_ocsp.OCSPPrefetchMixin.restart") def test_ocsp_prefetch_refresh_fail(self, _mock_restart): - ocsp_path = "certbot._internal.ocsp.RevocationChecker.ocsp_revoked_by_paths" + ocsp_path = "certbot.ocsp.RevocationChecker.ocsp_revoked_by_paths" log_path = "certbot_apache._internal.prefetch_ocsp.logger.warning" with mock.patch(ocsp_path) as mock_ocsp: mock_ocsp.return_value = True diff --git a/certbot/tests/ocsp_test.py b/certbot/tests/ocsp_test.py index a6741f51c..0d1d407ff 100644 --- a/certbot/tests/ocsp_test.py +++ b/certbot/tests/ocsp_test.py @@ -198,14 +198,14 @@ class OSCPTestCryptography(unittest.TestCase): @mock.patch('certbot.ocsp._check_ocsp_cryptography') def test_ensure_cryptography_toggled(self, mock_revoke, mock_determine): mock_determine.return_value = ('http://example.com', 'example.com') - self._call_expirymock(self.checker.ocsp_revoked, self.cert_obj) + self.checker.ocsp_revoked(self.cert_obj) mock_revoke.assert_called_once_with(self.cert_path, self.chain_path, 'http://example.com', None) def test_revoke(self): with _ocsp_mock(ocsp_lib.OCSPCertStatus.REVOKED, ocsp_lib.OCSPResponseStatus.SUCCESSFUL): - revoked = self._call_expirymock(self.checker.ocsp_revoked, self.cert_obj) + revoked = self.checker.ocsp_revoked(self.cert_obj) self.assertTrue(revoked) def test_responder_is_issuer(self): @@ -215,7 +215,7 @@ class OSCPTestCryptography(unittest.TestCase): with _ocsp_mock(ocsp_lib.OCSPCertStatus.REVOKED, ocsp_lib.OCSPResponseStatus.SUCCESSFUL) as mocks: mocks['mock_response'].return_value.responder_name = issuer.subject - self._call_expirymock(self.checker.ocsp_revoked, self.cert_obj) + self.checker.ocsp_revoked(self.cert_obj) # Here responder and issuer are the same. So only the signature of the OCSP # response is checked (using the issuer/responder public key). self.assertEqual(mocks['mock_check'].call_count, 1) @@ -230,7 +230,7 @@ class OSCPTestCryptography(unittest.TestCase): with _ocsp_mock(ocsp_lib.OCSPCertStatus.REVOKED, ocsp_lib.OCSPResponseStatus.SUCCESSFUL) as mocks: - self._call_expirymock(self.checker.ocsp_revoked, self.cert_obj) + self.checker.ocsp_revoked(self.cert_obj) # Here responder and issuer are not the same. Two signatures will be checked then, # first to verify the responder cert (using the issuer public key), second to # to verify the OCSP response itself (using the responder public key). @@ -326,7 +326,7 @@ class OSCPTestCryptography(unittest.TestCase): self.assertEqual(next_update, datetime(2020, 1, 3, 4, 4)) def test_ocsp_times_cryptography_no_nextupdate(self): - with mock.patch('certbot..ocsp.open', mock.mock_open(read_data="")): + with mock.patch('certbot.ocsp.open', mock.mock_open(read_data="")): with mock.patch('cryptography.x509.ocsp.load_der_ocsp_response') as mock_load: resp = mock.MagicMock() resp.produced_at = datetime(2020, 1, 2, 9, 9)