From 530a9fbef47826a26f3aab4b06ff8c9cec85e122 Mon Sep 17 00:00:00 2001 From: Gerrod Ubben Date: Thu, 20 Jun 2024 12:24:17 -0400 Subject: [PATCH] Fix content index title when domains are enabled fixes: #4253 --- CHANGES/4253.bugfix | 1 + pulpcore/content/handler.py | 5 ++++- .../api/using_plugin/test_content_directory.py | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 CHANGES/4253.bugfix diff --git a/CHANGES/4253.bugfix b/CHANGES/4253.bugfix new file mode 100644 index 0000000000..1c95f5208a --- /dev/null +++ b/CHANGES/4253.bugfix @@ -0,0 +1 @@ +Fixed path title at content directory index to include domain's name when enabled. diff --git a/pulpcore/content/handler.py b/pulpcore/content/handler.py index 3af78826de..d88a854faf 100644 --- a/pulpcore/content/handler.py +++ b/pulpcore/content/handler.py @@ -407,6 +407,9 @@ def render_html(directory_list, path="", dates=None, sizes=None): """ dates = dates or {} sizes = sizes or {} + root = path == settings.CONTENT_PATH_PREFIX + if root and settings.DOMAIN_ENABLED: + path += f"{get_domain().name}/" template = Template( """ @@ -439,7 +442,7 @@ def render_html(directory_list, path="", dates=None, sizes=None): dir_list=sorted(directory_list), dates=dates, path=path, - root=path == settings.CONTENT_PATH_PREFIX, + root=root, sizes=sizes, ) diff --git a/pulpcore/tests/functional/api/using_plugin/test_content_directory.py b/pulpcore/tests/functional/api/using_plugin/test_content_directory.py index e7076ad976..414f222538 100644 --- a/pulpcore/tests/functional/api/using_plugin/test_content_directory.py +++ b/pulpcore/tests/functional/api/using_plugin/test_content_directory.py @@ -42,3 +42,14 @@ def test_zero_byte_file_listing( z_line = [i for i in response.decode("utf-8").split("\n") if i.startswith('')] assert len(z_line) == 1 assert z_line[0].endswith("0 Bytes") + + +@pytest.mark.parallel +def test_content_index_title(pulp_content_url, pulp_settings, http_get): + title = pulp_settings.CONTENT_PATH_PREFIX + if pulp_settings.DOMAIN_ENABLED: + title += "default/" + + response = http_get(pulp_content_url).decode("utf-8") + assert f"Index of {title}" in response + assert f"

Index of {title}

" in response