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.3 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
  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(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. token = self.channel.make_token()
  12. url = "/integrations/%s/verify/%s/" % (self.channel.code, token)
  13. r = self.client.get(url)
  14. assert r.status_code == 200, r.status_code
  15. channel = Channel.objects.get(code=self.channel.code)
  16. assert channel.email_verified
  17. def test_it_handles_bad_token(self):
  18. url = "/integrations/%s/verify/bad-token/" % self.channel.code
  19. r = self.client.get(url)
  20. assert r.status_code == 200, r.status_code
  21. channel = Channel.objects.get(code=self.channel.code)
  22. assert not channel.email_verified
  23. def test_missing_channel(self):
  24. # Valid UUID, and even valid token but there is no channel for it:
  25. code = "6837d6ec-fc08-4da5-a67f-08a9ed1ccf62"
  26. token = self.channel.make_token()
  27. url = "/integrations/%s/verify/%s/" % (code, token)
  28. r = self.client.get(url)
  29. assert r.status_code == 404