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

Fixed distributions not being viewable in content app #1217

Merged
merged 1 commit into from Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/8475.bugfix
@@ -0,0 +1 @@
Distributions are now viewable again at the base url of the content app
2 changes: 1 addition & 1 deletion pulpcore/content/handler.py
Expand Up @@ -119,7 +119,7 @@ async def list_distributions(self, request):
base_paths = list(BaseDistribution.objects.values_list("base_path", flat=True))
else:
base_paths = list(self.distribution_model.objects.values_list("base_path", flat=True))
directory_list = ["{}/".format(d.base_path) for d in base_paths]
directory_list = ["{}/".format(base_path) for base_path in base_paths]
return HTTPOk(headers={"Content-Type": "text/html"}, body=self.render_html(directory_list))

async def stream_content(self, request):
Expand Down
4 changes: 4 additions & 0 deletions pulpcore/tests/functional/api/using_plugin/constants.py
Expand Up @@ -13,6 +13,10 @@

PULP_FIXTURES_BASE_URL = config.get_config().get_fixtures_url()

PULP_CONTENT_HOST_BASE_URL = config.get_config().get_content_host_base_url()

PULP_CONTENT_BASE_URL = urljoin(PULP_CONTENT_HOST_BASE_URL, "pulp/content/")
Copy link
Contributor

Choose a reason for hiding this comment

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

🥇


FILE_CONTENT_NAME = "file.file"

FILE_CONTENT_PATH = urljoin(BASE_CONTENT_PATH, "file/files/")
Expand Down
Expand Up @@ -12,6 +12,7 @@
FILE_FIXTURE_MANIFEST_URL,
FILE_REMOTE_PATH,
FILE_REPO_PATH,
PULP_CONTENT_BASE_URL,
)
from pulpcore.tests.functional.api.using_plugin.utils import create_file_publication
from pulpcore.tests.functional.api.using_plugin.utils import ( # noqa:F401
Expand All @@ -28,6 +29,7 @@ def test_all(self):
This test targets the following issue:

* `Pulp #4186 <https://pulp.plan.io/issues/4186>`_
* `Pulp #8475 <https://pulp.plan.io/issues/8475>`_

Do the following:

Expand All @@ -36,7 +38,9 @@ def test_all(self):
3. Create 2 distributions - using the same publication. Those
distributions will have different ``base_path``.
4. Assert that distributions have the same publication.
5. Select a content unit. Download that content unit from Pulp using
5. Assert that distributions are viewable from base url
6. Assert that content in distributions are viewable
7. Select a content unit. Download that content unit from Pulp using
the two different distributions.
Assert that content unit has the same checksum when fetched from
different distributions.
Expand Down Expand Up @@ -68,13 +72,18 @@ def test_all(self):
distributions[0]["publication"], distributions[1]["publication"], distributions
)

client.response_handler = api.safe_handler
self.assertEqual(client.get(PULP_CONTENT_BASE_URL).status_code, 200)

for distribution in distributions:
self.assertEqual(client.get(distribution["base_url"]).status_code, 200)

unit_urls = []
unit_path = get_added_content(repo)[FILE_CONTENT_NAME][0]["relative_path"]
for distribution in distributions:
unit_url = distribution["base_url"]
unit_urls.append(urljoin(unit_url, unit_path))

client.response_handler = api.safe_handler
self.assertEqual(
hashlib.sha256(client.get(unit_urls[0]).content).hexdigest(),
hashlib.sha256(client.get(unit_urls[1]).content).hexdigest(),
Expand Down