diff --git a/awscurl/awscurl.py b/awscurl/awscurl.py index 5b662d8..9f03493 100755 --- a/awscurl/awscurl.py +++ b/awscurl/awscurl.py @@ -12,6 +12,7 @@ import sys import re +from typing import Dict import urllib from urllib.parse import quote @@ -156,7 +157,7 @@ def remove_default_port(parsed_url): # pylint: disable=too-many-arguments,too-many-locals def task_1_create_a_canonical_request( query, - headers, + headers: Dict, port, host, amzdate, @@ -187,6 +188,7 @@ def task_1_create_a_canonical_request( # If the host was specified in the HTTP header, ensure that the canonical # headers are set accordingly + headers = requests.structures.CaseInsensitiveDict(headers) if 'host' in headers: fullhost = headers['host'] else: diff --git a/tests/stages_test.py b/tests/stages_test.py index 954b036..7682dd1 100644 --- a/tests/stages_test.py +++ b/tests/stages_test.py @@ -3,6 +3,8 @@ Test cases for seprate header calculation stages. """ +import json + from unittest import TestCase from awscurl.awscurl import ( @@ -25,7 +27,7 @@ def test_task_1_create_a_canonical_request(self): """ canonical_request, payload_hash, signed_headers = task_1_create_a_canonical_request( query="Action=DescribeInstances&Version=2013-10-15", - headers="{'Content-Type': 'application/json', 'Accept': 'application/xml'}", + headers=json.loads('{"Content-Type": "application/json", "Accept": "application/xml"}'), port=None, host="ec2.amazonaws.com", amzdate="20190921T022008Z", @@ -52,7 +54,7 @@ def test_task_1_create_a_canonical_request_url_encode_querystring(self): """ canonical_request, payload_hash, signed_headers = task_1_create_a_canonical_request( query="arg1=true&arg3=c,b,a&arg2=false&noEncoding=ABC-abc_1.23~tilde/slash", - headers="{'Content-Type': 'application/json', 'Accept': 'application/xml'}", + headers=json.loads('{"Content-Type": "application/json", "Accept": "application/xml"}'), port=None, host="my-gateway-id.execute-api.us-east-1.amazonaws.com", amzdate="20190921T022008Z",