organizationAuthList.spec.jsx 3.7 KB

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