File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -318,3 +318,19 @@ def test_timeout(self, mock_post):
318318 eq_ (mock_post .call_args [1 ].get ('timeout' ), 5.2 )
319319 webpush (subscription_info , timeout = 10.001 )
320320 eq_ (mock_post .call_args [1 ].get ('timeout' ), 10.001 )
321+
322+ @patch ("requests.Session" )
323+ def test_send_using_requests_session (self , mock_session ):
324+ subscription_info = self ._gen_subscription_info ()
325+ headers = {"Crypto-Key" : "pre-existing" ,
326+ "Authentication" : "bearer vapid" }
327+ data = "Mary had a little lamb"
328+ WebPusher (subscription_info , requests_session = mock_session ).send (data , headers )
329+ eq_ (subscription_info .get ('endpoint' ), mock_session .post .call_args [0 ][0 ])
330+ pheaders = mock_session .post .call_args [1 ].get ('headers' )
331+ eq_ (pheaders .get ('ttl' ), '0' )
332+ ok_ ('encryption' in pheaders )
333+ eq_ (pheaders .get ('AUTHENTICATION' ), headers .get ('Authentication' ))
334+ ckey = pheaders .get ('crypto-key' )
335+ ok_ ('pre-existing' in ckey )
336+ eq_ (pheaders .get ('content-encoding' ), 'aesgcm' )
You can’t perform that action at this time.
0 commit comments