organizationAuthList.spec.tsx 3.5 KB

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