18 lines
500 B
Python
18 lines
500 B
Python
import os
|
|
import time
|
|
|
|
import pytest
|
|
from client import Client
|
|
|
|
|
|
@pytest.mark.expiry
|
|
def test_session_expires(live: Client):
|
|
ttl = int(os.environ.get("SESSION_TTL_SECONDS", "3600"))
|
|
if os.environ.get("RUN_EXPIRY") != "1":
|
|
pytest.skip("set RUN_EXPIRY=1 and SESSION_TTL_SECONDS<=3")
|
|
assert ttl <= 3
|
|
actor = live.user("ttl")
|
|
live.call("GET", "/api/v1/users/me", actor=actor, schema="User")
|
|
time.sleep(ttl + 1.5)
|
|
live.call("GET", "/api/v1/users/me", 401, actor=actor)
|