test_accept_organization_invite.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. from django.db.models import F
  2. from sentry.models import AuthProvider, Organization
  3. from sentry.testutils.cases import AcceptanceTestCase
  4. from sentry.testutils.silo import no_silo_test
  5. # When we want to set this stable=True, we'll need to configure regions in order for invites to work.
  6. # See the accept_organization_invite.py#get_invite_state logic
  7. @no_silo_test(stable=True)
  8. class AcceptOrganizationInviteTest(AcceptanceTestCase):
  9. def setUp(self):
  10. super().setUp()
  11. self.user = self.create_user("foo@example.com")
  12. self.org = self.create_organization(name="Rowdy Tiger", owner=None)
  13. self.team = self.create_team(organization=self.org, name="Mariachi Band")
  14. self.member = self.create_member(
  15. user=None,
  16. email="bar@example.com",
  17. organization=self.org,
  18. role="owner",
  19. teams=[self.team],
  20. )
  21. def test_invite_simple(self):
  22. self.login_as(self.user)
  23. self.browser.get(self.member.get_invite_link().split("/", 3)[-1])
  24. self.browser.wait_until('[data-test-id="accept-invite"]')
  25. assert self.browser.element_exists('[data-test-id="join-organization"]')
  26. def test_invite_not_authenticated(self):
  27. self.browser.get(self.member.get_invite_link().split("/", 3)[-1])
  28. self.browser.wait_until('[data-test-id="accept-invite"]')
  29. assert self.browser.element_exists('[data-test-id="create-account"]')
  30. def test_invite_2fa_enforced_org(self):
  31. self.org.update(flags=F("flags").bitor(Organization.flags.require_2fa))
  32. self.browser.get(self.member.get_invite_link().split("/", 3)[-1])
  33. self.browser.wait_until('[data-test-id="accept-invite"]')
  34. assert not self.browser.element_exists_by_test_id("2fa-warning")
  35. self.login_as(self.user)
  36. self.org.update(flags=F("flags").bitor(Organization.flags.require_2fa))
  37. self.browser.get(self.member.get_invite_link().split("/", 3)[-1])
  38. self.browser.wait_until('[data-test-id="accept-invite"]')
  39. assert self.browser.element_exists_by_test_id("2fa-warning")
  40. def test_invite_sso_org(self):
  41. AuthProvider.objects.create(organization_id=self.org.id, provider="google")
  42. self.browser.get(self.member.get_invite_link().split("/", 3)[-1])
  43. self.browser.wait_until('[data-test-id="accept-invite"]')
  44. assert self.browser.element_exists_by_test_id("action-info-sso")
  45. assert self.browser.element_exists('[data-test-id="sso-login"]')