fix(api): upgrade django code (pre-commit)

This commit is contained in:
jo 2023-04-24 16:49:12 +02:00 committed by Kyle Robbertze
parent 14357102e5
commit a8e2ce7732
2 changed files with 11 additions and 9 deletions

View file

@ -19,17 +19,21 @@ class TestIsSystemTokenOrUser(APITestCase):
def test_token_incorrect(self):
token = "doesnotexist"
request = APIRequestFactory().get(self.path)
request = APIRequestFactory().get(
self.path,
headers={"Authorization": f"Api-Key {token}"},
)
request.user = AnonymousUser()
request.META["Authorization"] = f"Api-Key {token}"
allowed = IsSystemTokenOrUser().has_permission(request, None)
self.assertFalse(allowed)
def test_token_correct(self):
token = settings.CONFIG.general.api_key
request = APIRequestFactory().get(self.path)
request = APIRequestFactory().get(
self.path,
headers={"Authorization": f"Api-Key {token}"},
)
request.user = AnonymousUser()
request.META["Authorization"] = f"Api-Key {token}"
allowed = IsSystemTokenOrUser().has_permission(request, None)
self.assertTrue(allowed)