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.

43 lines
1.6 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
  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.value = "[email protected]"
  8. self.channel.save()
  9. def test_it_works(self):
  10. url = "/integrations/%s/checks/" % self.channel.code
  11. self.client.login(username="[email protected]", password="password")
  12. r = self.client.get(url)
  13. self.assertContains(r, "Assign Checks to Integration", status_code=200)
  14. def test_team_access_works(self):
  15. url = "/integrations/%s/checks/" % self.channel.code
  16. # Logging in as bob, not alice. Bob has team access so this
  17. # should work.
  18. self.client.login(username="[email protected]", password="password")
  19. r = self.client.get(url)
  20. self.assertContains(r, "Assign Checks to Integration", status_code=200)
  21. def test_it_checks_owner(self):
  22. # channel does not belong to mallory so this should come back
  23. # with 403 Forbidden:
  24. url = "/integrations/%s/checks/" % self.channel.code
  25. self.client.login(username="[email protected]", password="password")
  26. r = self.client.get(url)
  27. assert r.status_code == 403
  28. def test_missing_channel(self):
  29. # Valid UUID but there is no channel for it:
  30. url = "/integrations/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/checks/"
  31. self.client.login(username="[email protected]", password="password")
  32. r = self.client.get(url)
  33. assert r.status_code == 404