test_authentication.py 950 B

12345678910111213141516171819202122232425
  1. from django.test import TestCase
  2. from django.urls import reverse
  3. from model_bakery import baker
  4. class AuthenticationTestCase(TestCase):
  5. @classmethod
  6. def setUpTestData(cls):
  7. cls.project = baker.make("projects.Project")
  8. cls.project_key = cls.project.projectkey_set.first()
  9. cls.organization = cls.project.organization
  10. def setUp(self):
  11. self.url = reverse(
  12. "api:event_envelope", args=[self.project.id]
  13. ) + f"?sentry_key={self.project_key.public_key}"
  14. def test_org_throttle(self):
  15. res = self.client.post(self.url, [{}], content_type="application/json")
  16. self.assertEqual(res.status_code, 200)
  17. self.organization.event_throttle_rate = 100
  18. self.organization.save()
  19. res = self.client.post(self.url, [{}], content_type="application/json")
  20. self.assertEqual(res.headers.get('Retry-After'), '600')
  21. self.assertEqual(res.status_code, 429)