diff --git a/tests/helpers.py b/tests/helpers.py index 238a2d0..e4ed56a 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -40,7 +40,19 @@ def file(key): @app.route("/upload_info/") 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", diff --git a/tests/test_s3.py b/tests/test_s3.py index 7ec448b..afea516 100644 --- a/tests/test_s3.py +++ b/tests/test_s3.py @@ -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]