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.

40 lines
1.4 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 django.contrib.auth.models import User
  2. from hc.api.models import Channel
  3. from hc.test import BaseTestCase
  4. class ChannelChecksTestCase(BaseTestCase):
  5. def setUp(self):
  6. super(ChannelChecksTestCase, self).setUp()
  7. self.channel = Channel(user=self.alice, kind="email")
  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, "[email protected]", status_code=200)
  15. def test_it_checks_owner(self):
  16. mallory = User(username="mallory", email="[email protected]")
  17. mallory.set_password("password")
  18. mallory.save()
  19. # channel does not belong to mallory so this should come back
  20. # with 403 Forbidden:
  21. url = "/integrations/%s/checks/" % self.channel.code
  22. self.client.login(username="[email protected]", password="password")
  23. r = self.client.get(url)
  24. assert r.status_code == 403
  25. def test_missing_channel(self):
  26. # Valid UUID but there is no channel for it:
  27. url = "/integrations/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/checks/"
  28. self.client.login(username="[email protected]", password="password")
  29. r = self.client.get(url)
  30. assert r.status_code == 404