test_api_permissions.py 718 B

123456789101112131415161718192021
  1. from django.urls import reverse
  2. from model_bakery import baker
  3. from glitchtip.test_utils.test_case import APIPermissionTestCase
  4. class StatsAPIPermissionTests(APIPermissionTestCase):
  5. def setUp(self):
  6. self.create_user_org()
  7. self.set_client_credentials(self.auth_token.token)
  8. self.event = baker.make(
  9. "issue_events.IssueEvent", issue__project__organization=self.organization
  10. )
  11. self.url = reverse(
  12. "stats-v2", kwargs={"organization_slug": self.organization.slug}
  13. )
  14. def test_get(self):
  15. self.assertGetReqStatusCode(self.url, 403)
  16. self.auth_token.add_permission("org:read")
  17. self.assertGetReqStatusCode(self.url, 400)