organizationAuthList.spec.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import {AuthProvidersFixture} from 'sentry-fixture/authProviders';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {RouterContextFixture} from 'sentry-fixture/routerContextFixture';
  4. import {render, screen} from 'sentry-test/reactTestingLibrary';
  5. import {OrganizationAuthList} from 'sentry/views/settings/organizationAuth/organizationAuthList';
  6. describe('OrganizationAuthList', function () {
  7. it('renders with no providers', function () {
  8. render(
  9. <OrganizationAuthList organization={OrganizationFixture()} providerList={[]} />
  10. );
  11. expect(
  12. screen.queryByText('No authentication providers are available.')
  13. ).toBeInTheDocument();
  14. });
  15. it('renders', function () {
  16. render(
  17. <OrganizationAuthList
  18. organization={OrganizationFixture()}
  19. providerList={AuthProvidersFixture()}
  20. />
  21. );
  22. expect(screen.getAllByLabelText('Configure').length).toBe(2);
  23. expect(screen.queryByText('Dummy')).toBeInTheDocument();
  24. expect(screen.queryByText('Dummy SAML')).toBeInTheDocument();
  25. });
  26. it('renders for members', function () {
  27. const context = RouterContextFixture([
  28. {organization: OrganizationFixture({access: ['org:read']})},
  29. ]);
  30. render(
  31. <OrganizationAuthList
  32. organization={OrganizationFixture()}
  33. providerList={AuthProvidersFixture()}
  34. activeProvider={AuthProvidersFixture()[0]}
  35. />,
  36. {context}
  37. );
  38. expect(screen.getByText('Active')).toBeInTheDocument();
  39. });
  40. describe('with 2fa warning', function () {
  41. const require2fa = {require2FA: true};
  42. const withSSO = {features: ['sso-basic']};
  43. const withSAML = {features: ['sso-saml2']};
  44. it('renders', function () {
  45. const organization = OrganizationFixture({...require2fa, ...withSSO});
  46. const context = RouterContextFixture([{organization}]);
  47. render(
  48. <OrganizationAuthList
  49. organization={organization}
  50. providerList={AuthProvidersFixture()}
  51. />,
  52. {context}
  53. );
  54. expect(
  55. screen.getByText('Require 2FA will be disabled if you enable SSO.')
  56. ).toBeInTheDocument();
  57. });
  58. it('renders with saml available', function () {
  59. const organization = OrganizationFixture({...require2fa, ...withSAML});
  60. const context = RouterContextFixture([{organization}]);
  61. render(
  62. <OrganizationAuthList
  63. organization={organization}
  64. providerList={AuthProvidersFixture()}
  65. />,
  66. {context}
  67. );
  68. expect(
  69. screen.getByText('Require 2FA will be disabled if you enable SSO.')
  70. ).toBeInTheDocument();
  71. });
  72. it('does not render without sso available', function () {
  73. const organization = OrganizationFixture({...require2fa});
  74. const context = RouterContextFixture([{organization}]);
  75. render(
  76. <OrganizationAuthList
  77. organization={organization}
  78. providerList={AuthProvidersFixture()}
  79. />,
  80. {context}
  81. );
  82. expect(
  83. screen.queryByText('Require 2FA will be disabled if you enable SSO.')
  84. ).not.toBeInTheDocument();
  85. });
  86. it('does not render with sso and require 2fa disabled', function () {
  87. const organization = OrganizationFixture({...withSSO});
  88. const context = RouterContextFixture([{organization}]);
  89. render(
  90. <OrganizationAuthList
  91. organization={organization}
  92. providerList={AuthProvidersFixture()}
  93. />,
  94. {context}
  95. );
  96. expect(
  97. screen.queryByText('Require 2FA will be disabled if you enable SSO.')
  98. ).not.toBeInTheDocument();
  99. });
  100. it('does not render with saml and require 2fa disabled', function () {
  101. const organization = OrganizationFixture({...withSAML});
  102. const context = RouterContextFixture([{organization}]);
  103. render(
  104. <OrganizationAuthList
  105. organization={organization}
  106. providerList={AuthProvidersFixture()}
  107. />,
  108. {context}
  109. );
  110. expect(
  111. screen.queryByText('Require 2FA will be disabled if you enable SSO.')
  112. ).not.toBeInTheDocument();
  113. });
  114. });
  115. });