diff --git a/authentik/events/api/event.py b/authentik/events/api/event.py index 2134da380..e7234fded 100644 --- a/authentik/events/api/event.py +++ b/authentik/events/api/event.py @@ -11,7 +11,7 @@ from rest_framework.response import Response from rest_framework.serializers import ModelSerializer, Serializer from rest_framework.viewsets import ReadOnlyModelViewSet -from authentik.core.api.utils import TypeCreateSerializer +from authentik.core.api.utils import PassiveSerializer, TypeCreateSerializer from authentik.events.models import Event, EventAction @@ -38,31 +38,19 @@ class EventSerializer(ModelSerializer): ] -class EventTopPerUserParams(Serializer): +class EventTopPerUserParams(PassiveSerializer): """Query params for top_per_user""" top_n = IntegerField(default=15) - def create(self, request: Request) -> Response: - raise NotImplementedError - def update(self, request: Request) -> Response: - raise NotImplementedError - - -class EventTopPerUserSerializer(Serializer): +class EventTopPerUserSerializer(PassiveSerializer): """Response object of Event's top_per_user""" application = DictField() counted_events = IntegerField() unique_users = IntegerField() - def create(self, request: Request) -> Response: - raise NotImplementedError - - def update(self, request: Request) -> Response: - raise NotImplementedError - class EventsFilter(django_filters.FilterSet): """Filter for events""" @@ -132,7 +120,7 @@ class EventViewSet(ReadOnlyModelViewSet): def top_per_user(self, request: Request): """Get the top_n events grouped by user count""" filtered_action = request.query_params.get("action", EventAction.LOGIN) - top_n = request.query_params.get("top_n", 15) + top_n = int(request.query_params.get("top_n", "15")) return Response( get_objects_for_user(request.user, "authentik_events.view_event") .filter(action=filtered_action) diff --git a/authentik/outposts/signals.py b/authentik/outposts/signals.py index eb71162bf..391b85c7e 100644 --- a/authentik/outposts/signals.py +++ b/authentik/outposts/signals.py @@ -46,7 +46,7 @@ def pre_delete_cleanup(sender, instance: Outpost, **_): # Service connection here try: outpost_pre_delete.delay(instance.pk.hex).get() - except RuntimeError: + except RuntimeError: # pragma: no cover # In e2e/integration tests, this might run inside a thread/process and # trigger the celery `Never call result.get() within a task` detection if settings.TEST: