1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-10-20 18:32:41 +00:00

[api2] Return 401 if api token is invalid

This commit is contained in:
zhengxie
2015-04-13 11:59:57 +08:00
parent 16b77837b8
commit 94dcfe338a
2 changed files with 38 additions and 11 deletions

View File

@@ -18,9 +18,22 @@ def fake_ccnet_id():
return randstring(length=40)
class AuthTest(ApiTestBase):
"""This tests involves creating/deleting api tokens, so for this test we use
a specific auth token so that it won't affect other test cases.
"""This tests involves creating/deleting api tokens, so for this test we
use a specific auth token so that it won't affect other test cases.
"""
def test_auth_token_missing(self):
return self.get(AUTH_PING_URL, token=None, use_token=False,
expected=403)
def test_auth_token_is_empty(self):
return self.get(AUTH_PING_URL, token='', expected=401)
def test_auth_token_contains_space(self):
return self.get(AUTH_PING_URL, token='token with space', expected=401)
def test_random_auth_token(self):
return self.get(AUTH_PING_URL, token='randomtoken', expected=401)
def test_logout_device(self):
token = self._desktop_login()
self._do_auth_ping(token, expected=200)