Skip to content

Commit 189da4a

Browse files
committed
Add content-disposition header assertions
closes #828 Required PR: pulp/pulpcore#3245
1 parent 6dd11e3 commit 189da4a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGES/828.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added content-disposition header assertions when content is consumed from an object storage.

pulp_file/tests/functional/api/test_download_policies.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
from pulpcore.client.pulp_file import FileFilePublication, RepositorySyncURL
1818

1919

20+
OBJECT_STORAGES = (
21+
"storages.backends.s3boto3.S3Boto3Storage",
22+
"storages.backends.azure_storage.AzureStorage",
23+
)
24+
25+
2026
def _do_range_request_download_and_assert(url, range_header, expected_bytes):
2127
file1 = download_file(url, headers=range_header)
2228
file2 = download_file(url, headers=range_header)
@@ -111,6 +117,11 @@ def test_download_policy(
111117
actual_checksum = hashlib.sha256(downloaded_file.body).hexdigest()
112118
expected_checksum = content_unit[1]
113119
assert expected_checksum == actual_checksum
120+
if download_policy == "immediate" and settings.DEFAULT_FILE_STORAGE in OBJECT_STORAGES:
121+
content_disposition = downloaded_file.response_obj.headers.get("Content-Disposition")
122+
assert content_disposition is not None
123+
filename = content_unit[0]
124+
assert f"attachment;filename={filename}" == content_disposition
114125

115126
# Assert proper download with range requests smaller than one chunk of downloader
116127
range_header = {"Range": "bytes=1048586-1049586"}

0 commit comments

Comments
 (0)