File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed
src/argus/notificationprofile
tests/notificationprofile Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -713,6 +713,11 @@ Notification profile endpoints
713
713
}
714
714
}
715
715
716
+ .. note ::
717
+ ``event_types `` cannot be ``null `` or ``[] ``, because all events have an event
718
+ type set, which would therefore result in no notifications ever being sent.
719
+ For not filtering by ``event_types `` the key needs to be removed.
720
+
716
721
717
722
- ``/api/v1/notificationprofiles/filters/<int:pk>/ ``:
718
723
@@ -1490,6 +1495,11 @@ Notification profile endpoints
1490
1495
}
1491
1496
}
1492
1497
1498
+ .. note ::
1499
+ ``event_types `` cannot be ``null `` or ``[] ``, because all events have an event
1500
+ type set, which would therefore result in no notifications ever being sent.
1501
+ For not filtering by ``event_types `` the key needs to be removed.
1502
+
1493
1503
1494
1504
- ``/api/v2/notificationprofiles/filters/<int:pk>/ ``:
1495
1505
Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ class FilterBlobSerializer(serializers.Serializer):
31
31
required = False ,
32
32
)
33
33
34
+ def validate_event_types (self , value ):
35
+ if not value :
36
+ raise serializers .ValidationError ("Event types cannot be empty, remove it completely from filter instead." )
37
+ return value
38
+
34
39
35
40
class FilterPreviewSerializer (serializers .Serializer ):
36
41
sourceSystemIds = serializers .ListField (child = serializers .IntegerField (min_value = 1 ), allow_empty = True )
Original file line number Diff line number Diff line change @@ -403,6 +403,17 @@ def test_should_create_filter_with_event_types(self):
403
403
self .assertEqual (response .status_code , status .HTTP_201_CREATED )
404
404
self .assertTrue (Filter .objects .filter (pk = response .data ["pk" ]).exists ())
405
405
406
+ def test_should_not_create_filter_with_empty_event_types (self ):
407
+ filter_name = "test-filter"
408
+ response = self .user1_rest_client .post (
409
+ path = self .ENDPOINT ,
410
+ data = {
411
+ "name" : filter_name ,
412
+ "filter" : {"event_types" : []},
413
+ },
414
+ )
415
+ self .assertEqual (response .status_code , status .HTTP_400_BAD_REQUEST )
416
+
406
417
def test_should_update_filter_name_with_valid_values (self ):
407
418
filter1_pk = self .filter1 .pk
408
419
filter1_path = f"{ self .ENDPOINT } { filter1_pk } /"
You can’t perform that action at this time.
0 commit comments