@@ -100,9 +100,20 @@ def test_streaming_response_list(self, client: Increase) -> None:
100100
101101 assert cast (Any , response .is_closed ) is True
102102
103- def test_method_unwrap (self , client : Increase ) -> None :
104- key = b"secret"
105- hook = standardwebhooks .Webhook (key )
103+ @pytest .mark .parametrize (
104+ "client_opt,method_opt" ,
105+ [
106+ ("whsec_c2VjcmV0Cg==" , None ),
107+ ("wrong" , b"secret\n " ),
108+ ("wrong" , "whsec_c2VjcmV0Cg==" ),
109+ (None , b"secret\n " ),
110+ (None , "whsec_c2VjcmV0Cg==" ),
111+ ],
112+ )
113+ def test_method_unwrap (self , client : Increase , client_opt : str | None , method_opt : str | bytes | None ) -> None :
114+ hook = standardwebhooks .Webhook (b"secret\n " )
115+
116+ client = client .with_options (webhook_secret = client_opt )
106117
107118 data = """{"id":"event_001dzz0r20rzr4zrhrr1364hy80","associated_object_id":"account_in71c4amph0vgo2qllky","associated_object_type":"account","category":"account.created","created_at":"2020-01-31T23:59:59Z","type":"event"}"""
108119 msg_id = "1"
@@ -115,7 +126,7 @@ def test_method_unwrap(self, client: Increase) -> None:
115126 }
116127
117128 try :
118- _ = client .events .unwrap (data , headers = headers , key = key )
129+ _ = client .events .unwrap (data , headers = headers , key = method_opt )
119130 except standardwebhooks .WebhookVerificationError as e :
120131 raise AssertionError ("Failed to unwrap valid webhook" ) from e
121132
@@ -126,7 +137,7 @@ def test_method_unwrap(self, client: Increase) -> None:
126137 ]
127138 for bad_header in bad_headers :
128139 with pytest .raises (standardwebhooks .WebhookVerificationError ):
129- _ = client .events .unwrap (data , headers = bad_header , key = key )
140+ _ = client .events .unwrap (data , headers = bad_header , key = method_opt )
130141
131142
132143class TestAsyncEvents :
@@ -213,9 +224,22 @@ async def test_streaming_response_list(self, async_client: AsyncIncrease) -> Non
213224
214225 assert cast (Any , response .is_closed ) is True
215226
216- def test_method_unwrap (self , client : Increase ) -> None :
217- key = b"secret"
218- hook = standardwebhooks .Webhook (key )
227+ @pytest .mark .parametrize (
228+ "client_opt,method_opt" ,
229+ [
230+ ("whsec_c2VjcmV0Cg==" , None ),
231+ ("wrong" , b"secret\n " ),
232+ ("wrong" , "whsec_c2VjcmV0Cg==" ),
233+ (None , b"secret\n " ),
234+ (None , "whsec_c2VjcmV0Cg==" ),
235+ ],
236+ )
237+ def test_method_unwrap (
238+ self , async_client : Increase , client_opt : str | None , method_opt : str | bytes | None
239+ ) -> None :
240+ hook = standardwebhooks .Webhook (b"secret\n " )
241+
242+ async_client = async_client .with_options (webhook_secret = client_opt )
219243
220244 data = """{"id":"event_001dzz0r20rzr4zrhrr1364hy80","associated_object_id":"account_in71c4amph0vgo2qllky","associated_object_type":"account","category":"account.created","created_at":"2020-01-31T23:59:59Z","type":"event"}"""
221245 msg_id = "1"
@@ -228,7 +252,7 @@ def test_method_unwrap(self, client: Increase) -> None:
228252 }
229253
230254 try :
231- _ = client .events .unwrap (data , headers = headers , key = key )
255+ _ = async_client .events .unwrap (data , headers = headers , key = method_opt )
232256 except standardwebhooks .WebhookVerificationError as e :
233257 raise AssertionError ("Failed to unwrap valid webhook" ) from e
234258
@@ -239,4 +263,4 @@ def test_method_unwrap(self, client: Increase) -> None:
239263 ]
240264 for bad_header in bad_headers :
241265 with pytest .raises (standardwebhooks .WebhookVerificationError ):
242- _ = client .events .unwrap (data , headers = bad_header , key = key )
266+ _ = async_client .events .unwrap (data , headers = bad_header , key = method_opt )
0 commit comments