diff --git a/moto/moto_server/werkzeug_app.py b/moto/moto_server/werkzeug_app.py index 14f855174..234a74d47 100644 --- a/moto/moto_server/werkzeug_app.py +++ b/moto/moto_server/werkzeug_app.py @@ -201,7 +201,7 @@ class DomainDispatcherApplication: finally: if body: # We've consumed the body = need to reset it - environ["wsgi.input"] = io.StringIO(body) + environ["wsgi.input"] = io.BytesIO(body.encode("utf-8")) return body def get_service_from_body( diff --git a/tests/test_core/test_account_id_resolution.py b/tests/test_core/test_account_id_resolution.py index d5d5b56bd..b4df22532 100644 --- a/tests/test_core/test_account_id_resolution.py +++ b/tests/test_core/test_account_id_resolution.py @@ -57,6 +57,7 @@ class TestAccountIdResolution: headers = { "Authorization": "AWS4-HMAC-SHA256 Credential=abcd/20010101/us-east-2/sts/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=...", "Content-Length": f"{len(data)}", + "Content-Type": "application/x-www-form-urlencoded", } headers.update(extra_headers or {}) return requests.post(f"{BASE_URL}", headers=headers, data=data) diff --git a/tests/test_moto_api/recorder/__init__.py b/tests/test_moto_api/recorder/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/test_moto_api/recorder/test_recorder.py b/tests/test_moto_api/recorder/test_recorder.py index f716b3d63..5eef59190 100644 --- a/tests/test_moto_api/recorder/test_recorder.py +++ b/tests/test_moto_api/recorder/test_recorder.py @@ -1,3 +1,4 @@ +import base64 import boto3 import json import requests @@ -81,8 +82,13 @@ class TestRecorder(TestCase): content = json.loads(self._download_recording()) - content.should.have.key("body").should.contain("Action=RunInstances") - content.should.have.key("body").should.contain(f"ImageId={EXAMPLE_AMI_ID}") + if content.get("body_encoded"): + body = base64.b64decode(content.get("body")).decode("ascii") + else: + body = content["body"] + + body.should.contain("Action=RunInstances") + body.should.contain(f"ImageId={EXAMPLE_AMI_ID}") def test_multiple_services(self): self._start_recording() diff --git a/tests/test_s3/test_server.py b/tests/test_s3/test_server.py index 3f60fb831..a971b4ec3 100644 --- a/tests/test_s3/test_server.py +++ b/tests/test_s3/test_server.py @@ -36,12 +36,8 @@ def test_s3_server_get(): res.data.should.contain(b"ListAllMyBucketsResult") -@pytest.mark.parametrize("key_name", ["bar_baz", "baz bar"]) +@pytest.mark.parametrize("key_name", ["bar_baz", "bar+baz", "baz bar"]) def test_s3_server_bucket_create(key_name): - # Very similar test in test_s3.py::test_get_object_versions_with_prefix - # That test also includes a key containing a +, such as 'baz+bar' - # We cannot test that example here, because Werkzeug (as of 2.3.0) will helpfully normalize that to `baz bar` - # TODO: re-enable this key-name if/when we ever replace Werkzeug test_client = authenticated_client() res = test_client.put("/", "http://foobaz.localhost:5000/")