mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-13 21:13:01 +00:00
allow oauth provider to be missing
mostly for testing
This commit is contained in:
@@ -183,7 +183,7 @@ def test_spawn_fails(db, io_loop):
|
||||
'config': None,
|
||||
})
|
||||
|
||||
with pytest.raises(Exception) as exc:
|
||||
with pytest.raises(RuntimeError) as exc:
|
||||
io_loop.run_sync(user.spawn)
|
||||
assert user.server is None
|
||||
assert not user.running
|
||||
|
@@ -246,20 +246,21 @@ class User(HasTraits):
|
||||
spawner.api_token = api_token
|
||||
spawner.admin_access = self.settings.get('admin_access', False)
|
||||
spawner.oauth_client_id = client_id = 'user-%s-%s' % (self.escaped_name, server_name)
|
||||
client_store = self.settings['oauth_provider'].client_authenticator.client_store
|
||||
try:
|
||||
oauth_client = client_store.fetch_by_client_id(client_id)
|
||||
except ClientNotFoundError:
|
||||
oauth_client = None
|
||||
# create a new OAuth client + secret on every launch,
|
||||
# except for resuming containers.
|
||||
if oauth_client is None or not spawner.will_resume:
|
||||
spawner.oauth_client_secret = client_secret = new_token()
|
||||
print(server.base_url)
|
||||
client_store.add_client(client_id, client_secret,
|
||||
url_path_join(server.base_url, 'oauth_callback'),
|
||||
)
|
||||
db.commit()
|
||||
oauth_provider = self.settings.get('oauth_provider')
|
||||
if oauth_provider:
|
||||
client_store = oauth_provider.client_authenticator.client_store
|
||||
try:
|
||||
oauth_client = client_store.fetch_by_client_id(client_id)
|
||||
except ClientNotFoundError:
|
||||
oauth_client = None
|
||||
# create a new OAuth client + secret on every launch,
|
||||
# except for resuming containers.
|
||||
if oauth_client is None or not spawner.will_resume:
|
||||
spawner.oauth_client_secret = client_secret = new_token()
|
||||
client_store.add_client(client_id, client_secret,
|
||||
url_path_join(server.base_url, 'oauth_callback'),
|
||||
)
|
||||
db.commit()
|
||||
|
||||
# trigger pre-spawn hook on authenticator
|
||||
authenticator = self.authenticator
|
||||
|
Reference in New Issue
Block a user