Browse Source
Fix special character escaping in Zulip notifications
pull/617/head
Pēteris Caune
2 years ago
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
2 changed files with
15 additions and
2 deletions
-
hc/api/tests/test_notify_zulip.py
-
templates/integrations/zulip_topic.html
|
|
@ -45,7 +45,7 @@ class NotifyZulipTestCase(BaseTestCase): |
|
|
|
self.assertEqual(url, "https://example.org/api/v1/messages") |
|
|
|
|
|
|
|
payload = kwargs["data"] |
|
|
|
self.assertIn("DOWN", payload["topic"]) |
|
|
|
self.assertEqual(payload["topic"], "Foobar is DOWN") |
|
|
|
|
|
|
|
# payload should not contain check's code |
|
|
|
serialized = json.dumps(payload) |
|
|
@ -99,3 +99,16 @@ class NotifyZulipTestCase(BaseTestCase): |
|
|
|
|
|
|
|
n = Notification.objects.get() |
|
|
|
self.assertEqual(n.error, "Zulip notifications are not enabled.") |
|
|
|
|
|
|
|
@patch("hc.api.transports.requests.request") |
|
|
|
def test_it_does_not_escape_topic(self, mock_post): |
|
|
|
mock_post.return_value.status_code = 200 |
|
|
|
|
|
|
|
self.check.name = "Foo & Bar" |
|
|
|
self.check.save() |
|
|
|
|
|
|
|
self.channel.notify(self.check) |
|
|
|
|
|
|
|
args, kwargs = mock_post.call_args |
|
|
|
payload = kwargs["data"] |
|
|
|
self.assertEqual(payload["topic"], "Foo & Bar is DOWN") |
|
|
@ -1 +1 @@ |
|
|
|
{{ check.name_then_code }} is {{ check.status|upper }} |
|
|
|
{{ check.name_then_code|safe }} is {{ check.status|upper }} |