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.

44 lines
1.6 KiB

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