Skip to content

Commit

Permalink
tests for overridden max_content_length
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-m-mclaughlin committed Sep 6, 2024
1 parent 4f88ae0 commit 0817a1a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,19 @@ def file(key):
@app.route("/upload_info/<path:key>")
def upload_info(key):
try:
upload_info = annex.get_upload_info(key)
known_query_args = {
"max_content_length": flask.request.args.get(
"max_content_length", type=int
)
}
upload_info = annex.get_upload_info(
key,
**{
k: v
for k, v in known_query_args.items()
if k in flask.request.args
},
)
except NotImplementedError:
upload_info = {
"method": "PUT",
Expand Down
12 changes: 12 additions & 0 deletions tests/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ def test_get_upload_info_max_content_length(self, app, client):
conditions = get_policy(upload_info)["conditions"]
self.assert_app_config_content_length_range(conditions)

def test_get_upload_info_overridden_max_content_length(self, app, client):
upload_info = get_upload_info(
client, "foo/qux.txt", query_string={"max_content_length": 500}
)
self.assert_upload_info_url_method(upload_info)

conditions = get_policy(upload_info)["conditions"]
self.assert_overridden_content_length_range(conditions)

def assert_overridden_content_length_range(self, conditions):
assert get_condition(conditions, "content-length-range") == [0, 500]

def assert_app_config_content_length_range(self, conditions):
assert get_condition(conditions, "content-length-range") == [0, 100]

Expand Down

0 comments on commit 0817a1a

Please sign in to comment.