From 6505054f622f2621af4be58760a96cdc0d1f6bd9 Mon Sep 17 00:00:00 2001 From: Alex Zorin Date: Mon, 23 Jan 2023 18:36:34 +1100 Subject: [PATCH] account: stop storing legacy new_authzr_uri --- certbot/certbot/_internal/account.py | 29 +++------------------------- certbot/tests/account_test.py | 11 +---------- 2 files changed, 4 insertions(+), 36 deletions(-) diff --git a/certbot/certbot/_internal/account.py b/certbot/certbot/_internal/account.py index eb2466f32..8dcf1de09 100644 --- a/certbot/certbot/_internal/account.py +++ b/certbot/certbot/_internal/account.py @@ -126,18 +126,6 @@ class AccountMemoryStorage(interfaces.AccountStorage): raise errors.AccountNotFound(account_id) -class RegistrationResourceWithNewAuthzrURI(messages.RegistrationResource): - """A backwards-compatible RegistrationResource with a new-authz URI. - - Hack: Certbot versions pre-0.11.1 expect to load - new_authzr_uri as part of the account. Because people - sometimes switch between old and new versions, we will - continue to write out this field for some time so older - clients don't crash in that scenario. - """ - new_authzr_uri: str = jose.field('new_authzr_uri') - - class AccountFileStorage(interfaces.AccountStorage): """Accounts file storage. @@ -360,20 +348,9 @@ class AccountFileStorage(interfaces.AccountStorage): def _update_regr(self, account: Account, acme: ClientV2, dir_path: str) -> None: with open(self._regr_path(dir_path), "w") as regr_file: - regr = account.regr - # If we have a value for new-authz, save it for forwards - # compatibility with older versions of Certbot. If we don't - # have a value for new-authz, this is an ACMEv2 directory where - # an older version of Certbot won't work anyway. - if hasattr(acme.directory, "new-authz"): - regr = RegistrationResourceWithNewAuthzrURI( - new_authzr_uri=acme.directory.new_authz, - body={}, - uri=regr.uri) - else: - regr = messages.RegistrationResource( - body={}, - uri=regr.uri) + regr = messages.RegistrationResource( + body={}, + uri=account.regr.uri) regr_file.write(regr.json_dumps()) def _update_meta(self, account: Account, dir_path: str) -> None: diff --git a/certbot/tests/account_test.py b/certbot/tests/account_test.py index 0037de31e..e0972f247 100644 --- a/certbot/tests/account_test.py +++ b/certbot/tests/account_test.py @@ -116,8 +116,7 @@ class AccountFileStorageTest(test_util.ConfigTestCase): 2021, 1, 5, 14, 4, 10, tzinfo=pytz.UTC)) self.acc = Account( regr=messages.RegistrationResource( - uri=None, body=messages.Registration(), - new_authzr_uri=new_authzr_uri), + uri=None, body=messages.Registration()), key=KEY, meta=meta) self.mock_client = mock.MagicMock() @@ -141,14 +140,6 @@ class AccountFileStorageTest(test_util.ConfigTestCase): loaded = self.storage.load(self.acc.id) self.assertEqual(self.acc, loaded) - def test_save_and_restore_old_version(self): - """Saved regr should include a new_authzr_uri for older Certbots""" - self.storage.save(self.acc, self.mock_client) - path = os.path.join(self.config.accounts_dir, self.acc.id, "regr.json") - with open(path, "r") as f: - regr = json.load(f) - self.assertIn("new_authzr_uri", regr) - def test_update_regr(self): self.storage.update_regr(self.acc, self.mock_client) account_path = os.path.join(self.config.accounts_dir, self.acc.id)