mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-17 15:03:02 +00:00
Move auth state fixture to conftest
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
import os
|
||||
import logging
|
||||
from getpass import getuser
|
||||
from subprocess import TimeoutExpired
|
||||
@@ -12,6 +13,7 @@ from pytest import fixture, raises
|
||||
from tornado import ioloop, gen
|
||||
|
||||
from .. import orm
|
||||
from .. import crypto
|
||||
from ..utils import random_port
|
||||
|
||||
from . import mocking
|
||||
@@ -70,6 +72,23 @@ def app(request, io_loop):
|
||||
return mocked_app
|
||||
|
||||
|
||||
@fixture
|
||||
def auth_state_enabled(app):
|
||||
app.authenticator.auth_state = {
|
||||
'who': 'cares',
|
||||
}
|
||||
app.authenticator.enable_auth_state = True
|
||||
ck = crypto.CryptKeeper.instance()
|
||||
before_keys = ck.keys
|
||||
ck.keys = [os.urandom(32)]
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
ck.keys = before_keys
|
||||
app.authenticator.enable_auth_state = False
|
||||
app.authenticator.auth_state = None
|
||||
|
||||
|
||||
# mock services for testing.
|
||||
# Shorter intervals, etc.
|
||||
class MockServiceSpawner(jupyterhub.services.service._ServiceSpawner):
|
||||
|
Reference in New Issue
Block a user