Repository: certbot/certbot

Issue:
Remove --update-registration
The command `certbot register --update-registration` has been deprecated for a long time in favor of `certbot update_account`. Let's remove `--update-registration` and the code that uses it.


Discussion:
In addition to https://github.com/certbot/certbot/issues/7454, I'd also love to work on this if no one is already assigned
That'd be great.

Thanks @TheNavigat!
We'd like this to be included in our next release in the beginning of December. @TheNavigat, are you still planning on working on this or would you like one of us to take it over?
@bmw Sorry for the delay. Let me give it a shot this week and see how far I can go. If I got stuck I can hand it over. What do you think about that? 
That sounds good to me!

Resolving patch:
diff --git a/certbot/_internal/constants.py b/certbot/_internal/constants.py
--- a/certbot/_internal/constants.py
+++ b/certbot/_internal/constants.py
@@ -32,7 +32,6 @@
     certname=None,
     dry_run=False,
     register_unsafely_without_email=False,
-    update_registration=False,
     email=None,
     eff_email=None,
     reinstall=False,
diff --git a/certbot/_internal/main.py b/certbot/_internal/main.py
--- a/certbot/_internal/main.py
+++ b/certbot/_internal/main.py
@@ -668,14 +668,6 @@ def register(config, unused_plugins):
     :rtype: None or str
 
     """
-    # TODO: When `certbot register --update-registration` is fully deprecated,
-    # delete the true case of if block
-    if config.update_registration:
-        msg = ("Usage 'certbot register --update-registration' is deprecated.\n"
-               "Please use 'certbot update_account [options]' instead.\n")
-        logger.warning(msg)
-        return update_account(config, unused_plugins)
-
     # Portion of _determine_account logic to see whether accounts already
     # exist or not.
     account_storage = account.AccountFileStorage(config)
diff --git a/certbot/cli.py b/certbot/cli.py
--- a/certbot/cli.py
+++ b/certbot/cli.py
@@ -980,12 +980,6 @@ def prepare_and_parse_args(plugins, args, detect_defaults=False):  # pylint: dis
              "certificates. Updates to the Subscriber Agreement will still "
              "affect you, and will be effective 14 days after posting an "
              "update to the web site.")
-    # TODO: When `certbot register --update-registration` is fully deprecated,
-    # delete following helpful.add
-    helpful.add(
-        "register", "--update-registration", action="store_true",
-        default=flag_default("update_registration"), dest="update_registration",
-        help=argparse.SUPPRESS)
     helpful.add(
         ["register", "update_account", "unregister", "automation"], "-m", "--email",
         default=flag_default("email"),


Test patch:
diff --git a/certbot-ci/certbot_integration_tests/certbot_tests/test_main.py b/certbot-ci/certbot_integration_tests/certbot_tests/test_main.py
--- a/certbot-ci/certbot_integration_tests/certbot_tests/test_main.py
+++ b/certbot-ci/certbot_integration_tests/certbot_tests/test_main.py
@@ -62,11 +62,6 @@ def test_registration_override(context):
     context.certbot(['unregister'])
     context.certbot(['register', '--email', 'ex1@domain.org,ex2@domain.org'])
 
-    # TODO: When `certbot register --update-registration` is fully deprecated,
-    #  delete the two following deprecated uses
-    context.certbot(['register', '--update-registration', '--email', 'ex1@domain.org'])
-    context.certbot(['register', '--update-registration', '--email', 'ex1@domain.org,ex2@domain.org'])
-
     context.certbot(['update_account', '--email', 'example@domain.org'])
     context.certbot(['update_account', '--email', 'ex1@domain.org,ex2@domain.org'])
 
diff --git a/certbot/tests/main_test.py b/certbot/tests/main_test.py
--- a/certbot/tests/main_test.py
+++ b/certbot/tests/main_test.py
@@ -1400,33 +1400,6 @@ def test_update_account_no_existing_accounts(self):
                  "user@example.org"])
             self.assertTrue("Could not find an existing account" in x[0])
 
-    # TODO: When `certbot register --update-registration` is fully deprecated,
-    # delete the following test
-    def test_update_registration_no_existing_accounts_deprecated(self):
-        # with mock.patch('certbot._internal.main.client') as mocked_client:
-        with mock.patch('certbot._internal.main.account') as mocked_account:
-            mocked_storage = mock.MagicMock()
-            mocked_account.AccountFileStorage.return_value = mocked_storage
-            mocked_storage.find_all.return_value = []
-            x = self._call_no_clientmock(
-                ["register", "--update-registration", "--email",
-                 "user@example.org"])
-            self.assertTrue("Could not find an existing account" in x[0])
-
-    # TODO: When `certbot register --update-registration` is fully deprecated,
-    # delete the following test
-    def test_update_registration_unsafely_deprecated(self):
-        # This test will become obsolete when register --update-registration
-        # supports removing an e-mail address from the account
-        with mock.patch('certbot._internal.main.account') as mocked_account:
-            mocked_storage = mock.MagicMock()
-            mocked_account.AccountFileStorage.return_value = mocked_storage
-            mocked_storage.find_all.return_value = ["an account"]
-            x = self._call_no_clientmock(
-                "register --update-registration "
-                "--register-unsafely-without-email".split())
-            self.assertTrue("--register-unsafely-without-email" in x[0])
-
     @mock.patch('certbot._internal.main.display_ops.get_email')
     @test_util.patch_get_utility()
     def test_update_account_with_email(self, mock_utility, mock_email):
@@ -1457,42 +1430,6 @@ def test_update_account_with_email(self, mock_utility, mock_email):
                             email in mock_utility().add_message.call_args[0][0])
                         self.assertTrue(mock_handle.called)
 
-    # TODO: When `certbot register --update-registration` is fully deprecated,
-    # delete the following test
-    @mock.patch('certbot._internal.main.display_ops.get_email')
-    @test_util.patch_get_utility()
-    def test_update_registration_with_email_deprecated(self, mock_utility, mock_email):
-        email = "user@example.com"
-        mock_email.return_value = email
-        with mock.patch('certbot._internal.eff.handle_subscription') as mock_handle:
-            with mock.patch('certbot._internal.main._determine_account') as mocked_det:
-                with mock.patch('certbot._internal.main.account') as mocked_account:
-                    with mock.patch('certbot._internal.main.client') as mocked_client:
-                        mocked_storage = mock.MagicMock()
-                        mocked_account.AccountFileStorage.return_value = mocked_storage
-                        mocked_storage.find_all.return_value = ["an account"]
-                        mock_acc = mock.MagicMock()
-                        mock_regr = mock_acc.regr
-                        mocked_det.return_value = (mock_acc, "foo")
-                        cb_client = mock.MagicMock()
-                        mocked_client.Client.return_value = cb_client
-                        x = self._call_no_clientmock(
-                            ["register", "--update-registration"])
-                        # When registration change succeeds, the return value
-                        # of register() is None
-                        self.assertTrue(x[0] is None)
-                        # and we got supposedly did update the registration from
-                        # the server
-                        reg_arg = cb_client.acme.update_registration.call_args[0][0]
-                        # Test the return value of .update() was used because
-                        # the regr is immutable.
-                        self.assertEqual(reg_arg, mock_regr.update())
-                        # and we saved the updated registration on disk
-                        self.assertTrue(mocked_storage.save_regr.called)
-                        self.assertTrue(
-                            email in mock_utility().add_message.call_args[0][0])
-                        self.assertTrue(mock_handle.called)
-
     @mock.patch('certbot._internal.plugins.selection.choose_configurator_plugins')
     @mock.patch('certbot._internal.updater._run_updaters')
     def test_plugin_selection_error(self, mock_run, mock_choose):