@ -31,7 +31,7 @@ class ChannelChecksTestCase(BaseTestCase): | |||||
url = "/integrations/%s/checks/" % self.channel.code | url = "/integrations/%s/checks/" % self.channel.code | ||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.get(url) | r = self.client.get(url) | ||||
assert r.status_code == 403 | |||||
self.assertEqual(r.status_code, 404) | |||||
def test_missing_channel(self): | def test_missing_channel(self): | ||||
# Valid UUID but there is no channel for it: | # Valid UUID but there is no channel for it: | ||||
@ -39,4 +39,4 @@ class ChannelChecksTestCase(BaseTestCase): | |||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.get(url) | r = self.client.get(url) | ||||
assert r.status_code == 404 | |||||
self.assertEqual(r.status_code, 404) |
@ -14,7 +14,7 @@ class RemoveChannelTestCase(BaseTestCase): | |||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.post(url) | r = self.client.post(url) | ||||
self.assertRedirects(r, "/integrations/") | |||||
self.assertRedirects(r, self.channels_url) | |||||
assert Channel.objects.count() == 0 | assert Channel.objects.count() == 0 | ||||
@ -37,7 +37,7 @@ class RemoveChannelTestCase(BaseTestCase): | |||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.post(url) | r = self.client.post(url) | ||||
assert r.status_code == 403 | |||||
self.assertEqual(r.status_code, 404) | |||||
def test_it_handles_missing_uuid(self): | def test_it_handles_missing_uuid(self): | ||||
# Valid UUID but there is no channel for it: | # Valid UUID but there is no channel for it: | ||||
@ -45,7 +45,7 @@ class RemoveChannelTestCase(BaseTestCase): | |||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.post(url) | r = self.client.post(url) | ||||
assert r.status_code == 302 | |||||
self.assertEqual(r.status_code, 404) | |||||
def test_it_rejects_get(self): | def test_it_rejects_get(self): | ||||
url = "/integrations/%s/remove/" % self.channel.code | url = "/integrations/%s/remove/" % self.channel.code | ||||
@ -20,7 +20,7 @@ class SendTestNotificationTestCase(BaseTestCase): | |||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.post(self.url, {}, follow=True) | r = self.client.post(self.url, {}, follow=True) | ||||
self.assertRedirects(r, "/integrations/") | |||||
self.assertRedirects(r, self.channels_url) | |||||
self.assertContains(r, "Test notification sent!") | self.assertContains(r, "Test notification sent!") | ||||
# And email should have been sent | # And email should have been sent | ||||
@ -52,7 +52,7 @@ class SendTestNotificationTestCase(BaseTestCase): | |||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.post(self.url, {}, follow=True) | r = self.client.post(self.url, {}, follow=True) | ||||
self.assertRedirects(r, "/integrations/") | |||||
self.assertRedirects(r, self.channels_url) | |||||
self.assertContains(r, "Test notification sent!") | self.assertContains(r, "Test notification sent!") | ||||
def test_it_handles_webhooks_with_no_urls(self): | def test_it_handles_webhooks_with_no_urls(self): | ||||
@ -73,5 +73,10 @@ class SendTestNotificationTestCase(BaseTestCase): | |||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.post(self.url, {}, follow=True) | r = self.client.post(self.url, {}, follow=True) | ||||
self.assertRedirects(r, "/integrations/") | |||||
self.assertRedirects(r, self.channels_url) | |||||
self.assertContains(r, "Could not send a test notification") | self.assertContains(r, "Could not send a test notification") | ||||
def test_it_checks_channel_ownership(self): | |||||
self.client.login(username="[email protected]", password="password") | |||||
r = self.client.post(self.url, {}, follow=True) | |||||
self.assertEqual(r.status_code, 404) |
@ -16,8 +16,8 @@ class UpdateChannelTestCase(BaseTestCase): | |||||
payload = {"channel": self.channel.code, "check-%s" % self.check.code: True} | payload = {"channel": self.channel.code, "check-%s" % self.check.code: True} | ||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.post("/integrations/", data=payload) | |||||
self.assertRedirects(r, "/integrations/") | |||||
r = self.client.post(self.channels_url, data=payload) | |||||
self.assertRedirects(r, self.channels_url) | |||||
channel = Channel.objects.get(code=self.channel.code) | channel = Channel.objects.get(code=self.channel.code) | ||||
checks = channel.checks.all() | checks = channel.checks.all() | ||||
@ -30,19 +30,19 @@ class UpdateChannelTestCase(BaseTestCase): | |||||
# Logging in as bob, not alice. Bob has team access so this | # Logging in as bob, not alice. Bob has team access so this | ||||
# should work. | # should work. | ||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.post("/integrations/", data=payload, follow=True) | |||||
r = self.client.post(self.channels_url, data=payload, follow=True) | |||||
self.assertEqual(r.status_code, 200) | self.assertEqual(r.status_code, 200) | ||||
def test_it_checks_channel_user(self): | def test_it_checks_channel_user(self): | ||||
payload = {"channel": self.channel.code} | payload = {"channel": self.channel.code} | ||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.post("/integrations/", data=payload) | |||||
r = self.client.post(self.channels_url, data=payload) | |||||
# self.channel does not belong to charlie, this should fail-- | # self.channel does not belong to charlie, this should fail-- | ||||
assert r.status_code == 403 | |||||
self.assertEqual(r.status_code, 404) | |||||
def test_it_checks_check_user(self): | |||||
def test_it_checks_check_owner(self): | |||||
charlies_project = Project.objects.create(owner=self.charlie) | charlies_project = Project.objects.create(owner=self.charlie) | ||||
charlies_channel = Channel(project=charlies_project, kind="email") | charlies_channel = Channel(project=charlies_project, kind="email") | ||||
charlies_channel.email = "[email protected]" | charlies_channel.email = "[email protected]" | ||||
@ -50,18 +50,18 @@ class UpdateChannelTestCase(BaseTestCase): | |||||
payload = {"channel": charlies_channel.code, "check-%s" % self.check.code: True} | payload = {"channel": charlies_channel.code, "check-%s" % self.check.code: True} | ||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.post("/integrations/", data=payload) | |||||
r = self.client.post(self.channels_url, data=payload) | |||||
# mc belongs to charlie but self.check does not-- | # mc belongs to charlie but self.check does not-- | ||||
assert r.status_code == 403 | |||||
self.assertEqual(r.status_code, 404) | |||||
def test_it_handles_missing_channel(self): | def test_it_handles_missing_channel(self): | ||||
# Correct UUID but there is no channel for it: | # Correct UUID but there is no channel for it: | ||||
payload = {"channel": "6837d6ec-fc08-4da5-a67f-08a9ed1ccf62"} | payload = {"channel": "6837d6ec-fc08-4da5-a67f-08a9ed1ccf62"} | ||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.post("/integrations/", data=payload) | |||||
assert r.status_code == 400 | |||||
r = self.client.post(self.channels_url, data=payload) | |||||
self.assertEqual(r.status_code, 400) | |||||
def test_it_handles_missing_check(self): | def test_it_handles_missing_check(self): | ||||
# check- key has a correct UUID but there's no check object for it | # check- key has a correct UUID but there's no check object for it | ||||
@ -71,5 +71,5 @@ class UpdateChannelTestCase(BaseTestCase): | |||||
} | } | ||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.post("/integrations/", data=payload) | |||||
assert r.status_code == 400 | |||||
r = self.client.post(self.channels_url, data=payload) | |||||
self.assertEqual(r.status_code, 400) |
@ -15,7 +15,7 @@ class UpdateChannelNameTestCase(BaseTestCase): | |||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.post(self.url, data=payload) | r = self.client.post(self.url, data=payload) | ||||
self.assertRedirects(r, "/integrations/") | |||||
self.assertRedirects(r, self.channels_url) | |||||
self.channel.refresh_from_db() | self.channel.refresh_from_db() | ||||
self.assertEqual(self.channel.name, "My work email") | self.assertEqual(self.channel.name, "My work email") | ||||
@ -36,7 +36,7 @@ class UpdateChannelNameTestCase(BaseTestCase): | |||||
self.client.login(username="[email protected]", password="password") | self.client.login(username="[email protected]", password="password") | ||||
r = self.client.post(self.url, data=payload) | r = self.client.post(self.url, data=payload) | ||||
self.assertEqual(r.status_code, 403) | |||||
self.assertEqual(r.status_code, 404) | |||||
def test_it_handles_missing_uuid(self): | def test_it_handles_missing_uuid(self): | ||||
# Valid UUID but there is no check for it: | # Valid UUID but there is no check for it: | ||||