File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -258,7 +258,6 @@ def set_default_headers(self) -> None:
258
258
self .set_header ("Content-Type" , 'application/json' )
259
259
260
260
@web .authenticated
261
- # @authorised TODO: I can't think why we would want to authorise this
262
261
def get (self ):
263
262
user_info = {
264
263
** self .current_user .__dict__ ,
@@ -281,6 +280,13 @@ def get(self):
281
280
user_info ['mode' ] = 'single user'
282
281
else :
283
282
user_info ['mode' ] = 'multi user'
283
+
284
+ user_info ['extensions' ] = {
285
+ y .name : y .default_url
286
+ for x in self .serverapp .extension_manager .extension_apps .values ()
287
+ for y in x if getattr (y , 'default_url' , '/' ) != '/'
288
+ }
289
+
284
290
self .write (json .dumps (user_info ))
285
291
286
292
Original file line number Diff line number Diff line change 15
15
16
16
from functools import partial
17
17
from getpass import getuser
18
+ import json
18
19
from unittest import mock
19
20
from unittest .mock import MagicMock
20
21
import pytest
@@ -120,3 +121,19 @@ def test_assert_callback_handler_gets_called(self):
120
121
self .io_loop .run_sync (handler .open ,
121
122
get_async_test_timeout ())
122
123
handler .subscription_server .handle .assert_called_once ()
124
+
125
+
126
+ @pytest .mark .integration
127
+ async def test_userprofile (
128
+ jp_fetch , cylc_uis , jp_serverapp ,
129
+ ):
130
+ """Test the userprofile endpoint."""
131
+ # patch the default_url back to how it is set in cylc.uiserver.app
132
+ cylc_uis .default_url = '/cylc'
133
+
134
+ response = await jp_fetch ('cylc' , 'userprofile' )
135
+ user_profile = json .loads (response .body .decode ())
136
+ assert user_profile ['username' ] == getuser ()
137
+ assert user_profile ['owner' ] == getuser ()
138
+ assert 'read' in user_profile ['permissions' ]
139
+ assert 'cylc' in user_profile ['extensions' ]
You can’t perform that action at this time.
0 commit comments