File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 1
1
from tornado .websocket import WebSocketHandler
2
+ from jupyter_server .base .handlers import JupyterHandler
2
3
import tornado
3
4
import json
4
5
5
6
6
- class CustomWebSocketHandler (WebSocketHandler ):
7
+ class CustomWebSocketHandler (JupyterHandler , WebSocketHandler ):
7
8
def open (self ):
9
+ if not self .current_user :
10
+ self .write_message (json .dumps ({"error" : "Unauthorized access" }))
11
+ self .close ()
12
+ return
8
13
self .write_message (json .dumps ({"status" : "connected" }))
9
14
self .set_nodelay (True )
10
15
# Start a periodic callback to send data every 50ms
Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ def handler_args():
20
20
with patch ("tornado.web.Application" ) as mock_application , patch (
21
21
"tornado.httputil.HTTPServerRequest"
22
22
) as mock_request :
23
+ # Mock the settings to return appropriate values
24
+ mock_settings = {
25
+ "base_url" : "/" ,
26
+ }
27
+ mock_application .settings = mock_settings
23
28
yield mock_application , mock_request
24
29
25
30
Original file line number Diff line number Diff line change @@ -26,6 +26,11 @@ def handler_args():
26
26
with patch ("tornado.web.Application" ) as mock_application , patch (
27
27
"tornado.httputil.HTTPServerRequest"
28
28
) as mock_request :
29
+ # Mock the settings to return appropriate values
30
+ mock_settings = {
31
+ "base_url" : "/" ,
32
+ }
33
+ mock_application .settings = mock_settings
29
34
yield mock_application , mock_request
30
35
31
36
You can’t perform that action at this time.
0 commit comments