forked from GithubBackups/healthchecks
parent
448721e916
commit
5321f772fe
@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
|
||||
- Implement email body decoding in the "Ping Details" dialog
|
||||
- Add a "Subject" field in the "Ping Details" dialog
|
||||
- Improve HTML email display in the "Ping Details" dialog
|
||||
- Add a link to check's details page in Slack notifications
|
||||
|
||||
## Bug Fixes
|
||||
- Fix downtime summary to handle months when the check didn't exist yet (#472)
|
||||
|
@ -41,6 +41,7 @@ POST_LOGIN_ROUTES = (
|
||||
"hc-add-pushover",
|
||||
"hc-add-telegram",
|
||||
"hc-project-settings",
|
||||
"hc-uncloak",
|
||||
)
|
||||
|
||||
FIDO2_SERVER = Fido2Server(PublicKeyCredentialRpEntity(settings.RP_ID, "healthchecks"))
|
||||
|
@ -118,6 +118,9 @@ class Check(models.Model):
|
||||
def details_url(self):
|
||||
return settings.SITE_ROOT + reverse("hc-details", args=[self.code])
|
||||
|
||||
def cloaked_url(self):
|
||||
return settings.SITE_ROOT + reverse("hc-uncloak", args=[self.unique_key])
|
||||
|
||||
def email(self):
|
||||
return "%s@%s" % (self.code, settings.PING_EMAIL_DOMAIN)
|
||||
|
||||
|
@ -39,6 +39,9 @@ class NotifyTestCase(BaseTestCase):
|
||||
fields = {f["title"]: f["value"] for f in attachment["fields"]}
|
||||
self.assertEqual(fields["Last Ping"], "an hour ago")
|
||||
|
||||
uncloak_url = "/cloaked/%s/" % self.check.unique_key
|
||||
self.assertTrue(attachment["title_link"].endswith(uncloak_url))
|
||||
|
||||
@patch("hc.api.transports.requests.request")
|
||||
def test_slack_with_complex_value(self, mock_post):
|
||||
v = json.dumps({"incoming_webhook": {"url": "123"}})
|
||||
|
29
hc/front/tests/test_uncloak.py
Normal file
29
hc/front/tests/test_uncloak.py
Normal file
@ -0,0 +1,29 @@
|
||||
from hc.api.models import Check
|
||||
from hc.test import BaseTestCase
|
||||
|
||||
|
||||
class UncloakTestCase(BaseTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.check = Check.objects.create(project=self.project, status="paused")
|
||||
self.url = "/cloaked/%s/" % self.check.unique_key
|
||||
self.redirect_url = "/checks/%s/details/" % self.check.code
|
||||
|
||||
def test_it_redirects(self):
|
||||
self.client.login(username="alice@example.org", password="password")
|
||||
r = self.client.get(self.url)
|
||||
self.assertRedirects(r, self.redirect_url)
|
||||
|
||||
def test_it_handles_bad_unique_key(self):
|
||||
self.client.login(username="alice@example.org", password="password")
|
||||
r = self.client.get("/cloaked/0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33/")
|
||||
self.assertEqual(r.status_code, 404)
|
||||
|
||||
def test_it_checks_access(self):
|
||||
self.client.login(username="charlie@example.org", password="password")
|
||||
r = self.client.get(self.url)
|
||||
self.assertEqual(r.status_code, 404)
|
||||
|
||||
def test_it_requires_logged_in_user(self):
|
||||
r = self.client.get(self.url)
|
||||
self.assertRedirects(r, "/accounts/login/?next=" + self.url)
|
@ -92,6 +92,7 @@ urlpatterns = [
|
||||
path("tv/", views.dashboard, name="hc-dashboard"),
|
||||
path("checks/cron_preview/", views.cron_preview),
|
||||
path("checks/<uuid:code>/", include(check_urls)),
|
||||
path("cloaked/<sha1:unique_key>/", views.uncloak, name="hc-uncloak"),
|
||||
path("integrations/", include(channel_urls)),
|
||||
path("projects/<uuid:code>/", include(project_urls)),
|
||||
path("docs/", views.serve_doc, name="hc-docs"),
|
||||
|
@ -637,6 +637,15 @@ def details(request, code):
|
||||
return render(request, "front/details.html", ctx)
|
||||
|
||||
|
||||
@login_required
|
||||
def uncloak(request, unique_key):
|
||||
for check in request.profile.checks_from_all_projects().only("code"):
|
||||
if check.unique_key == unique_key:
|
||||
return redirect("hc-details", check.code)
|
||||
|
||||
raise Http404("not found")
|
||||
|
||||
|
||||
@login_required
|
||||
def transfer(request, code):
|
||||
check = _get_rw_check_for_user(request, code)
|
||||
|
@ -11,7 +11,8 @@
|
||||
|
||||
"fallback": "The check \"{{ check.name_then_code|escapejs }}\" is {{ check.status|upper }}.",
|
||||
"mrkdwn_in": ["fields"],
|
||||
"text": "“{{ check.name_then_code|escapejs }}” is {{ check.status|upper }}.",
|
||||
"title": "“{{ check.name_then_code|escapejs }}” is {{ check.status|upper }}.",
|
||||
"title_link": "{{ check.cloaked_url }}",
|
||||
"fields": [
|
||||
{% if check.desc %}
|
||||
{"title": "Description",
|
||||
|
Loading…
x
Reference in New Issue
Block a user