Skip to content

Commit 936caa0

Browse files
committed
fix tests
1 parent 76c2f2b commit 936caa0

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

app/src/test_validate.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ def test_validate_timestamp_valid():
2525
"""expected timestamp"""
2626
headers = {"x-timestamp": str(int(time.time()))}
2727
request_body = b""
28-
json_data = {}
2928

30-
validator = ValidateRequest(headers, json_data, request_body)
29+
validator = ValidateRequest(headers, request_body)
3130
try:
3231
validator.validate_timestamp()
3332
except ValueError:
@@ -38,9 +37,8 @@ def test_validate_timestamp_missing():
3837
"""no timestamp"""
3938
headers = {}
4039
request_body = b""
41-
json_data = {}
4240

43-
validator = ValidateRequest(headers, json_data, request_body)
41+
validator = ValidateRequest(headers, request_body)
4442
with pytest.raises(ValueError, match="missing x-timestamp in header"):
4543
validator.validate_timestamp()
4644

@@ -49,9 +47,8 @@ def test_validate_timestamp_invalid_format():
4947
"""not a real time stamp"""
5048
headers = {"x-timestamp": "invalid-timestamp"}
5149
request_body = b""
52-
json_data = {}
5350

54-
validator = ValidateRequest(headers, json_data, request_body)
51+
validator = ValidateRequest(headers, request_body)
5552
with pytest.raises(
5653
ValueError, match="expected x-timestamp to be epoch int"
5754
):
@@ -63,9 +60,8 @@ def test_validate_timestamp_out_of_range():
6360
future_timestamp = int(time.time()) + 1000
6461
headers = {"x-timestamp": str(future_timestamp)}
6562
request_body = b""
66-
json_data = {}
6763

68-
validator = ValidateRequest(headers, json_data, request_body)
64+
validator = ValidateRequest(headers, request_body)
6965
with pytest.raises(
7066
ValueError, match="Request is too old or too far in the future"
7167
):
@@ -80,10 +76,9 @@ def test_validate_signature_valid():
8076
"x-timestamp": timestamp,
8177
"x-signature": generate_signature(SECRET_KEY, request_body, timestamp),
8278
}
83-
json_data = {}
8479

8580
with patch.dict("os.environ", {"SECRET_KEY": SECRET_KEY}):
86-
validator = ValidateRequest(headers, json_data, request_body)
81+
validator = ValidateRequest(headers, request_body)
8782
try:
8883
validator.validate_signature()
8984
except ValueError:
@@ -95,9 +90,8 @@ def test_validate_signature_missing():
9590
timestamp = str(int(time.time()))
9691
request_body = b"test body"
9792
headers = {"x-timestamp": timestamp}
98-
json_data = {}
9993

100-
validator = ValidateRequest(headers, json_data, request_body)
94+
validator = ValidateRequest(headers, request_body)
10195
with pytest.raises(ValueError, match="missing x-signature in header"):
10296
validator.validate_signature()
10397

@@ -107,10 +101,9 @@ def test_validate_signature_invalid():
107101
timestamp = str(int(time.time()))
108102
request_body = b"test body"
109103
headers = {"x-timestamp": timestamp, "x-signature": "invalid-signature"}
110-
json_data = {}
111104

112105
with patch.dict("os.environ", {"SECRET_KEY": SECRET_KEY}):
113-
validator = ValidateRequest(headers, json_data, request_body)
106+
validator = ValidateRequest(headers, request_body)
114107
with pytest.raises(ValueError, match="invalid signature"):
115108
validator.validate_signature()
116109

@@ -121,7 +114,7 @@ def test_get_container_name_valid():
121114
request_body = b""
122115
data = RequestData(container_name="test-container")
123116

124-
validator = ValidateRequest(headers, data, request_body)
125-
container_name = validator.get_container_name()
117+
validator = ValidateRequest(headers, request_body)
118+
container_name = validator.get_container_name(data)
126119

127120
assert container_name == "test-container"

0 commit comments

Comments
 (0)