Skip to content

Commit

Permalink
Fix content-disposition filename for tarball (distributed-system-anal…
Browse files Browse the repository at this point in the history
…ysis#3547)

* Fix content-disposition filename for tarball

PBENCH-1268

The content-disposition filename for the tarball was generated using the base
dataset name without the canonical ".tar.xz" suffix. Fix it, and validate the
expected response header in the functional test.
  • Loading branch information
dbutenhof authored Sep 5, 2023
1 parent d6ea9d0 commit 4fd01eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pbench/server/cache_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ def get_inventory(self, path: str) -> Optional[JSONOBJECT]:
"""
if not path:
info = {
"name": self.name,
"name": self.tarball_path.name,
"type": CacheType.FILE,
"stream": Inventory(self.tarball_path.open("rb"), None),
}
Expand Down
14 changes: 14 additions & 0 deletions lib/pbench/test/functional/server/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,20 @@ def read_metadata(response: Response) -> JSONOBJECT:
meta = read_metadata(response)
assert meta == dataset.metadata["dataset.metalog"]

# Test that the content-disposition header has the proper full
# filename for the tarball itself.
response = server_client.get(
API.DATASETS_INVENTORY,
{"dataset": dataset.resource_id, "target": ""},
)

# Werkzeug quotes filenames it thinks might be "suspect"; rather
# than try to reverse engineer the logic, check it piecemeal.
assert response.headers["content-disposition"].startswith(
"attachment; filename="
)
assert f"{dataset.name}.tar.xz" in response.headers["content-disposition"]


class TestUpdate:
@pytest.mark.dependency(name="publish", depends=["index"], scope="session")
Expand Down

0 comments on commit 4fd01eb

Please sign in to comment.