@@ -377,6 +377,38 @@ def test_handle_connect(self, eio):
377377 _run (s ._handle_eio_message ('456' , '0' ))
378378 assert s .manager .initialize .call_count == 1
379379
380+ def test_handle_connect_with_auth (self , eio ):
381+ eio .return_value .send = AsyncMock ()
382+ s = asyncio_server .AsyncServer ()
383+ s .manager .initialize = mock .MagicMock ()
384+ handler = mock .MagicMock ()
385+ s .on ('connect' , handler )
386+ _run (s ._handle_eio_connect ('123' , 'environ' ))
387+ _run (s ._handle_eio_message ('123' , '0{"token":"abc"}' ))
388+ assert s .manager .is_connected ('1' , '/' )
389+ handler .assert_called_once_with ('1' , 'environ' , {'token' : 'abc' })
390+ s .eio .send .mock .assert_called_once_with ('123' , '0{"sid":"1"}' )
391+ assert s .manager .initialize .call_count == 1
392+ _run (s ._handle_eio_connect ('456' , 'environ' ))
393+ _run (s ._handle_eio_message ('456' , '0' ))
394+ assert s .manager .initialize .call_count == 1
395+
396+ def test_handle_connect_with_auth_none (self , eio ):
397+ eio .return_value .send = AsyncMock ()
398+ s = asyncio_server .AsyncServer ()
399+ s .manager .initialize = mock .MagicMock ()
400+ handler = mock .MagicMock (side_effect = [TypeError , None , None ])
401+ s .on ('connect' , handler )
402+ _run (s ._handle_eio_connect ('123' , 'environ' ))
403+ _run (s ._handle_eio_message ('123' , '0' ))
404+ assert s .manager .is_connected ('1' , '/' )
405+ handler .assert_called_with ('1' , 'environ' , None )
406+ s .eio .send .mock .assert_called_once_with ('123' , '0{"sid":"1"}' )
407+ assert s .manager .initialize .call_count == 1
408+ _run (s ._handle_eio_connect ('456' , 'environ' ))
409+ _run (s ._handle_eio_message ('456' , '0' ))
410+ assert s .manager .initialize .call_count == 1
411+
380412 def test_handle_connect_async (self , eio ):
381413 eio .return_value .send = AsyncMock ()
382414 s = asyncio_server .AsyncServer ()
0 commit comments