22
33import hashlib
44import hmac
5+ from typing import Any
56
67from stableops .webhooks import (
78 SIGNATURE_HEADER ,
@@ -24,11 +25,11 @@ def build_header(secret: str, timestamp: int, body: str) -> str:
2425 return f"t={ timestamp } ,v1={ signature } "
2526
2627
27- def test_signature_header_constant_matches_delivery_protocol ():
28+ def test_signature_header_constant_matches_delivery_protocol () -> None :
2829 assert SIGNATURE_HEADER == "x-product-signature"
2930
3031
31- def test_valid_signature_header ():
32+ def test_valid_signature_header () -> None :
3233 secret = "whsec_test123"
3334 body = '{"type":"payment.finalized","data":{"payment_order_id":"po_123"}}'
3435
@@ -43,7 +44,7 @@ def test_valid_signature_header():
4344 assert result .reason == "valid"
4445
4546
46- def test_accepts_any_v1_signature_during_rotation ():
47+ def test_accepts_any_v1_signature_during_rotation () -> None :
4748 old_secret = "whsec_old"
4849 new_secret = "whsec_new"
4950 body = '{"type":"payment.finalized"}'
@@ -63,7 +64,7 @@ def test_accepts_any_v1_signature_during_rotation():
6364 assert result .reason == "valid"
6465
6566
66- def test_invalid_signature ():
67+ def test_invalid_signature () -> None :
6768 result = verify_webhook_signature (
6869 body = '{"type":"payment.finalized"}' ,
6970 header = f"t={ NOW } ,v1=invalid_signature" ,
@@ -75,7 +76,7 @@ def test_invalid_signature():
7576 assert result .reason == "invalid_signature"
7677
7778
78- def test_missing_header ():
79+ def test_missing_header () -> None :
7980 result = verify_webhook_signature (
8081 body = '{"type":"payment.finalized"}' ,
8182 header = "" ,
@@ -87,7 +88,7 @@ def test_missing_header():
8788 assert result .reason == "missing_header"
8889
8990
90- def test_timestamp_too_old ():
91+ def test_timestamp_too_old () -> None :
9192 result = verify_webhook_signature (
9293 body = '{"type":"payment.finalized"}' ,
9394 header = f"t={ NOW } ,v1=sig123" ,
@@ -100,7 +101,7 @@ def test_timestamp_too_old():
100101 assert result .reason == "timestamp_expired"
101102
102103
103- def test_invalid_header_format ():
104+ def test_invalid_header_format () -> None :
104105 result = verify_webhook_signature (
105106 body = '{"type":"payment.finalized"}' ,
106107 header = "t=not_a_number,v1=sig123" ,
@@ -112,30 +113,30 @@ def test_invalid_header_format():
112113 assert result .reason == "invalid_format"
113114
114115
115- def test_webhooks_api_matches_server_routes ():
116+ def test_webhooks_api_matches_server_routes () -> None :
116117 assert not hasattr (WebhooksApi , "retrieve" )
117118 assert not hasattr (WebhooksApi , "delete" )
118119 assert not hasattr (AsyncWebhooksApi , "retrieve" )
119120 assert not hasattr (AsyncWebhooksApi , "delete" )
120121
121122
122- def test_webhooks_api_exposes_delivery_and_replay_methods ():
123+ def test_webhooks_api_exposes_delivery_and_replay_methods () -> None :
123124 for name in ("replay" , "list_deliveries" , "replay_delivery" , "replay_dead_letters" ):
124125 assert hasattr (WebhooksApi , name )
125126 assert hasattr (AsyncWebhooksApi , name )
126127
127128
128129class _FakeHttp :
129- def __init__ (self , response ) :
130+ def __init__ (self , response : Any ) -> None :
130131 self .response = response
131- self .last_request = {}
132+ self .last_request : dict [ str , Any ] = {}
132133
133- def request (self , ** kwargs ) :
134+ def request (self , ** kwargs : Any ) -> Any :
134135 self .last_request = kwargs
135136 return self .response
136137
137138
138- def test_create_endpoint_forwards_redact_metadata ():
139+ def test_create_endpoint_forwards_redact_metadata () -> None :
139140 http = _FakeHttp (
140141 {
141142 "id" : "we_1" ,
@@ -159,7 +160,7 @@ def test_create_endpoint_forwards_redact_metadata():
159160 assert endpoint .redact_metadata is True
160161
161162
162- def test_list_deliveries_filters_and_parses ():
163+ def test_list_deliveries_filters_and_parses () -> None :
163164 http = _FakeHttp (
164165 {
165166 "items" : [
@@ -198,7 +199,7 @@ def test_list_deliveries_filters_and_parses():
198199 assert deliveries [0 ].payload == {"type" : "payment.finalized" }
199200
200201
201- def test_replay_dead_letters_parses_result ():
202+ def test_replay_dead_letters_parses_result () -> None :
202203 http = _FakeHttp (
203204 {
204205 "replayed" : 2 ,
0 commit comments