mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
auth: add several AnonymousUser method stubs
We'll need to use these, so this commit implements them here with tests for coverage. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
c006386079
commit
741cbfaa4e
2 changed files with 46 additions and 1 deletions
|
@ -53,10 +53,30 @@ class AnonymousUser:
|
||||||
def is_authenticated():
|
def is_authenticated():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_trusted_user():
|
||||||
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_developer():
|
||||||
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_elevated():
|
||||||
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def has_credential(credential):
|
def has_credential(credential):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def voted_for(package):
|
||||||
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def notified(package):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class BasicAuthBackend(AuthenticationBackend):
|
class BasicAuthBackend(AuthenticationBackend):
|
||||||
async def authenticate(self, conn: HTTPConnection):
|
async def authenticate(self, conn: HTTPConnection):
|
||||||
|
|
|
@ -5,7 +5,7 @@ import pytest
|
||||||
from sqlalchemy.exc import IntegrityError
|
from sqlalchemy.exc import IntegrityError
|
||||||
|
|
||||||
from aurweb import db
|
from aurweb import db
|
||||||
from aurweb.auth import BasicAuthBackend, account_type_required, has_credential
|
from aurweb.auth import AnonymousUser, BasicAuthBackend, account_type_required, has_credential
|
||||||
from aurweb.db import create, query
|
from aurweb.db import create, query
|
||||||
from aurweb.models.account_type import USER, USER_ID, AccountType
|
from aurweb.models.account_type import USER, USER_ID, AccountType
|
||||||
from aurweb.models.session import Session
|
from aurweb.models.session import Session
|
||||||
|
@ -92,3 +92,28 @@ def test_account_type_required():
|
||||||
# But this one should! We have no "FAKE" key.
|
# But this one should! We have no "FAKE" key.
|
||||||
with pytest.raises(KeyError):
|
with pytest.raises(KeyError):
|
||||||
account_type_required({'FAKE'})
|
account_type_required({'FAKE'})
|
||||||
|
|
||||||
|
|
||||||
|
def test_is_trusted_user():
|
||||||
|
user_ = AnonymousUser()
|
||||||
|
assert not user_.is_trusted_user()
|
||||||
|
|
||||||
|
|
||||||
|
def test_is_developer():
|
||||||
|
user_ = AnonymousUser()
|
||||||
|
assert not user_.is_developer()
|
||||||
|
|
||||||
|
|
||||||
|
def test_is_elevated():
|
||||||
|
user_ = AnonymousUser()
|
||||||
|
assert not user_.is_elevated()
|
||||||
|
|
||||||
|
|
||||||
|
def test_voted_for():
|
||||||
|
user_ = AnonymousUser()
|
||||||
|
assert not user_.voted_for(None)
|
||||||
|
|
||||||
|
|
||||||
|
def test_notified():
|
||||||
|
user_ = AnonymousUser()
|
||||||
|
assert not user_.notified(None)
|
||||||
|
|
Loading…
Add table
Reference in a new issue