organizationAuthList.spec.tsx 3.9 KB

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