Logout now requires Authorization: Bearer <access-token>.
This commit is contained in:
@@ -55,6 +55,17 @@ def test_login_returns_token():
|
||||
assert client.get('/api/auth/me', params={'token': payload['access_token']}).status_code == 401
|
||||
|
||||
|
||||
def test_logout_requires_bearer_header_and_revokes_token_family():
|
||||
login = client.post('/api/auth/login', json={'email': 'alice@example.com', 'password': 'secret123'}).json()
|
||||
token = login['access_token']
|
||||
headers = {'Authorization': f'Bearer {token}'}
|
||||
assert client.post('/api/auth/logout', json={'token': token}).status_code == 401
|
||||
assert client.get('/api/auth/me', headers=headers).status_code == 200
|
||||
assert client.post('/api/auth/logout', headers=headers).status_code == 200
|
||||
assert client.get('/api/auth/me', headers=headers).status_code == 401
|
||||
assert client.post('/api/auth/refresh', json={'refresh_token': login['refresh_token'], 'device_id': login['device_id']}).status_code == 401
|
||||
|
||||
|
||||
def test_login_rate_limit_locks_out_after_five_failures_and_resets_on_success():
|
||||
email = f'unknown-{uuid4().hex}@example.com'
|
||||
for attempt in range(5):
|
||||
@@ -643,8 +654,7 @@ def test_only_link_owner_can_edit_link():
|
||||
|
||||
def test_logout_revokes_token_and_admin_can_list_plugins():
|
||||
headers = login_headers()
|
||||
token = headers['Authorization'].removeprefix('Bearer ')
|
||||
assert client.post('/api/auth/logout', json={'token': token}).status_code == 200
|
||||
assert client.post('/api/auth/logout', headers=headers).status_code == 200
|
||||
|
||||
revoked_response = client.post('/api/links', headers=headers, json={
|
||||
'title': 'Should fail',
|
||||
|
||||
Reference in New Issue
Block a user