From 5b1e9996eda2a8cd5fe11c619c05685f720a40f6 Mon Sep 17 00:00:00 2001 From: suckatrash Date: Fri, 27 Dec 2019 15:46:46 -0800 Subject: [PATCH] additional removal --- certbot/certbot/_internal/cert_manager.py | 15 --------- certbot/certbot/_internal/storage.py | 15 +-------- certbot/tests/cert_manager_test.py | 40 ----------------------- certbot/tests/storage_test.py | 15 --------- 4 files changed, 1 insertion(+), 84 deletions(-) diff --git a/certbot/certbot/_internal/cert_manager.py b/certbot/certbot/_internal/cert_manager.py index 1def76a3d..d36845f09 100644 --- a/certbot/certbot/_internal/cert_manager.py +++ b/certbot/certbot/_internal/cert_manager.py @@ -23,21 +23,6 @@ logger = logging.getLogger(__name__) # Commands ################### -def update_live_symlinks(config): - """Update the certificate file family symlinks to use archive_dir. - - Use the information in the config file to make symlinks point to - the correct archive directory. - - .. note:: This assumes that the installation is using a Reverter object. - - :param config: Configuration. - :type config: :class:`certbot._internal.configuration.NamespaceConfig` - - """ - for renewal_file in storage.renewal_conf_files(config): - storage.RenewableCert(renewal_file, config, update_symlinks=True) - def rename_lineage(config): """Rename the specified lineage to the new name. diff --git a/certbot/certbot/_internal/storage.py b/certbot/certbot/_internal/storage.py index 964515eee..b7aaf6bbd 100644 --- a/certbot/certbot/_internal/storage.py +++ b/certbot/certbot/_internal/storage.py @@ -412,7 +412,7 @@ class RenewableCert(interfaces.RenewableCert): renewal configuration file and/or systemwide defaults. """ - def __init__(self, config_filename, cli_config, update_symlinks=False): + def __init__(self, config_filename, cli_config): """Instantiate a RenewableCert object from an existing lineage. :param str config_filename: the path to the renewal config file @@ -460,8 +460,6 @@ class RenewableCert(interfaces.RenewableCert): self.live_dir = os.path.dirname(self.cert) self._fix_symlinks() - if update_symlinks: - self._update_symlinks() self._check_symlinks() @property @@ -535,17 +533,6 @@ class RenewableCert(interfaces.RenewableCert): raise errors.CertStorageError("target {0} of symlink {1} does " "not exist".format(target, link)) - def _update_symlinks(self): - """Updates symlinks to use archive_dir""" - for kind in ALL_FOUR: - link = getattr(self, kind) - previous_link = get_link_target(link) - new_link = os.path.join(self.relative_archive_dir(link), - os.path.basename(previous_link)) - - os.unlink(link) - os.symlink(new_link, link) - def _consistent(self): """Are the files associated with this lineage self-consistent? diff --git a/certbot/tests/cert_manager_test.py b/certbot/tests/cert_manager_test.py index 81134f02f..705c21d8b 100644 --- a/certbot/tests/cert_manager_test.py +++ b/certbot/tests/cert_manager_test.py @@ -62,46 +62,6 @@ class BaseCertManagerTest(test_util.ConfigTestCase): config_file.write() return config_file - -class UpdateLiveSymlinksTest(BaseCertManagerTest): - """Tests for certbot._internal.cert_manager.update_live_symlinks - """ - def test_update_live_symlinks(self): - """Test update_live_symlinks""" - # create files with incorrect symlinks - from certbot._internal import cert_manager - archive_paths = {} - for domain in self.domains: - custom_archive = self.domains[domain] - if custom_archive is not None: - archive_dir_path = custom_archive - else: - archive_dir_path = os.path.join(self.config.default_archive_dir, domain) - archive_paths[domain] = dict((kind, - os.path.join(archive_dir_path, kind + "1.pem")) for kind in ALL_FOUR) - for kind in ALL_FOUR: - live_path = self.config_files[domain][kind] - archive_path = archive_paths[domain][kind] - open(archive_path, 'a').close() - # path is incorrect but base must be correct - os.symlink(os.path.join(self.config.config_dir, kind + "1.pem"), live_path) - - # run update symlinks - cert_manager.update_live_symlinks(self.config) - - # check that symlinks go where they should - prev_dir = os.getcwd() - try: - for domain in self.domains: - for kind in ALL_FOUR: - os.chdir(os.path.dirname(self.config_files[domain][kind])) - self.assertEqual( - filesystem.realpath(os.readlink(self.config_files[domain][kind])), - filesystem.realpath(archive_paths[domain][kind])) - finally: - os.chdir(prev_dir) - - class DeleteTest(storage_test.BaseRenewableCertTest): """Tests for certbot._internal.cert_manager.delete """ diff --git a/certbot/tests/storage_test.py b/certbot/tests/storage_test.py index 6208974ec..8ebd21d83 100644 --- a/certbot/tests/storage_test.py +++ b/certbot/tests/storage_test.py @@ -775,21 +775,6 @@ class RenewableCertTests(BaseRenewableCertTest): self.assertEqual(stat.S_IMODE(os.lstat(temp).st_mode), stat.S_IMODE(os.lstat(temp2).st_mode)) - def test_update_symlinks(self): - from certbot._internal import storage - archive_dir_path = os.path.join(self.config.config_dir, "archive", "example.org") - for kind in ALL_FOUR: - live_path = self.config_file[kind] - basename = kind + "1.pem" - archive_path = os.path.join(archive_dir_path, basename) - open(archive_path, 'a').close() - os.symlink(os.path.join(self.config.config_dir, basename), live_path) - self.assertRaises(errors.CertStorageError, - storage.RenewableCert, self.config_file.filename, - self.config) - storage.RenewableCert(self.config_file.filename, self.config, - update_symlinks=True) - class DeleteFilesTest(BaseRenewableCertTest): """Tests for certbot._internal.storage.delete_files""" def setUp(self):