diff --git a/authentik/admin/mixins.py b/authentik/admin/mixins.py deleted file mode 100644 index 97ee3c53a..000000000 --- a/authentik/admin/mixins.py +++ /dev/null @@ -1,9 +0,0 @@ -"""authentik admin mixins""" -from django.contrib.auth.mixins import UserPassesTestMixin - - -class AdminRequiredMixin(UserPassesTestMixin): - """Make sure user is administrator""" - - def test_func(self): - return self.request.user.is_superuser diff --git a/authentik/api/tests/__init__.py b/authentik/api/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/authentik/api/tests.py b/authentik/api/tests/test_auth.py similarity index 100% rename from authentik/api/tests.py rename to authentik/api/tests/test_auth.py diff --git a/authentik/api/tests/test_swagger.py b/authentik/api/tests/test_swagger.py new file mode 100644 index 000000000..b8095a388 --- /dev/null +++ b/authentik/api/tests/test_swagger.py @@ -0,0 +1,24 @@ +"""Swagger generation tests""" +from json import loads + +from django.urls import reverse +from rest_framework.test import APITestCase +from yaml import safe_load + + +class TestSwaggerGeneration(APITestCase): + """Generic admin tests""" + + def test_yaml(self): + """Test YAML generation""" + response = self.client.get( + reverse("authentik_api:schema-json", kwargs={"format": ".yaml"}), + ) + self.assertTrue(safe_load(response.content.decode())) + + def test_json(self): + """Test JSON generation""" + response = self.client.get( + reverse("authentik_api:schema-json", kwargs={"format": ".json"}), + ) + self.assertTrue(loads(response.content.decode())) diff --git a/authentik/core/signals.py b/authentik/core/signals.py index 4f293af09..ec7675fe2 100644 --- a/authentik/core/signals.py +++ b/authentik/core/signals.py @@ -17,7 +17,7 @@ def post_save_application(sender, instance, created: bool, **_): if sender != Application: return - if not created: + if not created: # pragma: no cover return # Also delete user application cache keys = cache.keys(user_app_cache_key("*")) diff --git a/authentik/events/middleware.py b/authentik/events/middleware.py index d9b865017..bb130cb02 100644 --- a/authentik/events/middleware.py +++ b/authentik/events/middleware.py @@ -76,7 +76,9 @@ class AuditMiddleware: user: User, request: HttpRequest, sender, instance: Model, **_ ): """Signal handler for all object's pre_delete""" - if isinstance(instance, (Event, Notification, UserObjectPermission)): + if isinstance( + instance, (Event, Notification, UserObjectPermission) + ): # pragma: no cover return EventNewThread( diff --git a/authentik/managed/models.py b/authentik/managed/models.py index d6dca21e6..508cc8102 100644 --- a/authentik/managed/models.py +++ b/authentik/managed/models.py @@ -1,6 +1,5 @@ """Managed Object models""" from django.db import models -from django.db.models import QuerySet from django.utils.translation import gettext_lazy as _ @@ -22,10 +21,6 @@ class ManagedModel(models.Model): unique=True, ) - def managed_objects(self) -> QuerySet: - """Get all objects which are managed""" - return self.objects.exclude(managed__isnull=True) - class Meta: abstract = True