33import datetime
44from zoneinfo import ZoneInfo
55
6+ import pytest
67import vws_auth_tools
78from freezegun import freeze_time
89
@@ -36,7 +37,8 @@ def test_rfc_1123_date() -> None:
3637 assert result == "Thu, 05 Feb 2015 14:55:12 GMT"
3738
3839
39- def test_authorization_header () -> None :
40+ @pytest .mark .parametrize ("content" , [b"some_bytes" , "some_bytes" ])
41+ def test_authorization_header (content : bytes | str ) -> None :
4042 """The Authorization header is constructed as documented.
4143
4244 This example has been run on known-working code and so any refactor should
@@ -46,7 +48,6 @@ def test_authorization_header() -> None:
4648 # Ignore "Possible hardcoded password" as it is appropriate here.
4749 secret_key = "my_secret_key" # noqa: S105
4850 method = "HTTPMETHOD"
49- content = b"some_bytes"
5051 content_type = "some/content/type"
5152 date = "some_date_string"
5253 request_path = "/foo"
@@ -62,3 +63,29 @@ def test_authorization_header() -> None:
6263 )
6364
6465 assert result == "VWS my_access_key:8Uy6SKuO5sSBY2X8/znlPFmDF/k="
66+
67+
68+ @pytest .mark .parametrize ("content" , [b"" , None ])
69+ def test_authorization_header_none_content (content : bytes | None ) -> None :
70+ """
71+ The Authorization header is the same whether the content is None or b"".
72+ """
73+ access_key = "my_access_key"
74+ # Ignore "Possible hardcoded password" as it is appropriate here.
75+ secret_key = "my_secret_key" # noqa: S105
76+ method = "HTTPMETHOD"
77+ content_type = "some/content/type"
78+ date = "some_date_string"
79+ request_path = "/foo"
80+
81+ result = vws_auth_tools .authorization_header (
82+ access_key = access_key ,
83+ secret_key = secret_key ,
84+ method = method ,
85+ content = content ,
86+ content_type = content_type ,
87+ date = date ,
88+ request_path = request_path ,
89+ )
90+
91+ assert result == "VWS my_access_key:XXvKyRyMkwS8/1P1WLQ0duqNpKs="
0 commit comments