test_dsyms.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import zipfile
  2. from io import BytesIO
  3. from django.core.files.uploadedfile import SimpleUploadedFile
  4. from django.test.client import RequestFactory
  5. from django.urls import reverse
  6. from fixtures.apidocs_test_case import APIDocsTestCase
  7. from sentry.testutils.silo import region_silo_test
  8. @region_silo_test
  9. class ProjectDsymsDocs(APIDocsTestCase):
  10. def setUp(self):
  11. self.url = reverse(
  12. "sentry-api-0-dsym-files",
  13. kwargs={"organization_slug": self.organization.slug, "project_slug": self.project.slug},
  14. )
  15. self.create_dif_file(project=self.project)
  16. self.login_as(user=self.user)
  17. def test_get(self):
  18. response = self.client.get(self.url)
  19. request = RequestFactory().get(self.url)
  20. self.validate_schema(request, response)
  21. def test_post(self):
  22. PROGUARD_UUID = "6dc7fdb0-d2fb-4c8e-9d6b-bb1aa98929b1"
  23. PROGUARD_SOURCE = b"""\
  24. org.slf4j.helpers.Util$ClassContextSecurityManager -> org.a.b.g$a:
  25. 65:65:void <init>() -> <init>
  26. 67:67:java.lang.Class[] getClassContext() -> getClassContext
  27. 65:65:void <init>(org.slf4j.helpers.Util$1) -> <init>
  28. """
  29. out = BytesIO()
  30. f = zipfile.ZipFile(out, "w")
  31. f.writestr("proguard/%s.txt" % PROGUARD_UUID, PROGUARD_SOURCE)
  32. f.close()
  33. data = {
  34. "file": SimpleUploadedFile(
  35. "symbols.zip", out.getvalue(), content_type="application/zip"
  36. ),
  37. }
  38. response = self.client.post(
  39. self.url,
  40. data,
  41. format="multipart",
  42. )
  43. request = RequestFactory().post(self.url, data)
  44. self.validate_schema(request, response)