forked from GithubBackups/healthchecks
Don't allow adding webhook integrations with both URLs blank
This commit is contained in:
parent
84a4de32cc
commit
38ed309a3c
@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Unsubscribe links serve a form, and require HTTP POST to actually unsubscribe
|
- Unsubscribe links serve a form, and require HTTP POST to actually unsubscribe
|
||||||
- For webhook integration, validate each header line separately
|
- For webhook integration, validate each header line separately
|
||||||
- Fix "Send Test Notification" for webhooks that only fire on checks going up
|
- Fix "Send Test Notification" for webhooks that only fire on checks going up
|
||||||
|
- Don't allow adding webhook integrations with both URLs blank
|
||||||
|
|
||||||
|
|
||||||
## v1.11.0 - 2019-11-22
|
## v1.11.0 - 2019-11-22
|
||||||
|
@ -122,6 +122,15 @@ class AddWebhookForm(forms.Form):
|
|||||||
max_length=1000, required=False, validators=[WebhookValidator()]
|
max_length=1000, required=False, validators=[WebhookValidator()]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
super().clean()
|
||||||
|
|
||||||
|
url_down = self.cleaned_data.get("url_down")
|
||||||
|
url_up = self.cleaned_data.get("url_up")
|
||||||
|
|
||||||
|
if not url_down and not url_up:
|
||||||
|
self.add_error("url_down", "Enter a valid URL.")
|
||||||
|
|
||||||
def get_value(self):
|
def get_value(self):
|
||||||
return json.dumps(dict(self.cleaned_data), sort_keys=True)
|
return json.dumps(dict(self.cleaned_data), sort_keys=True)
|
||||||
|
|
||||||
|
@ -144,3 +144,18 @@ class AddWebhookTestCase(BaseTestCase):
|
|||||||
|
|
||||||
c = Channel.objects.get()
|
c = Channel.objects.get()
|
||||||
self.assertEqual(c.down_webhook_spec["headers"], {"test": "123"})
|
self.assertEqual(c.down_webhook_spec["headers"], {"test": "123"})
|
||||||
|
|
||||||
|
def test_it_rejects_both_empty(self):
|
||||||
|
|
||||||
|
self.client.login(username="alice@example.org", password="password")
|
||||||
|
form = {
|
||||||
|
"method_down": "GET",
|
||||||
|
"url_down": "",
|
||||||
|
"method_up": "GET",
|
||||||
|
"url_up": "",
|
||||||
|
}
|
||||||
|
|
||||||
|
r = self.client.post(self.url, form)
|
||||||
|
self.assertContains(r, "Enter a valid URL.")
|
||||||
|
|
||||||
|
self.assertEqual(Channel.objects.count(), 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user