test_project_keys.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. from datetime import datetime
  2. from django.utils import timezone
  3. from sentry.models import ProjectKey
  4. from sentry.testutils import AcceptanceTestCase, SnubaTestCase
  5. from sentry.testutils.silo import region_silo_test
  6. @region_silo_test
  7. class ProjectKeysTest(AcceptanceTestCase, SnubaTestCase):
  8. def setUp(self):
  9. super().setUp()
  10. self.user = self.create_user("foo@example.com")
  11. self.org = self.create_organization(name="Rowdy Tiger", owner=None)
  12. self.team = self.create_team(organization=self.org, name="Mariachi Band")
  13. self.project = self.create_project(organization=self.org, teams=[self.team], name="Bengal")
  14. self.create_member(user=self.user, organization=self.org, role="owner", teams=[self.team])
  15. ProjectKey.objects.filter(project=self.project).delete()
  16. ProjectKey.objects.create(
  17. project=self.project,
  18. label="Default",
  19. public_key="5cc0482a13d248ff99f9717101dd6356",
  20. secret_key="410fd998318844b8894775f36184ec28",
  21. )
  22. self.login_as(self.user)
  23. self.path = f"/{self.org.slug}/{self.project.slug}/settings/keys/"
  24. def test_simple(self):
  25. self.browser.get(self.path)
  26. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  27. self.browser.wait_until_test_id("project-keys")
  28. self.browser.snapshot("project keys")
  29. @region_silo_test
  30. class ProjectKeyDetailsTest(AcceptanceTestCase, SnubaTestCase):
  31. def setUp(self):
  32. super().setUp()
  33. self.user = self.create_user("foo@example.com")
  34. self.org = self.create_organization(name="Rowdy Tiger", owner=None)
  35. self.team = self.create_team(organization=self.org, name="Mariachi Band")
  36. self.project = self.create_project(organization=self.org, teams=[self.team], name="Bengal")
  37. self.create_member(user=self.user, organization=self.org, role="owner", teams=[self.team])
  38. self.pk = ProjectKey.objects.create(
  39. project=self.project,
  40. label="Default",
  41. public_key="5cc0482a13d248ff99f9717101dd6356",
  42. secret_key="410fd998318844b8894775f36184ec28",
  43. date_added=datetime(2015, 10, 1, 21, 19, 5, 648517, tzinfo=timezone.utc),
  44. )
  45. self.login_as(self.user)
  46. self.path = f"/{self.org.slug}/{self.project.slug}/settings/keys/{self.pk.public_key}/"
  47. def test_simple(self):
  48. self.browser.get(self.path)
  49. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  50. self.browser.wait_until_test_id("key-details")
  51. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  52. self.browser.snapshot("project key details")