account: stop storing legacy new_authzr_uri

This commit is contained in:
Alex Zorin
2023-01-23 18:41:25 +11:00
parent be3bf316c0
commit 6505054f62
2 changed files with 4 additions and 36 deletions
+3 -26
View File
@@ -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:
+1 -10
View File
@@ -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)