test_project_keys.py 2.5 KB

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