mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-08 06:30:05 +00:00
Read-only users cannot resume checks.
This commit is contained in:
parent
bdf99e0ea7
commit
24c34430ac
4 changed files with 24 additions and 1 deletions
|
@ -61,3 +61,16 @@ class DetailsTestCase(BaseTestCase):
|
|||
self.assertNotContains(r, "Create a Copy…")
|
||||
self.assertNotContains(r, "transfer-btn")
|
||||
self.assertNotContains(r, "details-remove-check")
|
||||
|
||||
def test_it_hides_resume_action_from_readonly_users(self):
|
||||
self.bobs_membership.rw = False
|
||||
self.bobs_membership.save()
|
||||
|
||||
self.check.status = "paused"
|
||||
self.check.manual_resume = True
|
||||
self.check.save()
|
||||
|
||||
self.client.login(username="bob@example.org", password="password")
|
||||
r = self.client.get(self.url)
|
||||
|
||||
self.assertNotContains(r, "resume-btn", status_code=200)
|
||||
|
|
|
@ -26,3 +26,11 @@ class ResumeTestCase(BaseTestCase):
|
|||
self.client.login(username="bob@example.org", password="password")
|
||||
r = self.client.post(self.url)
|
||||
self.assertRedirects(r, self.redirect_url)
|
||||
|
||||
def test_it_requires_rw_access(self):
|
||||
self.bobs_membership.rw = False
|
||||
self.bobs_membership.save()
|
||||
|
||||
self.client.login(username="bob@example.org", password="password")
|
||||
r = self.client.post(self.url)
|
||||
self.assertEqual(r.status_code, 403)
|
||||
|
|
|
@ -494,7 +494,7 @@ def pause(request, code):
|
|||
@require_POST
|
||||
@login_required
|
||||
def resume(request, code):
|
||||
check, rw = _get_check_for_user(request, code)
|
||||
check = _get_rw_check_for_user(request, code)
|
||||
|
||||
check.status = "new"
|
||||
check.last_start = None
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
This check is late. Last ping was {{ check.last_ping|naturaltime }}.
|
||||
{% elif status == "paused" and check.manual_resume %}
|
||||
This check is paused, and will ignore pings until resumed.
|
||||
{% if rw %}
|
||||
<a id="resume-btn" href="#">(Resume Now)</a>
|
||||
{% endif %}
|
||||
{% elif status == "paused" %}
|
||||
This check is paused.
|
||||
{% elif status == "new" and check.n_pings %}
|
||||
|
|
Loading…
Add table
Reference in a new issue