3
3
import datetime
4
4
from zoneinfo import ZoneInfo
5
5
6
+ import pytest
6
7
import vws_auth_tools
7
8
from freezegun import freeze_time
8
9
@@ -36,7 +37,8 @@ def test_rfc_1123_date() -> None:
36
37
assert result == "Thu, 05 Feb 2015 14:55:12 GMT"
37
38
38
39
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 :
40
42
"""The Authorization header is constructed as documented.
41
43
42
44
This example has been run on known-working code and so any refactor should
@@ -46,7 +48,6 @@ def test_authorization_header() -> None:
46
48
# Ignore "Possible hardcoded password" as it is appropriate here.
47
49
secret_key = "my_secret_key" # noqa: S105
48
50
method = "HTTPMETHOD"
49
- content = b"some_bytes"
50
51
content_type = "some/content/type"
51
52
date = "some_date_string"
52
53
request_path = "/foo"
@@ -62,3 +63,29 @@ def test_authorization_header() -> None:
62
63
)
63
64
64
65
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