(bugfix) Allow blank notification webhook headers
Normalize blank notification webhook headers to an empty JSON object so creating email targets from the browser does not try to store NULL in the JSON field. Closes #95
This commit is contained in:
@@ -318,6 +318,27 @@ class ViewTests(TestCase):
|
||||
self.assertEqual(target.channel, NotificationTarget.Channel.EMAIL)
|
||||
self.assertEqual(target.statuses, [BackupRun.Status.FAILED, BackupRun.Status.WARNING])
|
||||
self.assertEqual(target.email_to, "ops@example.test\nbackup@example.test")
|
||||
self.assertEqual(target.webhook_headers, {})
|
||||
|
||||
def test_notification_target_form_allows_blank_webhook_headers(self) -> None:
|
||||
self.client.force_login(self.staff_user)
|
||||
|
||||
response = self.client.post(
|
||||
reverse("create_notification_target"),
|
||||
{
|
||||
"name": "ops",
|
||||
"enabled": "on",
|
||||
"channel": NotificationTarget.Channel.EMAIL,
|
||||
"statuses": [BackupRun.Status.FAILED],
|
||||
"email_to": "ops@example.test",
|
||||
"webhook_headers": "",
|
||||
},
|
||||
follow=True,
|
||||
)
|
||||
|
||||
self.assertRedirects(response, reverse("notification_targets"))
|
||||
target = NotificationTarget.objects.get(name="ops")
|
||||
self.assertEqual(target.webhook_headers, {})
|
||||
|
||||
def test_notification_target_form_requires_channel_destination(self) -> None:
|
||||
self.client.force_login(self.staff_user)
|
||||
|
||||
Reference in New Issue
Block a user