test_project_keys.py 2.6 KB

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