mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-10 19:43:01 +00:00
Add tests for form based token generation
This commit is contained in:
@@ -493,6 +493,27 @@ def test_token(app):
|
|||||||
r = api_request(app, 'authorizations/token', 'notauthorized')
|
r = api_request(app, 'authorizations/token', 'notauthorized')
|
||||||
assert r.status_code == 404
|
assert r.status_code == 404
|
||||||
|
|
||||||
|
def test_get_token(app):
|
||||||
|
name = 'user'
|
||||||
|
user = add_user(app.db, app=app, name=name)
|
||||||
|
r = api_request(app, 'authorizations/token', method='post', data=json.dumps({
|
||||||
|
'username': name,
|
||||||
|
'password': name,
|
||||||
|
}))
|
||||||
|
assert r.status_code == 200
|
||||||
|
data = r.content.decode("utf-8")
|
||||||
|
token = json.loads(data)
|
||||||
|
assert not token['Authentication'] is None
|
||||||
|
|
||||||
|
def test_bad_get_token(app):
|
||||||
|
name = 'user'
|
||||||
|
password = 'fake'
|
||||||
|
user = add_user(app.db, app=app, name=name)
|
||||||
|
r = api_request(app, 'authorizations/token', method='post', data=json.dumps({
|
||||||
|
'username': name,
|
||||||
|
'password': password,
|
||||||
|
}))
|
||||||
|
assert r.status_code == 403
|
||||||
|
|
||||||
def test_options(app):
|
def test_options(app):
|
||||||
r = api_request(app, 'users', method='options')
|
r = api_request(app, 'users', method='options')
|
||||||
|
Reference in New Issue
Block a user