feat: 退出时选择离开系统或删除账号
This commit is contained in:
@@ -352,16 +352,32 @@ def test_browser_session_logout_and_revoke(monkeypatch) -> None:
|
||||
account = db.get(Account, "6650000146")
|
||||
assert account is not None
|
||||
assert account.credential_cipher
|
||||
again = client.post("/api/login", json={"employee_id": "6650000146", "password": "secret-pass"})
|
||||
assert again.status_code == 200
|
||||
assert calls["login"] == 1
|
||||
assert client.post("/api/revoke").status_code == 200
|
||||
assert client.get("/api/session").status_code == 401
|
||||
account.study_schedule_enabled = True
|
||||
db.commit()
|
||||
with SessionLocal() as db:
|
||||
account = db.get(Account, "6650000146")
|
||||
assert account is not None
|
||||
assert account.credential_cipher == ""
|
||||
assert account.password_cipher == ""
|
||||
assert account.study_schedule_enabled is True
|
||||
again = client.post("/api/login", json={"employee_id": "6650000146", "password": "secret-pass"})
|
||||
assert again.status_code == 200
|
||||
assert calls["login"] == 1
|
||||
from euniv.autostudy import _wanted
|
||||
from euniv.models import FinishedCourse
|
||||
|
||||
_wanted["6650000146"] = object()
|
||||
with SessionLocal() as db:
|
||||
db.add(FinishedCourse(employee_id="6650000146", knowledge_id="course-1"))
|
||||
db.commit()
|
||||
assert client.post("/api/revoke").status_code == 200
|
||||
assert client.get("/api/session").status_code == 401
|
||||
assert "6650000146" not in _wanted
|
||||
with SessionLocal() as db:
|
||||
from sqlalchemy import select
|
||||
|
||||
account = db.get(Account, "6650000146")
|
||||
assert account is None
|
||||
left = db.scalars(select(FinishedCourse).where(FinishedCourse.employee_id == "6650000146")).all()
|
||||
assert left == []
|
||||
|
||||
|
||||
def test_logout_keeps_the_other_browser_until_revoke(monkeypatch) -> None:
|
||||
|
||||
Reference in New Issue
Block a user