test_accept_organization_invite.py 2.3 KB

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