change(FastAPI): @auth_required login kwarg defaulted to True

We pretty much want @auth_required to send users to login
if we enforce auth requirements but don't otherwise specify
a way to deal with it.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-10-07 09:43:47 -07:00
parent dc11a88ed3
commit 2e6f8cb9f4
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
5 changed files with 35 additions and 32 deletions

View file

@ -9,7 +9,7 @@ import pytest
from fastapi.testclient import TestClient
from aurweb import db
from aurweb import db, util
from aurweb.models.account_type import AccountType
from aurweb.models.tu_vote import TUVote
from aurweb.models.tu_voteinfo import TUVoteInfo
@ -128,7 +128,9 @@ def test_tu_index_guest(client):
with client as request:
response = request.get("/tu", allow_redirects=False)
assert response.status_code == int(HTTPStatus.SEE_OTHER)
assert response.headers.get("location") == "/"
params = util.urlencode({"next": "/tu"})
assert response.headers.get("location") == f"/login?{params}"
def test_tu_index_unauthorized(client, user):