http://down.example.com
")
- self.assertContains(r, "http://up.example.com
")
- self.assertContains(r, "foobar
")
+ self.assertContains(r, "http://down.example.com")
+ self.assertContains(r, "http://up.example.com")
+ self.assertContains(r, "foobar")
def test_it_shows_pushover_details(self):
ch = Channel(kind="po", user=self.alice)
@@ -46,7 +46,6 @@ class ChannelsTestCase(BaseTestCase):
r = self.client.get("/integrations/")
self.assertEqual(r.status_code, 200)
- self.assertContains(r, "fake-key")
self.assertContains(r, "(normal priority)")
def test_it_shows_disabled_email(self):
@@ -63,7 +62,7 @@ class ChannelsTestCase(BaseTestCase):
self.client.login(username="alice@example.org", password="password")
r = self.client.get("/integrations/")
self.assertEqual(r.status_code, 200)
- self.assertContains(r, "(bounced, disabled)")
+ self.assertContains(r, "Disabled")
def test_it_shows_unconfirmed_email(self):
channel = Channel(user=self.alice, kind="email")
@@ -73,7 +72,7 @@ class ChannelsTestCase(BaseTestCase):
self.client.login(username="alice@example.org", password="password")
r = self.client.get("/integrations/")
self.assertEqual(r.status_code, 200)
- self.assertContains(r, "(unconfirmed)")
+ self.assertContains(r, "Unconfirmed")
def test_it_shows_sms_label(self):
ch = Channel(kind="sms", user=self.alice)
@@ -84,4 +83,4 @@ class ChannelsTestCase(BaseTestCase):
r = self.client.get("/integrations/")
self.assertEqual(r.status_code, 200)
- self.assertContains(r, "My Phone (+123)")
+ self.assertContains(r, "SMS to +123")
diff --git a/hc/front/tests/test_update_channel_name.py b/hc/front/tests/test_update_channel_name.py
new file mode 100644
index 00000000..7ed4864e
--- /dev/null
+++ b/hc/front/tests/test_update_channel_name.py
@@ -0,0 +1,54 @@
+from hc.api.models import Channel
+from hc.test import BaseTestCase
+
+
+class UpdateChannelNameTestCase(BaseTestCase):
+
+ def setUp(self):
+ super(UpdateChannelNameTestCase, self).setUp()
+ self.channel = Channel(kind="email", user=self.alice)
+ self.channel.save()
+
+ self.url = "/integrations/%s/name/" % self.channel.code
+
+ def test_it_works(self):
+ payload = {"name": "My work email"}
+
+ self.client.login(username="alice@example.org", password="password")
+ r = self.client.post(self.url, data=payload)
+ self.assertRedirects(r, "/integrations/")
+
+ self.channel.refresh_from_db()
+ self.assertEqual(self.channel.name, "My work email")
+
+ def test_team_access_works(self):
+ payload = {"name": "Bob was here"}
+
+ # Logging in as bob, not alice. Bob has team access so this
+ # should work.
+ self.client.login(username="bob@example.org", password="password")
+ self.client.post(self.url, data=payload)
+
+ self.channel.refresh_from_db()
+ self.assertEqual(self.channel.name, "Bob was here")
+
+ def test_it_checks_ownership(self):
+ payload = {"name": "Charlie Sent This"}
+
+ self.client.login(username="charlie@example.org", password="password")
+ r = self.client.post(self.url, data=payload)
+ self.assertEqual(r.status_code, 403)
+
+ def test_it_handles_missing_uuid(self):
+ # Valid UUID but there is no check for it:
+ url = "/integrations/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/name/"
+ payload = {"name": "Alice Was Here"}
+
+ self.client.login(username="alice@example.org", password="password")
+ r = self.client.post(url, data=payload)
+ self.assertEqual(r.status_code, 404)
+
+ def test_it_rejects_get(self):
+ self.client.login(username="alice@example.org", password="password")
+ r = self.client.get(self.url)
+ self.assertEqual(r.status_code, 405)
diff --git a/hc/front/tests/test_update_name.py b/hc/front/tests/test_update_name.py
index dfccaf5c..31725615 100644
--- a/hc/front/tests/test_update_name.py
+++ b/hc/front/tests/test_update_name.py
@@ -9,36 +9,35 @@ class UpdateNameTestCase(BaseTestCase):
self.check = Check(user=self.alice)
self.check.save()
+ self.url = "/checks/%s/name/" % self.check.code
+
def test_it_works(self):
- url = "/checks/%s/name/" % self.check.code
payload = {"name": "Alice Was Here"}
self.client.login(username="alice@example.org", password="password")
- r = self.client.post(url, data=payload)
+ r = self.client.post(self.url, data=payload)
self.assertRedirects(r, "/checks/")
- check = Check.objects.get(code=self.check.code)
- assert check.name == "Alice Was Here"
+ self.check.refresh_from_db()
+ self.assertEqual(self.check.name, "Alice Was Here")
def test_team_access_works(self):
- url = "/checks/%s/name/" % self.check.code
payload = {"name": "Bob Was Here"}
# Logging in as bob, not alice. Bob has team access so this
# should work.
self.client.login(username="bob@example.org", password="password")
- self.client.post(url, data=payload)
+ self.client.post(self.url, data=payload)
- check = Check.objects.get(code=self.check.code)
- assert check.name == "Bob Was Here"
+ self.check.refresh_from_db()
+ self.assertEqual(self.check.name, "Bob Was Here")
def test_it_checks_ownership(self):
- url = "/checks/%s/name/" % self.check.code
payload = {"name": "Charlie Sent This"}
self.client.login(username="charlie@example.org", password="password")
- r = self.client.post(url, data=payload)
- assert r.status_code == 403
+ r = self.client.post(self.url, data=payload)
+ self.assertEqual(r.status_code, 403)
def test_it_handles_bad_uuid(self):
url = "/checks/not-uuid/name/"
@@ -55,20 +54,18 @@ class UpdateNameTestCase(BaseTestCase):
self.client.login(username="alice@example.org", password="password")
r = self.client.post(url, data=payload)
- assert r.status_code == 404
+ self.assertEqual(r.status_code, 404)
def test_it_sanitizes_tags(self):
- url = "/checks/%s/name/" % self.check.code
payload = {"tags": " foo bar\r\t \n baz \n"}
self.client.login(username="alice@example.org", password="password")
- self.client.post(url, data=payload)
+ self.client.post(self.url, data=payload)
- check = Check.objects.get(id=self.check.id)
- self.assertEqual(check.tags, "foo bar baz")
+ self.check.refresh_from_db()
+ self.assertEqual(self.check.tags, "foo bar baz")
def test_it_rejects_get(self):
- url = "/checks/%s/name/" % self.check.code
self.client.login(username="alice@example.org", password="password")
- r = self.client.get(url)
+ r = self.client.get(self.url)
self.assertEqual(r.status_code, 405)
diff --git a/hc/front/urls.py b/hc/front/urls.py
index 20e430b0..be5e65dd 100644
--- a/hc/front/urls.py
+++ b/hc/front/urls.py
@@ -38,6 +38,7 @@ channel_urls = [
path('add_trello/', views.add_trello, name="hc-add-trello"),
path('add_trello/settings/', views.trello_settings, name="hc-trello-settings"),
path('Type | -Value | -Assigned Checks | ++ | Name, Details | +Assigned Checks | +Status | Last Notification | |
---|---|---|---|---|---|---|---|---|
{{ ch.get_kind_display }} | -- {% if ch.kind == "email" %} - to - {{ ch.value }} - {% if not ch.email_verified %} - {% if ch.latest_notification and ch.latest_notification.error %} - - (bounced, disabled) - + | + + | +
+
+ {% if ch.name %}
+ {{ ch.name }}
+ {% else %}
+
+ unnamed
+ {% endif %}
+
+ {% if ch.kind == "email" %}
+ Email to {{ ch.value }}
+ {% elif ch.kind == "pd" %}
+ PagerDuty account {{ ch.pd_account }}
+ {% elif ch.kind == "pagertree" %}
+ PagerTree
+ {% elif ch.kind == "opsgenie" %}
+ OpsGenie
+ {% elif ch.kind == "victorops" %}
+ VictorOps
+ {% elif ch.kind == "po" %}
+ Pushover ({{ ch.po_value|last }} priority)
+ {% elif ch.kind == "slack" %}
+ Slack
+ {% if ch.slack_team %}
+ team {{ ch.slack_team }},
+ channel {{ ch.slack_channel }}
+ {% endif %}
+ {% elif ch.kind == "webhook" %}
+ Webhook
+ {% elif ch.kind == "pushbullet" %}
+ Pushbullet
+ {% elif ch.kind == "discord" %}
+ Discord
+ {% elif ch.kind == "telegram" %}
+ Telegram
+ {% if ch.telegram_type == "group" %}
+ chat {{ ch.telegram_name }}
+ {% elif ch.telegram_type == "private" %}
+ user {{ ch.telegram_name }}
+ {% endif %}
+ {% elif ch.kind == "hipchat" %}
+ HipChat
+ {% elif ch.kind == "sms" %}
+ SMS to {{ ch.sms_number }}
+ {% elif ch.kind == "trello" %}
+ Trello
+ board {{ ch.trello_board_list|first }},
+ list {{ ch.trello_board_list|last }}
{% else %}
-
- (unconfirmed)
-
+ {{ ch.kind }}
{% endif %}
-
- {% endif %}
- {% elif ch.kind == "pd" %}
- {% if ch.pd_account %}
- account
- {{ ch.pd_account}},
- {% endif %}
- service key
- {{ ch.pd_service_key }}
- {% elif ch.kind == "pagertree" %}
- URL
- {{ ch.value }}
- {% elif ch.kind == "opsgenie" %}
- API key
- {{ ch.value }}
- {% elif ch.kind == "victorops" %}
- Post URL
- {{ ch.value }}
- {% elif ch.kind == "po" %}
- user key
- {{ ch.po_value|first }}
- ({{ ch.po_value|last }} priority)
- {% elif ch.kind == "slack" %}
- {% if ch.slack_team %}
- team
- {{ ch.slack_team }},
- channel
- {{ ch.slack_channel }}
- {% else %}
- {{ ch.value }}
- {% endif %}
- {% elif ch.kind == "webhook" %}
- {% if ch.url_down %}
- down {{ ch.url_down }}
- {% endif %}
- {% if ch.url_up and not ch.url_down %}
- up {{ ch.url_up }}
- {% endif %}
- {% if ch.url_up or ch.post_data or ch.headers %}
- (details)
- {% endif %}
-
-
- {% elif ch.kind == "pushbullet" %}
- API key
- {{ ch.value }}
- {% elif ch.kind == "discord" %}
- {{ ch.discord_webhook_id }}
- {% elif ch.kind == "telegram" %}
- {% if ch.telegram_type == "group" %}
- chat
- {% elif ch.telegram_type == "private" %}
- user
- {% endif %}
- {{ ch.telegram_name }}
- {% elif ch.kind == "hipchat" %}
- {{ ch.hipchat_webhook_url }}
- {% elif ch.kind == "zendesk" %}
- {{ ch.zendesk_subdomain }}.zendesk.com
- {% elif ch.kind == "sms" %}
- {% if ch.sms_label %}
- {{ ch.sms_label }} ({{ ch.sms_number }})
+
+ |
+
+
+ {{ ch.n_checks }} checks
+
+ |
+ + {% if ch.kind == "email" and not ch.email_verified %} + {% if n and n.error %} + Disabled {% else %} - {{ ch.sms_number }} + Unconfirmed {% endif %} - {% elif ch.kind == "trello" %} - board - {{ ch.trello_board_list|first }}, - list - {{ ch.trello_board_list|last }} {% else %} - {{ ch.value }} + Ready to deliver {% endif %} | -- - {{ ch.n_checks }} of {{ num_checks }} - - |
- {% with n=ch.latest_notification %}
{% if n %}
{% if n.error %}
@@ -140,7 +120,6 @@
{% if ch.kind == "sms" %}
Used {{ profile.sms_sent_this_month }} of {{ profile.sms_limit }} sends this month. {% endif %} - {% endwith %} |