organizationAuthList.spec.tsx 3.9 KB

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