mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
aurweb.auth: add user credentials and matcher functions
This clones the behavior already present in the PHP implementation, but it uses a global dict with credential constant keys to validation functions to determine if a given user has a credential. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
670f711b59
commit
07d5907ecd
4 changed files with 154 additions and 1 deletions
|
@ -4,8 +4,8 @@ import pytest
|
|||
|
||||
from starlette.authentication import AuthenticationError
|
||||
|
||||
from aurweb.auth import BasicAuthBackend, has_credential
|
||||
from aurweb.db import query
|
||||
from aurweb.auth import BasicAuthBackend
|
||||
from aurweb.models.account_type import AccountType
|
||||
from aurweb.testing import setup_test_db
|
||||
from aurweb.testing.models import make_session, make_user
|
||||
|
@ -78,3 +78,8 @@ async def test_basic_auth_backend():
|
|||
LastUpdateTS=now_ts + 5)
|
||||
_, result = await backend.authenticate(request)
|
||||
assert result == user
|
||||
|
||||
|
||||
def test_has_fake_credential_fails():
|
||||
# Fake credential 666 does not exist.
|
||||
assert not has_credential(user, 666)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue