Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

experimental client: Remove mirrors #1373

Merged
merged 10 commits into from
May 12, 2021
9 changes: 4 additions & 5 deletions tests/test_updater_rework.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,13 @@ def setUp(self):
# directory copied from the original repository files.
tuf.settings.repositories_directory = self.client_directory

self.repository_mirrors = {'mirror1': {'url_prefix': url_prefix,
'metadata_path': 'metadata',
'targets_path': 'targets'}}

metadata_url = os.path.join(url_prefix, 'metadata/')
targets_url = os.path.join(url_prefix, 'targets/')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should this be urllib.parse.urljoin()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I'll change that

Fact is that the test needs to be rewritten, it's copied from test_updater.py and is horribly complex and full of issues like this for (I assume) Historical Reasons... but I'm trying to limit scope so not fixing anything else here

# Creating a repository instance. The test cases will use this client
# updater to refresh metadata, fetch target files, etc.
self.repository_updater = updater.Updater(self.repository_name,
self.repository_mirrors)
metadata_url,
targets_url)

# Metadata role keys are needed by the test cases to make changes to the
# repository (e.g., adding a new target file to 'targets.json' and then
Expand Down
12 changes: 12 additions & 0 deletions tuf/client_rework/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,21 @@ def download_file(url, required_length, fetcher, strict_required_length=True):
raise

else:
temp_file.seek(0)
return temp_file


def download_bytes(url, required_length, fetcher, strict_required_length=True):
"""Download bytes from given url

Returns the downloaded bytes, otherwise like download_file()
"""
with download_file(
url, required_length, fetcher, strict_required_length
) as dl_file:
return dl_file.read()


def _check_downloaded_length(
total_downloaded,
required_length,
Expand Down
130 changes: 0 additions & 130 deletions tuf/client_rework/mirrors.py

This file was deleted.

Loading