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:
258258 self .set_header ("Content-Type" , 'application/json' )
259259
260260 @web .authenticated
261- # @authorised TODO: I can't think why we would want to authorise this
262261 def get (self ):
263262 user_info = {
264263 ** self .current_user .__dict__ ,
@@ -281,6 +280,13 @@ def get(self):
281280 user_info ['mode' ] = 'single user'
282281 else :
283282 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+
284290 self .write (json .dumps (user_info ))
285291
286292
Original file line number Diff line number Diff line change 1515
1616from functools import partial
1717from getpass import getuser
18+ import json
1819from unittest import mock
1920from unittest .mock import MagicMock
2021import pytest
@@ -120,3 +121,19 @@ def test_assert_callback_handler_gets_called(self):
120121 self .io_loop .run_sync (handler .open ,
121122 get_async_test_timeout ())
122123 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