You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.7 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. from hc.api.models import Channel, Check
  2. from hc.test import BaseTestCase
  3. class ChannelChecksTestCase(BaseTestCase):
  4. def setUp(self):
  5. super().setUp()
  6. self.channel = Channel(project=self.project, kind="email")
  7. self.channel.value = "[email protected]"
  8. self.channel.save()
  9. Check.objects.create(project=self.project, name="Database Backups")
  10. def test_it_works(self):
  11. url = "/integrations/%s/checks/" % self.channel.code
  12. self.client.login(username="[email protected]", password="password")
  13. r = self.client.get(url)
  14. self.assertContains(r, "Database Backups")
  15. self.assertContains(r, "Assign Checks to Integration", status_code=200)
  16. def test_team_access_works(self):
  17. url = "/integrations/%s/checks/" % self.channel.code
  18. # Logging in as bob, not alice. Bob has team access so this
  19. # should work.
  20. self.client.login(username="[email protected]", password="password")
  21. r = self.client.get(url)
  22. self.assertContains(r, "Assign Checks to Integration", status_code=200)
  23. def test_it_checks_owner(self):
  24. # channel does not belong to mallory so this should come back
  25. # with 403 Forbidden:
  26. url = "/integrations/%s/checks/" % self.channel.code
  27. self.client.login(username="[email protected]", password="password")
  28. r = self.client.get(url)
  29. self.assertEqual(r.status_code, 404)
  30. def test_missing_channel(self):
  31. # Valid UUID but there is no channel for it:
  32. url = "/integrations/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/checks/"
  33. self.client.login(username="[email protected]", password="password")
  34. r = self.client.get(url)
  35. self.assertEqual(r.status_code, 404)