
* events: initial alerting implementation * policies: move error handling to process, ensure policy UUID is saved * policies: add tests for error handling in PolicyProcess * events: improve loop detection * events: add API for action and trigger * policies: ensure http_request is not used in context * events: adjust unittests for user handling * policies/event_matcher: add policy type * events: add API tests * events: add middleware tests * core: make application's provider not required * outposts: allow blank kubeconfig * outposts: validate kubeconfig before saving * api: fix formatting * stages/invitation: remove invitation_created signal as model_created functions the same * stages/invitation: ensure created_by is set when creating from API * events: rebase migrations on master * events: fix missing Alerts from API * policies: fix unittests * events: add tests for alerts * events: rename from alerting to notifications * events: add ability to specify severity of notification created * policies/event_matcher: Add app field to match on event app * policies/event_matcher: fix EventMatcher not being included in API * core: use objects.none() when get_queryset is used * events: use m2m for multiple transports, create notification object in task * events: add default triggers * events: fix migrations return value * events: fix notification_transport not being in the correct queue * stages/email: allow sending of email without backend * events: implement sending via webhook + slack/discord + email
25 lines
762 B
Python
25 lines
762 B
Python
"""Event API tests"""
|
|
|
|
from django.shortcuts import reverse
|
|
from rest_framework.test import APITestCase
|
|
|
|
from authentik.core.models import User
|
|
from authentik.events.models import Event, EventAction
|
|
|
|
|
|
class TestEventsAPI(APITestCase):
|
|
"""Test Event API"""
|
|
|
|
def test_top_n(self):
|
|
"""Test top_per_user"""
|
|
user = User.objects.get(username="akadmin")
|
|
self.client.force_login(user)
|
|
|
|
event = Event.new(EventAction.AUTHORIZE_APPLICATION)
|
|
event.save() # We save to ensure nothing is un-saveable
|
|
response = self.client.get(
|
|
reverse("authentik_api:event-top-per-user"),
|
|
data={"filter_action": EventAction.AUTHORIZE_APPLICATION},
|
|
)
|
|
self.assertEqual(response.status_code, 200)
|