21 lines
623 B
Python
21 lines
623 B
Python
import os
|
|
import time
|
|
|
|
import pytest
|
|
|
|
|
|
def test_logout_revokes_current_token(client):
|
|
actor = client.user('logout')
|
|
client.call('DELETE', '/api/v1/auth/sessions/current', 204, actor=actor)
|
|
client.call('GET', '/api/v1/users/me', 401, actor=actor)
|
|
|
|
|
|
@pytest.mark.skipif(
|
|
int(os.getenv('SESSION_TTL_SECONDS', '3600')) > 2,
|
|
reason='run with SESSION_TTL_SECONDS=1 to check automatic session expiry',
|
|
)
|
|
def test_session_expires_with_short_ttl(client):
|
|
actor = client.user('expiry')
|
|
time.sleep(int(os.environ['SESSION_TTL_SECONDS']) + 0.25)
|
|
client.call('GET', '/api/v1/users/me', 401, actor=actor)
|