Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
git-hyagi committed Jan 14, 2025
1 parent 4829da1 commit 421a917
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
6 changes: 5 additions & 1 deletion pulpcore/app/serializers/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,11 @@ class BaseURLField(serializers.CharField):
"""

def to_representation(self, value):
origin = settings.CONTENT_ORIGIN.strip("/")
if not settings.CONTENT_ORIGIN:
origin = 'https://pulp/'
#origin = 'http://localhost:5001/'
else:
origin = settings.CONTENT_ORIGIN.strip("/")
prefix = settings.CONTENT_PATH_PREFIX.strip("/")
base_path = value.base_path.strip("/")
url = urljoin(origin, prefix + "/")
Expand Down
1 change: 1 addition & 0 deletions pulpcore/app/serializers/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class ContentSettingsSerializer(serializers.Serializer):

content_origin = serializers.CharField(
help_text=_("The CONTENT_ORIGIN setting for this Pulp instance"),
allow_blank=True, allow_null=True, required=False,
)
content_path_prefix = serializers.CharField(
help_text=_("The CONTENT_PATH_PREFIX setting for this Pulp instance"),
Expand Down
4 changes: 4 additions & 0 deletions pulpcore/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,10 @@ def pulp_api_v3_url(bindings_cfg, pulp_api_v3_path):
@pytest.fixture(scope="session")
def pulp_content_url(pulp_settings, pulp_domain_enabled):
url = f"{pulp_settings.CONTENT_ORIGIN}{pulp_settings.CONTENT_PATH_PREFIX}"
if not pulp_settings.CONTENT_ORIGIN:
url = f"https://pulp{pulp_settings.CONTENT_PATH_PREFIX}"
#url = f"http://localhost:5001{pulp_settings.CONTENT_PATH_PREFIX}"

if pulp_domain_enabled:
url += "default/"
return url
Expand Down
3 changes: 1 addition & 2 deletions pulpcore/tests/functional/api/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"content_settings": {
"type": "object",
"properties": {
"content_origin": {"type": "string"},
"content_origin": {"type": ["string", "null"]},
"content_path_prefix": {"type": "string"},
},
"required": ["content_origin", "content_path_prefix"],
Expand Down Expand Up @@ -138,7 +138,6 @@ def verify_get_response(status, expected_schema):
assert status["versions"] != []

assert status["content_settings"] is not None
assert status["content_settings"]["content_origin"] is not None
assert status["content_settings"]["content_path_prefix"] is not None

assert status["storage"]["used"] is not None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ def test_content_directory_listing(
]:
file_distribution_factory(base_path=base_path + path, content_guard=content_guard)

content_origin = pulp_status.content_settings.content_origin
if not content_origin:
content_origin = "https://pulp"
#content_origin = "http://localhost:5001"
base_url = urljoin(
pulp_status.content_settings.content_origin,
content_origin,
pulp_status.content_settings.content_path_prefix,
)
if pulp_settings.DOMAIN_ENABLED:
Expand All @@ -58,7 +62,7 @@ def test_content_directory_listing(

# Assert that not using a trailing slash on the root returns a 301
base_url = urljoin(
pulp_status.content_settings.content_origin,
content_origin,
pulp_status.content_settings.content_path_prefix,
)
if pulp_settings.DOMAIN_ENABLED:
Expand Down

0 comments on commit 421a917

Please sign in to comment.