From 2c968ec38885d5d6193eb9dd0992a577818a1b88 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Tue, 28 Nov 2023 09:25:00 +0100 Subject: [PATCH] fix tests --- tljh-plasma/tljh_plasma/permissions.py | 6 +++--- tljh-plasma/tljh_plasma/tests/conftest.py | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/tljh-plasma/tljh_plasma/permissions.py b/tljh-plasma/tljh_plasma/permissions.py index aa79496..5dde581 100644 --- a/tljh-plasma/tljh_plasma/permissions.py +++ b/tljh-plasma/tljh_plasma/permissions.py @@ -7,7 +7,7 @@ from jupyterhub.apihandlers import APIHandler from jupyterhub.handlers.base import BaseHandler from jupyterhub.orm import Base, Column, Integer, Unicode -from jupyterhub.utils import admin_only +from jupyterhub.scopes import needs_scope from tljh_repo2docker.docker import list_images from tornado.web import authenticated @@ -32,7 +32,7 @@ class PermissionsHandler(BaseHandler): """ @authenticated - @admin_only + @needs_scope("admin-ui") async def get(self): include_groups = self.settings.get("include_groups") all_groups = list_groups(include_groups) @@ -60,8 +60,8 @@ class PermissionsAPIHandler(APIHandler): Handle edits to the mapping of environments and groups. """ - @admin_only @authenticated + @needs_scope("admin-ui") async def post(self): raw_args = self.request.body.decode("utf-8") args = json.loads(raw_args) diff --git a/tljh-plasma/tljh_plasma/tests/conftest.py b/tljh-plasma/tljh_plasma/tests/conftest.py index 1c80c27..8b40aa3 100644 --- a/tljh-plasma/tljh_plasma/tests/conftest.py +++ b/tljh-plasma/tljh_plasma/tests/conftest.py @@ -1,16 +1,12 @@ -import asyncio -import os -import sys - import pytest +from jupyterhub.tests.mocking import MockPAMAuthenticator from tljh_repo2docker.tests.conftest import ( minimal_repo, image_name, generated_image_name, remove_all_test_images ) -from tljh_repo2docker.tests.utils import add_environment from tljh_repo2docker import tljh_custom_jupyterhub_config as tljh_repo2docker_config from tljh_plasma import tljh_custom_jupyterhub_config as tljh_plasma_config from traitlets.config import Config @@ -19,10 +15,11 @@ @pytest.fixture async def app(hub_app): config = Config() - config.authenticator_class = 'jupyterhub.tests.mocking.MockPAMAuthenticator' tljh_repo2docker_config(config) tljh_plasma_config(config) + config.JupyterHub.authenticator_class = MockPAMAuthenticator + app = await hub_app(config=config) return app \ No newline at end of file