feat(fastapi): render a 500 html response when unique SID generation fails

We've seen a bug in the past where unique SID generation fails and
still ends up raising an exception.

This commit reworks how we deal with database exceptions internally,
tries for 36 iterations to set a fresh unique SID, and raises a 500
HTTPException if we were unable to.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-12-02 23:26:42 -08:00
parent abfd41f31e
commit 806a19b91a
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
3 changed files with 85 additions and 29 deletions

View file

@ -62,7 +62,6 @@ def test_user_login_logout(user: User):
sid = user.login(request, "testPassword")
assert sid is not None
assert user.is_authenticated()
assert "AURSID" in request.cookies
# Expect that User session relationships work right.
user_session = db.query(Session,
@ -92,7 +91,6 @@ def test_user_login_logout(user: User):
# Test logout.
user.logout(request)
assert "AURSID" not in request.cookies
assert not user.is_authenticated()