|
7 | 7 | from ephios.core.models import AbstractParticipation, LocalParticipation, Notification |
8 | 8 | from ephios.core.services.notifications.backends import EmailNotificationBackend |
9 | 9 | from ephios.core.services.notifications.types import ( |
| 10 | + NOTIFICATION_READ_PARAM_NAME, |
10 | 11 | ConsequenceApprovedNotification, |
11 | 12 | ConsequenceDeniedNotification, |
12 | 13 | CustomEventParticipantNotification, |
@@ -201,11 +202,34 @@ def test_middleware_marks_notification_as_read(django_app, qualified_volunteer, |
201 | 202 | user=planner, slug=ResponsibleParticipationAwaitsDispositionNotification.slug |
202 | 203 | ) |
203 | 204 | assert not notification.read |
204 | | - response = django_app.get(notification.get_actions()[0][1], user=planner) |
| 205 | + django_app.get(notification.get_actions()[0][1], user=planner) |
205 | 206 | notification.refresh_from_db() |
206 | 207 | assert notification.read |
207 | 208 |
|
208 | 209 |
|
| 210 | +def test_broken_middleware_query_param(django_app, planner): |
| 211 | + django_app.get( |
| 212 | + f"/?{NOTIFICATION_READ_PARAM_NAME}=1", |
| 213 | + user=None, # anonymous user |
| 214 | + ) |
| 215 | + django_app.get( |
| 216 | + f"/?{NOTIFICATION_READ_PARAM_NAME}", |
| 217 | + user=planner, |
| 218 | + ) |
| 219 | + django_app.get( |
| 220 | + f"/?{NOTIFICATION_READ_PARAM_NAME}=123", |
| 221 | + user=planner, |
| 222 | + ) |
| 223 | + django_app.get( |
| 224 | + f"/?{NOTIFICATION_READ_PARAM_NAME}=abc", |
| 225 | + user=planner, |
| 226 | + ) |
| 227 | + django_app.get( |
| 228 | + f"/?{NOTIFICATION_READ_PARAM_NAME}=1&{NOTIFICATION_READ_PARAM_NAME}=2", |
| 229 | + user=planner, |
| 230 | + ) |
| 231 | + |
| 232 | + |
209 | 233 | def test_notification_doesnotexist_gets_deleted(django_app, qualified_volunteer, event): |
210 | 234 | participation = LocalParticipation.objects.create( |
211 | 235 | shift=event.shifts.first(), |
|
0 commit comments