@ -29,7 +29,7 @@ class DetailsTestCase(BaseTestCase): | |||
def test_it_checks_ownership(self): | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.get(self.url) | |||
assert r.status_code == 403 | |||
self.assertEqual(r.status_code, 404) | |||
def test_it_shows_cron_expression(self): | |||
self.check.kind = "cron" | |||
@ -38,3 +38,11 @@ class DetailsTestCase(BaseTestCase): | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.get(self.url) | |||
self.assertContains(r, "Cron Expression", status_code=200) | |||
def test_it_allows_cross_team_access(self): | |||
self.bobs_profile.current_team = None | |||
self.bobs_profile.save() | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.get(self.url) | |||
self.assertEqual(r.status_code, 200) |
@ -52,7 +52,7 @@ class LogTestCase(BaseTestCase): | |||
url = "/checks/%s/log/" % self.check.code | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.get(url) | |||
self.assertEqual(r.status_code, 403) | |||
self.assertEqual(r.status_code, 404) | |||
def test_it_shows_pushover_notifications(self): | |||
ch = Channel(kind="po", user=self.alice) | |||
@ -77,3 +77,12 @@ class LogTestCase(BaseTestCase): | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.get(url) | |||
self.assertContains(r, "Called webhook foo/$NAME", status_code=200) | |||
def test_it_allows_cross_team_access(self): | |||
self.bobs_profile.current_team = None | |||
self.bobs_profile.save() | |||
url = "/checks/%s/log/" % self.check.code | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.get(url) | |||
self.assertEqual(r.status_code, 200) |
@ -24,3 +24,13 @@ class PauseTestCase(BaseTestCase): | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.get(url) | |||
self.assertEqual(r.status_code, 405) | |||
def test_it_allows_cross_team_access(self): | |||
self.bobs_profile.current_team = None | |||
self.bobs_profile.save() | |||
url = "/checks/%s/pause/" % self.check.code | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(url) | |||
self.assertRedirects(r, "/checks/") |
@ -17,7 +17,7 @@ class LastPingTestCase(BaseTestCase): | |||
def test_it_requires_user(self): | |||
check = Check.objects.create() | |||
r = self.client.get("/checks/%s/last_ping/" % check.code) | |||
self.assertEqual(r.status_code, 403) | |||
self.assertEqual(r.status_code, 404) | |||
def test_it_accepts_n(self): | |||
check = Check(user=self.alice) | |||
@ -34,3 +34,16 @@ class LastPingTestCase(BaseTestCase): | |||
r = self.client.get("/checks/%s/pings/2/" % check.code) | |||
self.assertContains(r, "bar-456", status_code=200) | |||
def test_it_allows_cross_team_access(self): | |||
self.bobs_profile.current_team = None | |||
self.bobs_profile.save() | |||
check = Check(user=self.alice) | |||
check.save() | |||
Ping.objects.create(owner=check, body="this is body") | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.get("/checks/%s/last_ping/" % check.code) | |||
self.assertEqual(r.status_code, 200) |
@ -9,37 +9,32 @@ class RemoveCheckTestCase(BaseTestCase): | |||
self.check = Check(user=self.alice) | |||
self.check.save() | |||
def test_it_works(self): | |||
url = "/checks/%s/remove/" % self.check.code | |||
self.remove_url = "/checks/%s/remove/" % self.check.code | |||
def test_it_works(self): | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(url) | |||
r = self.client.post(self.remove_url) | |||
self.assertRedirects(r, "/checks/") | |||
assert Check.objects.count() == 0 | |||
self.assertEqual(Check.objects.count(), 0) | |||
def test_team_access_works(self): | |||
url = "/checks/%s/remove/" % self.check.code | |||
# Logging in as bob, not alice. Bob has team access so this | |||
# should work. | |||
self.client.login(username="[email protected]", password="password") | |||
self.client.post(url) | |||
assert Check.objects.count() == 0 | |||
self.client.post(self.remove_url) | |||
def test_it_handles_bad_uuid(self): | |||
url = "/checks/not-uuid/remove/" | |||
self.assertEqual(Check.objects.count(), 0) | |||
def test_it_handles_bad_uuid(self): | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(url) | |||
r = self.client.post("/checks/not-uuid/remove/") | |||
self.assertEqual(r.status_code, 404) | |||
def test_it_checks_owner(self): | |||
url = "/checks/%s/remove/" % self.check.code | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(url) | |||
assert r.status_code == 403 | |||
r = self.client.post(self.remove_url) | |||
self.assertEqual(r.status_code, 404) | |||
def test_it_handles_missing_uuid(self): | |||
# Valid UUID but there is no check for it: | |||
@ -47,10 +42,17 @@ class RemoveCheckTestCase(BaseTestCase): | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(url) | |||
assert r.status_code == 404 | |||
self.assertEqual(r.status_code, 404) | |||
def test_it_rejects_get(self): | |||
url = "/checks/%s/remove/" % self.check.code | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.get(url) | |||
r = self.client.get(self.remove_url) | |||
self.assertEqual(r.status_code, 405) | |||
def test_it_allows_cross_team_access(self): | |||
self.bobs_profile.current_team = None | |||
self.bobs_profile.save() | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(self.remove_url) | |||
self.assertRedirects(r, "/checks/") |
@ -46,3 +46,11 @@ class StatusSingleTestCase(BaseTestCase): | |||
doc = r.json() | |||
self.assertFalse("events" in doc) | |||
def test_it_allows_cross_team_access(self): | |||
self.bobs_profile.current_team = None | |||
self.bobs_profile.save() | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.get("/checks/%s/status/" % self.check.code) | |||
self.assertEqual(r.status_code, 200) |
@ -32,7 +32,7 @@ class SwitchChannelTestCase(BaseTestCase): | |||
def test_it_checks_ownership(self): | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(self.url, {"state": "on"}) | |||
self.assertEqual(r.status_code, 403) | |||
self.assertEqual(r.status_code, 404) | |||
def test_it_checks_channels_ownership(self): | |||
cc = Check(user=self.charlie) | |||
@ -43,4 +43,12 @@ class SwitchChannelTestCase(BaseTestCase): | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(self.url, {"state": "on"}) | |||
self.assertEqual(r.status_code, 403) | |||
self.assertEqual(r.status_code, 400) | |||
def test_it_allows_cross_team_access(self): | |||
self.bobs_profile.current_team = None | |||
self.bobs_profile.save() | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(self.url, {"state": "on"}) | |||
self.assertEqual(r.status_code, 200) |
@ -12,10 +12,8 @@ class UpdateNameTestCase(BaseTestCase): | |||
self.url = "/checks/%s/name/" % self.check.code | |||
def test_it_works(self): | |||
payload = {"name": "Alice Was Here"} | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(self.url, data=payload) | |||
r = self.client.post(self.url, data={"name": "Alice Was Here"}) | |||
self.assertRedirects(r, "/checks/") | |||
self.check.refresh_from_db() | |||
@ -32,12 +30,22 @@ class UpdateNameTestCase(BaseTestCase): | |||
self.check.refresh_from_db() | |||
self.assertEqual(self.check.name, "Bob Was Here") | |||
def test_it_allows_cross_team_access(self): | |||
# Bob's current team is not set | |||
self.bobs_profile.current_team = None | |||
self.bobs_profile.save() | |||
# But this should still work: | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(self.url, data={"name": "Bob Was Here"}) | |||
self.assertRedirects(r, "/checks/") | |||
def test_it_checks_ownership(self): | |||
payload = {"name": "Charlie Sent This"} | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(self.url, data=payload) | |||
self.assertEqual(r.status_code, 403) | |||
self.assertEqual(r.status_code, 404) | |||
def test_it_handles_bad_uuid(self): | |||
url = "/checks/not-uuid/name/" | |||
@ -145,10 +145,21 @@ class UpdateTimeoutTestCase(BaseTestCase): | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(url, data=payload) | |||
assert r.status_code == 403 | |||
self.assertEqual(r.status_code, 404) | |||
def test_it_rejects_get(self): | |||
url = "/checks/%s/timeout/" % self.check.code | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.get(url) | |||
self.assertEqual(r.status_code, 405) | |||
def test_it_allows_cross_team_access(self): | |||
self.bobs_profile.current_team = None | |||
self.bobs_profile.save() | |||
url = "/checks/%s/timeout/" % self.check.code | |||
payload = {"kind": "simple", "timeout": 3600, "grace": 60} | |||
self.client.login(username="[email protected]", password="password") | |||
r = self.client.post(url, data=payload) | |||
self.assertRedirects(r, "/checks/") |