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.

29 lines
1.1 KiB

  1. from hc.api.models import Check
  2. from hc.test import BaseTestCase
  3. class UncloakTestCase(BaseTestCase):
  4. def setUp(self):
  5. super().setUp()
  6. self.check = Check.objects.create(project=self.project, status="paused")
  7. self.url = "/cloaked/%s/" % self.check.unique_key
  8. self.redirect_url = "/checks/%s/details/" % self.check.code
  9. def test_it_redirects(self):
  10. self.client.login(username="[email protected]", password="password")
  11. r = self.client.get(self.url)
  12. self.assertRedirects(r, self.redirect_url)
  13. def test_it_handles_bad_unique_key(self):
  14. self.client.login(username="[email protected]", password="password")
  15. r = self.client.get("/cloaked/0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33/")
  16. self.assertEqual(r.status_code, 404)
  17. def test_it_checks_access(self):
  18. self.client.login(username="[email protected]", password="password")
  19. r = self.client.get(self.url)
  20. self.assertEqual(r.status_code, 404)
  21. def test_it_requires_logged_in_user(self):
  22. r = self.client.get(self.url)
  23. self.assertRedirects(r, "/accounts/login/?next=" + self.url)