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.

39 lines
1.3 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
  1. from hc.api.models import Channel
  2. from hc.test import BaseTestCase
  3. class VerifyEmailTestCase(BaseTestCase):
  4. def setUp(self):
  5. super(VerifyEmailTestCase, self).setUp()
  6. self.channel = Channel(project=self.project, kind="email")
  7. self.channel.value = "[email protected]"
  8. self.channel.save()
  9. def test_it_works(self):
  10. token = self.channel.make_token()
  11. url = "/integrations/%s/verify/%s/" % (self.channel.code, token)
  12. r = self.client.get(url)
  13. assert r.status_code == 200, r.status_code
  14. channel = Channel.objects.get(code=self.channel.code)
  15. assert channel.email_verified
  16. def test_it_handles_bad_token(self):
  17. url = "/integrations/%s/verify/bad-token/" % self.channel.code
  18. r = self.client.get(url)
  19. assert r.status_code == 200, r.status_code
  20. channel = Channel.objects.get(code=self.channel.code)
  21. assert not channel.email_verified
  22. def test_missing_channel(self):
  23. # Valid UUID, and even valid token but there is no channel for it:
  24. code = "6837d6ec-fc08-4da5-a67f-08a9ed1ccf62"
  25. token = self.channel.make_token()
  26. url = "/integrations/%s/verify/%s/" % (code, token)
  27. r = self.client.get(url)
  28. assert r.status_code == 404