@@ -34,7 +34,7 @@ async def auth_callback_failure(options, expect_failure=False):
3434class TestRealtimeAuth (BaseAsyncTestCase ):
3535 async def test_auth_valid_api_key (self ):
3636 ably = await TestApp .get_ably_realtime ()
37- await ably .connection .once_async (ConnectionState .CONNECTED )
37+ await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
3838 assert ably .connection .error_reason is None
3939 response_time_ms = await ably .connection .ping ()
4040 assert response_time_ms is not None
@@ -53,7 +53,7 @@ async def test_auth_with_token_string(self):
5353 rest = await TestApp .get_ably_rest ()
5454 token_details = await rest .auth .request_token ()
5555 ably = await TestApp .get_ably_realtime (token = token_details .token )
56- await ably .connection .once_async (ConnectionState .CONNECTED )
56+ await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
5757 response_time_ms = await ably .connection .ping ()
5858 assert response_time_ms is not None
5959 assert ably .connection .error_reason is None
@@ -71,7 +71,7 @@ async def test_auth_with_token_details(self):
7171 rest = await TestApp .get_ably_rest ()
7272 token_details = await rest .auth .request_token ()
7373 ably = await TestApp .get_ably_realtime (token_details = token_details )
74- await ably .connection .once_async (ConnectionState .CONNECTED )
74+ await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
7575 response_time_ms = await ably .connection .ping ()
7676 assert response_time_ms is not None
7777 assert ably .connection .error_reason is None
@@ -93,7 +93,7 @@ async def callback(params):
9393 return token_details
9494
9595 ably = await TestApp .get_ably_realtime (auth_callback = callback )
96- await ably .connection .once_async (ConnectionState .CONNECTED )
96+ await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
9797 response_time_ms = await ably .connection .ping ()
9898 assert response_time_ms is not None
9999 assert ably .connection .error_reason is None
@@ -107,7 +107,7 @@ async def callback(params):
107107 return token_details
108108
109109 ably = await TestApp .get_ably_realtime (auth_callback = callback )
110- await ably .connection .once_async (ConnectionState .CONNECTED )
110+ await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
111111 response_time_ms = await ably .connection .ping ()
112112 assert response_time_ms is not None
113113 assert ably .connection .error_reason is None
@@ -121,7 +121,7 @@ async def callback(params):
121121 return token_details .token
122122
123123 ably = await TestApp .get_ably_realtime (auth_callback = callback )
124- await ably .connection .once_async (ConnectionState .CONNECTED )
124+ await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
125125 response_time_ms = await ably .connection .ping ()
126126 assert response_time_ms is not None
127127 assert ably .connection .error_reason is None
@@ -144,7 +144,10 @@ async def test_auth_with_auth_url_json(self):
144144 url_path = f"{ echo_url } /?type=json&body={ urllib .parse .quote_plus (token_details_json )} "
145145
146146 ably = await TestApp .get_ably_realtime (auth_url = url_path )
147- await ably .connection .once_async (ConnectionState .CONNECTED )
147+ await asyncio .wait_for (
148+ ably .connection .once_async (ConnectionState .CONNECTED ),
149+ timeout = 5 ,
150+ )
148151 response_time_ms = await ably .connection .ping ()
149152 assert response_time_ms is not None
150153 assert ably .connection .error_reason is None
@@ -156,7 +159,7 @@ async def test_auth_with_auth_url_text_plain(self):
156159 url_path = f"{ echo_url } /?type=text&body={ token_details .token } "
157160
158161 ably = await TestApp .get_ably_realtime (auth_url = url_path )
159- await ably .connection .once_async (ConnectionState .CONNECTED )
162+ await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
160163 response_time_ms = await ably .connection .ping ()
161164 assert response_time_ms is not None
162165 assert ably .connection .error_reason is None
@@ -169,7 +172,7 @@ async def test_auth_with_auth_url_post(self):
169172
170173 ably = await TestApp .get_ably_realtime (auth_url = url_path , auth_method = 'POST' ,
171174 auth_params = token_details )
172- await ably .connection .once_async (ConnectionState .CONNECTED )
175+ await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
173176 response_time_ms = await ably .connection .ping ()
174177 assert response_time_ms is not None
175178 assert ably .connection .error_reason is None
@@ -183,7 +186,7 @@ async def callback(params):
183186 return token_details .token
184187
185188 ably = await TestApp .get_ably_realtime (auth_callback = callback )
186- await ably .connection .once_async (ConnectionState .CONNECTED )
189+ await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
187190
188191 assert ably .connection .connection_manager .transport
189192 original_access_token = ably .connection .connection_manager .transport .params .get ('accessToken' )
@@ -307,7 +310,7 @@ async def callback(params):
307310 "action" : ProtocolMessageAction .AUTH ,
308311 }
309312
310- await ably .connection .once_async (ConnectionState .CONNECTED )
313+ await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
311314 auth_future = asyncio .Future ()
312315
313316 def on_update (state_change ):
@@ -334,7 +337,7 @@ async def auth_callback(_):
334337
335338 ably = await TestApp .get_ably_realtime (auth_callback = auth_callback )
336339
337- await ably .connection .once_async (ConnectionState .CONNECTED )
340+ await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
338341 original_token_details = ably .auth .token_details
339342 await ably .connection .once_async (ConnectionEvent .UPDATE )
340343 assert ably .auth .token_details is not original_token_details
@@ -496,7 +499,7 @@ async def callback(params):
496499 }
497500 }
498501
499- await ably .connection .once_async (ConnectionState .CONNECTED )
502+ await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
500503 original_token_details = ably .auth .token_details
501504 assert ably .connection .connection_manager .transport
502505 await ably .connection .connection_manager .transport .on_protocol_message (msg )
@@ -511,7 +514,7 @@ async def test_renew_token_no_renew_means_provided_upon_disconnection(self):
511514
512515 ably = await TestApp .get_ably_realtime (token_details = token_details )
513516
514- state_change = await ably .connection .once_async (ConnectionState .CONNECTED )
517+ state_change = await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
515518 msg = {
516519 "action" : ProtocolMessageAction .DISCONNECTED ,
517520 "error" : {
@@ -544,7 +547,7 @@ async def callback(params):
544547 }
545548 }
546549
547- await ably .connection .once_async (ConnectionState .CONNECTED )
550+ await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
548551 connection_key = ably .connection .connection_details .connection_key
549552 await ably .connection .connection_manager .transport .dispose ()
550553 ably .connection .connection_manager .notify_state (ConnectionState .DISCONNECTED )
@@ -572,12 +575,12 @@ async def test_renew_token_no_renew_means_provided_on_resume(self):
572575 }
573576 }
574577
575- await ably .connection .once_async (ConnectionState .CONNECTED )
578+ await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
576579 connection_key = ably .connection .connection_details .connection_key
577580 await ably .connection .connection_manager .transport .dispose ()
578581 ably .connection .connection_manager .notify_state (ConnectionState .DISCONNECTED )
579582
580- state_change = await ably .connection .once_async (ConnectionState .CONNECTED )
583+ state_change = await asyncio . wait_for ( ably .connection .once_async (ConnectionState .CONNECTED ), timeout = 5 )
581584 assert ably .connection .connection_manager .transport .params ["resume" ] == connection_key
582585
583586 assert ably .connection .connection_manager .transport
0 commit comments