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.

45 lines
1.5 KiB

  1. from django.test.utils import override_settings
  2. from hc.test import BaseTestCase
  3. @override_settings(PD_VENDOR_KEY="foo")
  4. class AddPdcCompleteTestCase(BaseTestCase):
  5. def setUp(self):
  6. super().setUp()
  7. self.url = "/projects/%s/add_pdc/" % self.project.code
  8. self.url += "XXXXXXXXXXXX/?service_key=123"
  9. def test_it_validates_code(self):
  10. session = self.client.session
  11. session["pd"] = "1234567890AB"
  12. session.save()
  13. self.client.login(username="[email protected]", password="password")
  14. r = self.client.get(self.url)
  15. self.assertEqual(r.status_code, 400)
  16. @override_settings(PD_VENDOR_KEY=None)
  17. def test_it_requires_vendor_key(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. @override_settings(PD_ENABLED=False)
  22. def test_it_requires_pd_enabled(self):
  23. self.client.login(username="[email protected]", password="password")
  24. r = self.client.get(self.url)
  25. self.assertEqual(r.status_code, 404)
  26. def test_it_requires_rw_access(self):
  27. self.bobs_membership.rw = False
  28. self.bobs_membership.save()
  29. session = self.client.session
  30. session["pd"] = "1234567890AB"
  31. session.save()
  32. self.client.login(username="[email protected]", password="password")
  33. r = self.client.get(self.url)
  34. self.assertEqual(r.status_code, 403)