delay evaluation of oauth environment variables

only affects mocking in tests
This commit is contained in:
Min RK
2017-03-31 17:07:21 +02:00
parent d1822ee939
commit 198bb875df
2 changed files with 11 additions and 2 deletions

View File

@@ -405,18 +405,25 @@ class HubOAuth(HubAuth):
# HubOAuth API
oauth_client_id = Unicode(os.getenv('JUPYTERHUB_CLIENT_ID', ''),
oauth_client_id = Unicode(
help="""The OAuth client ID for this application.
Use JUPYTERHUB_CLIENT_ID by default.
"""
).tag(config=True)
oauth_client_secret = Unicode(os.getenv('JUPYTERHUB_CLIENT_SECRET', ''),
@default('oauth_client_id')
def _client_id(self):
return os.getenv('JUPYTERHUB_CLIENT_ID', '')
oauth_client_secret = Unicode(
help="""The OAuth client secret for this application.
Use JUPYTERHUB_CLIENT_SECRET by default.
"""
).tag(config=True)
@default('oauth_client_secret')
def _client_secret(self):
return os.getenv('JUPYTERHUB_CLIENT_SECRET', '')
oauth_redirect_uri = Unicode(
help="""OAuth redirect URI

View File

@@ -254,6 +254,8 @@ class StubSingleUserSpawner(MockSpawner):
with mock.patch.dict(os.environ, env):
app = self._app = MockSingleUserServer()
app.initialize(args)
assert app.hub_auth.oauth_client_id
assert app.hub_auth.oauth_client_secret
app.start()
self._thread = threading.Thread(target=_run)