admin: add api tests
This commit is contained in:
parent
0083cd55df
commit
ecdbc917a5
|
@ -0,0 +1,37 @@
|
||||||
|
"""test admin api"""
|
||||||
|
from json import loads
|
||||||
|
from django.shortcuts import reverse
|
||||||
|
|
||||||
|
from authentik import __version__
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
from authentik.core.models import User, Group
|
||||||
|
|
||||||
|
|
||||||
|
class TestAdminAPI(TestCase):
|
||||||
|
"""test admin api"""
|
||||||
|
|
||||||
|
def setUp(self) -> None:
|
||||||
|
super().setUp()
|
||||||
|
self.user = User.objects.create(username="test-user")
|
||||||
|
self.group = Group.objects.create(name="superusers", is_superuser=True)
|
||||||
|
self.group.users.add(self.user)
|
||||||
|
self.group.save()
|
||||||
|
self.client.force_login(self.user)
|
||||||
|
|
||||||
|
def test_overview(self):
|
||||||
|
"""Test Overview API"""
|
||||||
|
response = self.client.get(reverse("authentik_api:admin_overview-list"))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
body = loads(response.content)
|
||||||
|
self.assertEqual(body["version"], __version__)
|
||||||
|
|
||||||
|
def test_metrics(self):
|
||||||
|
"""Test metrics API"""
|
||||||
|
response = self.client.get(reverse("authentik_api:admin_metrics-list"))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
def test_tasks(self):
|
||||||
|
"""Test tasks metrics API"""
|
||||||
|
response = self.client.get(reverse("authentik_api:admin_system_tasks-list"))
|
||||||
|
self.assertEqual(response.status_code, 200)
|
|
@ -4,7 +4,7 @@ from django.conf import settings
|
||||||
from authentik.lib.config import CONFIG
|
from authentik.lib.config import CONFIG
|
||||||
|
|
||||||
|
|
||||||
class PytestTestRunner:
|
class PytestTestRunner: # pragma: no cover
|
||||||
"""Runs pytest to discover and run tests."""
|
"""Runs pytest to discover and run tests."""
|
||||||
|
|
||||||
def __init__(self, verbosity=1, failfast=False, keepdb=False, **_):
|
def __init__(self, verbosity=1, failfast=False, keepdb=False, **_):
|
||||||
|
|
Reference in New Issue