diff --git a/jupyterhub/apihandlers/hub.py b/jupyterhub/apihandlers/hub.py index f2bfd17e..c9df504f 100644 --- a/jupyterhub/apihandlers/hub.py +++ b/jupyterhub/apihandlers/hub.py @@ -57,8 +57,6 @@ class RootAPIHandler(APIHandler): def get(self): """GET /api/ returns info about the Hub and its API. - It is not an authenticated endpoint. - For now, it just returns the version of JupyterHub itself. """ data = {'version': __version__} @@ -66,12 +64,11 @@ class RootAPIHandler(APIHandler): class InfoAPIHandler(APIHandler): + @needs_scope('read:hub') def get(self): """GET /api/info returns detailed info about the Hub and its API. - It is not an authenticated endpoint. - - For now, it just returns the version of JupyterHub itself. + Currently, it returns information on the python version, spawner and authenticator """ def _class_info(typ): diff --git a/jupyterhub/tests/test_api.py b/jupyterhub/tests/test_api.py index c740820e..53fbb011 100644 --- a/jupyterhub/tests/test_api.py +++ b/jupyterhub/tests/test_api.py @@ -1618,14 +1618,16 @@ async def test_root_api(app): if app.internal_ssl: kwargs['cert'] = (app.internal_ssl_cert, app.internal_ssl_key) kwargs["verify"] = app.internal_ssl_ca - r = await async_requests.get(url, **kwargs) + with mock_role(app): + r = await api_request(app, bypass_proxy=True) r.raise_for_status() expected = {'version': jupyterhub.__version__} assert r.json() == expected async def test_info(app): - r = await api_request(app, 'info') + with mock_role(app): + r = await api_request(app, 'info') r.raise_for_status() data = r.json() assert data['version'] == jupyterhub.__version__ diff --git a/jupyterhub/tests/test_scopes.py b/jupyterhub/tests/test_scopes.py index 66fe7e84..db588c96 100644 --- a/jupyterhub/tests/test_scopes.py +++ b/jupyterhub/tests/test_scopes.py @@ -97,7 +97,7 @@ class MockAPIHandler: def group_thing(self, group_name): return True - @needs_scope('services') + @needs_scope('read:services') def service_thing(self, service_name): return True @@ -133,7 +133,7 @@ class MockAPIHandler: ('maybe', 'bluth2'), False, ), - (['services'], 'service_thing', ('service1',), True), + (['read:services'], 'service_thing', ('service1',), True), ( ['users!user=george', 'read:groups!group=bluths'], 'group_thing', diff --git a/jupyterhub/tests/utils.py b/jupyterhub/tests/utils.py index 8876705a..c09a7247 100644 --- a/jupyterhub/tests/utils.py +++ b/jupyterhub/tests/utils.py @@ -223,6 +223,7 @@ def get_scopes(role='admin'): 'services', 'proxy', 'shutdown', + 'read:hub', ], 'user': [ 'all',