@@ -17,11 +17,13 @@ def test_shutdown_sock_server_integration():
1717 encoded_sock_path = urlencode_unix_socket_path (sock )
1818
1919 p = subprocess .Popen (
20- ['jupyter-notebook' , '--sock=%s' % sock ],
20+ ['jupyter-notebook' , '--sock=%s' % sock , '--sock-mode=0700' ],
2121 stdout = subprocess .PIPE , stderr = subprocess .PIPE
2222 )
2323
24+ complete = False
2425 for line in iter (p .stderr .readline , b'' ):
26+ print (line )
2527 if url in line :
2628 complete = True
2729 break
@@ -30,8 +32,8 @@ def test_shutdown_sock_server_integration():
3032
3133 assert encoded_sock_path .encode () in subprocess .check_output (['jupyter-notebook' , 'list' ])
3234
33- # Ensure default umask is properly applied.
34- assert stat .S_IMODE (os .lstat (sock ).st_mode ) == 0o600
35+ # Ensure umask is properly applied.
36+ assert stat .S_IMODE (os .lstat (sock ).st_mode ) == 0o700
3537
3638 try :
3739 subprocess .check_output (['jupyter-notebook' , 'stop' ], stderr = subprocess .STDOUT )
@@ -49,6 +51,29 @@ def test_shutdown_sock_server_integration():
4951 p .wait ()
5052
5153
54+ def test_sock_server_validate_sockmode_type ():
55+ try :
56+ subprocess .check_output (
57+ ['jupyter-notebook' , '--sock=/tmp/nonexistent' , '--sock-mode=badbadbad' ],
58+ stderr = subprocess .STDOUT
59+ )
60+ except subprocess .CalledProcessError as e :
61+ assert 'badbadbad' in e .output .decode ()
62+ else :
63+ raise AssertionError ('expected execution to fail due to validation of --sock-mode param' )
64+
65+
66+ def test_sock_server_validate_sockmode_accessible ():
67+ try :
68+ subprocess .check_output (
69+ ['jupyter-notebook' , '--sock=/tmp/nonexistent' , '--sock-mode=0444' ],
70+ stderr = subprocess .STDOUT
71+ )
72+ except subprocess .CalledProcessError as e :
73+ assert '0444' in e .output .decode ()
74+ else :
75+ raise AssertionError ('expected execution to fail due to validation of --sock-mode param' )
76+
5277
5378def _ensure_stopped (check_msg = 'There are no running servers' ):
5479 try :
0 commit comments