allow oauth provider to be missing

mostly for testing
This commit is contained in:
Min RK
2017-03-31 16:15:00 +02:00
parent 5819b442aa
commit 5e1516189b
2 changed files with 16 additions and 15 deletions

View File

@@ -183,7 +183,7 @@ def test_spawn_fails(db, io_loop):
'config': None, 'config': None,
}) })
with pytest.raises(Exception) as exc: with pytest.raises(RuntimeError) as exc:
io_loop.run_sync(user.spawn) io_loop.run_sync(user.spawn)
assert user.server is None assert user.server is None
assert not user.running assert not user.running

View File

@@ -246,7 +246,9 @@ class User(HasTraits):
spawner.api_token = api_token spawner.api_token = api_token
spawner.admin_access = self.settings.get('admin_access', False) spawner.admin_access = self.settings.get('admin_access', False)
spawner.oauth_client_id = client_id = 'user-%s-%s' % (self.escaped_name, server_name) spawner.oauth_client_id = client_id = 'user-%s-%s' % (self.escaped_name, server_name)
client_store = self.settings['oauth_provider'].client_authenticator.client_store oauth_provider = self.settings.get('oauth_provider')
if oauth_provider:
client_store = oauth_provider.client_authenticator.client_store
try: try:
oauth_client = client_store.fetch_by_client_id(client_id) oauth_client = client_store.fetch_by_client_id(client_id)
except ClientNotFoundError: except ClientNotFoundError:
@@ -255,7 +257,6 @@ class User(HasTraits):
# except for resuming containers. # except for resuming containers.
if oauth_client is None or not spawner.will_resume: if oauth_client is None or not spawner.will_resume:
spawner.oauth_client_secret = client_secret = new_token() spawner.oauth_client_secret = client_secret = new_token()
print(server.base_url)
client_store.add_client(client_id, client_secret, client_store.add_client(client_id, client_secret,
url_path_join(server.base_url, 'oauth_callback'), url_path_join(server.base_url, 'oauth_callback'),
) )