core: add minor tests for users api
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
3c349b1f22
commit
0032f535da
|
@ -0,0 +1,29 @@
|
||||||
|
"""Test Users API"""
|
||||||
|
from django.urls.base import reverse
|
||||||
|
from rest_framework.test import APITestCase
|
||||||
|
|
||||||
|
from authentik.core.models import User
|
||||||
|
|
||||||
|
|
||||||
|
class TestUsersAPI(APITestCase):
|
||||||
|
"""Test Users API"""
|
||||||
|
|
||||||
|
def setUp(self) -> None:
|
||||||
|
self.admin = User.objects.get(username="akadmin")
|
||||||
|
self.user = User.objects.create(username="test-user")
|
||||||
|
|
||||||
|
def test_metrics(self):
|
||||||
|
"""Test user's metrics"""
|
||||||
|
self.client.force_login(self.admin)
|
||||||
|
response = self.client.get(
|
||||||
|
reverse("authentik_api:user-metrics", kwargs={"pk": self.user.pk})
|
||||||
|
)
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
def test_metrics_denied(self):
|
||||||
|
"""Test user's metrics (non-superuser)"""
|
||||||
|
self.client.force_login(self.user)
|
||||||
|
response = self.client.get(
|
||||||
|
reverse("authentik_api:user-metrics", kwargs={"pk": self.user.pk})
|
||||||
|
)
|
||||||
|
self.assertEqual(response.status_code, 403)
|
|
@ -15639,6 +15639,8 @@ components:
|
||||||
long:
|
long:
|
||||||
type: number
|
type: number
|
||||||
format: float
|
format: float
|
||||||
|
city:
|
||||||
|
type: string
|
||||||
nullable: true
|
nullable: true
|
||||||
readOnly: true
|
readOnly: true
|
||||||
user:
|
user:
|
||||||
|
|
Reference in New Issue