@@ -68,7 +68,7 @@ def callback(update):
6868 streaming_node .write (new_arr )
6969
7070 # Wait for all messages to be received
71- assert received_event .wait (timeout = 5 .0 ), "Timeout waiting for messages"
71+ assert received_event .wait (timeout = 10 .0 ), "Timeout waiting for messages"
7272
7373 # Verify all updates received in order
7474 assert len (received ) == 3
@@ -139,7 +139,7 @@ def callback(update):
139139 streaming_node .write (new_arr )
140140
141141 # Wait for messages to be received
142- assert received_event .wait (timeout = 5 .0 ), "Timeout waiting for messages"
142+ assert received_event .wait (timeout = 10 .0 ), "Timeout waiting for messages"
143143
144144 # Should only receive the 2 new updates (not the first one)
145145 assert len (received ) == 2
@@ -196,7 +196,7 @@ def callback(update):
196196 streaming_node .write (new_arr )
197197
198198 # Wait for all messages to be received
199- assert received_event .wait (timeout = 5 .0 ), "Timeout waiting for messages"
199+ assert received_event .wait (timeout = 10 .0 ), "Timeout waiting for messages"
200200
201201 # Should receive: initial array + first update + 2 new updates = 4 total
202202 assert len (received ) == 4
@@ -253,7 +253,7 @@ def child_metadata_updated_cb(update):
253253 time .sleep (0.1 )
254254 unique_key = f"{ uuid .uuid4 ().hex [:8 ]} "
255255 uploaded_nodes .append (client .create_container (unique_key ))
256- assert created_3 .wait (timeout = 5 .0 ), "Timeout waiting for messages"
256+ assert created_3 .wait (timeout = 10 .0 ), "Timeout waiting for messages"
257257 downloaded_nodes = list (client .values ())
258258 for up , streamed , down in zip (uploaded_nodes , streamed_nodes , downloaded_nodes ):
259259 pass
@@ -262,7 +262,7 @@ def child_metadata_updated_cb(update):
262262
263263 assert len (child_metadata_updated_updates ) == 0
264264 client .values ().last ().update_metadata ({"color" : "blue" })
265- assert received_event .wait (timeout = 5 .0 ), "Timeout waiting for messages"
265+ assert received_event .wait (timeout = 10 .0 ), "Timeout waiting for messages"
266266 assert len (child_metadata_updated_updates ) == 1
267267
268268
@@ -283,7 +283,7 @@ def callback(sub):
283283 sub .stream_closed .add_callback (callback )
284284 assert not event .is_set ()
285285 x .close_stream ()
286- assert event .wait (timeout = 5 .0 ), "Timeout waiting for messages"
286+ assert event .wait (timeout = 10 .0 ), "Timeout waiting for messages"
287287
288288
289289def test_subscribe_to_disconnected (
@@ -305,7 +305,7 @@ def callback(sub):
305305 sub .disconnected .add_callback (callback )
306306 assert not event .is_set ()
307307 sub .disconnect ()
308- assert event .wait (timeout = 5 .0 ), "Timeout waiting for messages"
308+ assert event .wait (timeout = 10 .0 ), "Timeout waiting for messages"
309309
310310 # If the writer closes the stream, the client is disconnected.
311311 with x .subscribe ().start_in_thread () as sub :
@@ -317,7 +317,7 @@ def callback(sub):
317317 sub .disconnected .add_callback (callback )
318318 assert not event .is_set ()
319319 x .close_stream ()
320- assert event .wait (timeout = 5 .0 ), "Timeout waiting for messages"
320+ assert event .wait (timeout = 10 .0 ), "Timeout waiting for messages"
321321
322322
323323def test_subscribe_to_array_registered_with_patch (tiled_websocket_context , tmp_path ):
@@ -412,7 +412,7 @@ def on_child_created(update):
412412 content = safe_json_dump ({"data_source" : updated_data_source }),
413413 params = params ,
414414 ).raise_for_status ()
415- assert event .wait (timeout = 5 .0 ), "Timeout waiting for messages"
415+ assert event .wait (timeout = 10 .0 ), "Timeout waiting for messages"
416416 x .close_stream ()
417417 client .close_stream ()
418418 x .refresh ()
@@ -503,7 +503,7 @@ def on_child_created(update):
503503 }
504504 ),
505505 ).raise_for_status ()
506- assert event .wait (timeout = 5 .0 ), "Timeout waiting for messages"
506+ assert event .wait (timeout = 10 .0 ), "Timeout waiting for messages"
507507 x .close_stream ()
508508 client .close_stream ()
509509 x .refresh ()
@@ -533,12 +533,12 @@ def collect(update):
533533 sub = client [key ].subscribe ()
534534 sub .new_data .add_callback (collect )
535535 with sub .start_in_thread (1 ):
536- assert event .wait (timeout = 5 .0 ), "Timeout waiting for messages"
536+ assert event .wait (timeout = 10 .0 ), "Timeout waiting for messages"
537537 actual = updates [0 ].data ()
538538 assert_frame_equal (actual , df1 )
539539 event .clear ()
540540 x .write (df2 )
541- assert event .wait (timeout = 5 .0 ), "Timeout waiting for messages"
541+ assert event .wait (timeout = 10 .0 ), "Timeout waiting for messages"
542542 assert not updates [1 ].append
543543 actual_updated = updates [1 ].data ()
544544 assert_frame_equal (actual_updated , df2 )
@@ -565,14 +565,14 @@ def collect(update):
565565 sub .new_data .add_callback (collect )
566566 with sub .start_in_thread (1 ):
567567 x .append_partition (0 , table1 )
568- assert event .wait (timeout = 5 .0 ), "Timeout waiting for messages"
568+ assert event .wait (timeout = 10 .0 ), "Timeout waiting for messages"
569569 assert updates [0 ].append
570570 streamed1 = updates [0 ].data ()
571571 streamed1_pyarrow = pyarrow .Table .from_pandas (streamed1 , preserve_index = False )
572572 assert streamed1_pyarrow == table1
573573 event .clear ()
574574 x .append_partition (0 , table2 )
575- assert event .wait (timeout = 5 .0 ), "Timeout waiting for messages"
575+ assert event .wait (timeout = 10 .0 ), "Timeout waiting for messages"
576576 assert updates [1 ].append
577577 streamed2 = updates [1 ].data ()
578578 streamed2_pyarrow = pyarrow .Table .from_pandas (streamed2 , preserve_index = False )
@@ -641,3 +641,51 @@ def __call__(self, timeout=None):
641641
642642 # Restore original recv before disconnecting to avoid cleanup issues
643643 subscription ._websocket .recv = original_recv
644+
645+
646+ def test_subscribe_no_api_key_rejected (tiled_websocket_context ):
647+ "Private server does not allow anonymous user to subscribe."
648+ context = tiled_websocket_context
649+ client = from_context (context )
650+
651+ arr = np .arange (10 )
652+ streaming_node = client .write_array (arr , key = "test_stream_immediate" )
653+
654+ received_event = threading .Event ()
655+
656+ def callback (update ):
657+ "Set event once any update has been received."
658+ received_event .set ()
659+
660+ # Any further requests will be unauthenticated.
661+ context .api_key = None
662+
663+ subscription = streaming_node .subscribe ()
664+ subscription .new_data .add_callback (callback )
665+
666+ with pytest .raises (WebSocketDenialResponse ):
667+ subscription .start (0 )
668+
669+
670+ def test_subscribe_no_api_key_public (tiled_websocket_context_public ):
671+ "Public server allows anonymous user to subscribe."
672+ context = tiled_websocket_context_public
673+ client = from_context (context )
674+
675+ arr = np .arange (10 )
676+ streaming_node = client .write_array (arr , key = "test_stream_immediate" )
677+
678+ received_event = threading .Event ()
679+
680+ def callback (update ):
681+ "Set event once any update has been received."
682+ received_event .set ()
683+
684+ # Any further requests will be unauthenticated.
685+ context .api_key = None
686+
687+ subscription = streaming_node .subscribe ()
688+ subscription .new_data .add_callback (callback )
689+
690+ with subscription .start_in_thread (0 ):
691+ assert received_event .wait (timeout = 10.0 ), "Timeout waiting for messages"
0 commit comments