test_accept_organization_invite.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. from django.db.models import F
  2. from sentry.models import AuthProvider, Organization
  3. from sentry.testutils import AcceptanceTestCase
  4. from sentry.testutils.silo import region_silo_test
  5. @region_silo_test
  6. class AcceptOrganizationInviteTest(AcceptanceTestCase):
  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.member = self.create_member(
  13. user=None,
  14. email="bar@example.com",
  15. organization=self.org,
  16. role="owner",
  17. teams=[self.team],
  18. )
  19. def test_invite_simple(self):
  20. self.login_as(self.user)
  21. self.browser.get(self.member.get_invite_link().split("/", 3)[-1])
  22. self.browser.wait_until('[data-test-id="accept-invite"]')
  23. self.browser.snapshot(name="accept organization invite")
  24. assert self.browser.element_exists('[aria-label="join-organization"]')
  25. def test_invite_not_authenticated(self):
  26. self.browser.get(self.member.get_invite_link().split("/", 3)[-1])
  27. self.browser.wait_until('[data-test-id="accept-invite"]')
  28. assert self.browser.element_exists('[aria-label="create-account"]')
  29. def test_invite_2fa_enforced_org(self):
  30. self.org.update(flags=F("flags").bitor(Organization.flags.require_2fa))
  31. self.browser.get(self.member.get_invite_link().split("/", 3)[-1])
  32. self.browser.wait_until('[data-test-id="accept-invite"]')
  33. assert not self.browser.element_exists_by_test_id("2fa-warning")
  34. self.login_as(self.user)
  35. self.org.update(flags=F("flags").bitor(Organization.flags.require_2fa))
  36. self.browser.get(self.member.get_invite_link().split("/", 3)[-1])
  37. self.browser.wait_until('[data-test-id="accept-invite"]')
  38. assert self.browser.element_exists_by_test_id("2fa-warning")
  39. def test_invite_sso_org(self):
  40. AuthProvider.objects.create(organization=self.org, provider="google")
  41. self.browser.get(self.member.get_invite_link().split("/", 3)[-1])
  42. self.browser.wait_until('[data-test-id="accept-invite"]')
  43. assert self.browser.element_exists_by_test_id("action-info-sso")
  44. assert self.browser.element_exists('[aria-label="sso-login"]')