Skip to content

Commit 350ef03

Browse files
author
Michael Brewer
committed
test(data-classes): add json_body test case for isBase64Encoded
1 parent 9e8cedc commit 350ef03

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: tests/functional/test_data_classes.py

+12
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,18 @@ def test_base_proxy_event_decode_body_encoded_true():
10371037
assert event.decoded_body == data
10381038

10391039

1040+
def test_base_proxy_event_json_body_with_base64_encoded_data():
1041+
# GIVEN a base64 encoded json body
1042+
data = {"message": "Foo"}
1043+
data_str = json.dumps(data)
1044+
encoded_data = base64.b64encode(data_str.encode()).decode()
1045+
event = BaseProxyEvent({"body": encoded_data, "isBase64Encoded": True})
1046+
1047+
# WHEN calling json_body
1048+
# THEN then base64 decode and json load
1049+
assert event.json_body == data
1050+
1051+
10401052
def test_kinesis_stream_event():
10411053
event = KinesisStreamEvent(load_event("kinesisStreamEvent.json"))
10421054

0 commit comments

Comments
 (0)