index.spec.tsx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {ProjectFixture} from 'sentry-fixture/project';
  3. import {initializeOrg} from 'sentry-test/initializeOrg';
  4. import {render, screen} from 'sentry-test/reactTestingLibrary';
  5. import ProjectSecurityAndPrivacy from 'sentry/views/settings/projectSecurityAndPrivacy';
  6. describe('projectSecurityAndPrivacy', function () {
  7. it('renders form fields', function () {
  8. const organization = OrganizationFixture({features: ['event-attachments']});
  9. const project = ProjectFixture({
  10. sensitiveFields: ['creditcard', 'ssn'],
  11. safeFields: ['business-email', 'company'],
  12. });
  13. render(<ProjectSecurityAndPrivacy project={project} organization={organization} />);
  14. // Store Minidumps As Attachments
  15. expect(
  16. screen.getByRole('textbox', {
  17. name: 'Store Minidumps As Attachments',
  18. })
  19. ).not.toHaveValue();
  20. expect(screen.getByText(/Inherit organization settings/)).toBeInTheDocument();
  21. expect(
  22. screen.getByRole('checkbox', {
  23. name: 'Enable server-side data scrubbing',
  24. })
  25. ).not.toBeChecked();
  26. expect(
  27. screen.getByRole('checkbox', {
  28. name: 'Enable to apply default scrubbers to prevent things like passwords and credit cards from being stored',
  29. })
  30. ).not.toBeChecked();
  31. expect(
  32. screen.getByRole('checkbox', {
  33. name: 'Enable to prevent IP addresses from being stored for new events',
  34. })
  35. ).not.toBeChecked();
  36. expect(
  37. screen.getByRole('textbox', {
  38. name: 'Enter field names which data scrubbers should ignore. Separate multiple entries with a newline',
  39. })
  40. ).toHaveValue('business-email\ncompany');
  41. expect(
  42. screen.getByRole('textbox', {
  43. name: 'Enter additional field names to match against when scrubbing data. Separate multiple entries with a newline',
  44. })
  45. ).toHaveValue('creditcard\nssn');
  46. expect(
  47. screen.getByRole('textbox', {
  48. name: 'Enter additional field names to match against when scrubbing data. Separate multiple entries with a newline',
  49. })
  50. ).toHaveValue('creditcard\nssn');
  51. });
  52. it('disables field when equivalent org setting is true', function () {
  53. const {organization} = initializeOrg();
  54. const project = ProjectFixture();
  55. organization.dataScrubber = true;
  56. organization.scrubIPAddresses = false;
  57. MockApiClient.addMockResponse({
  58. url: `/projects/${organization.slug}/${project.slug}/`,
  59. method: 'GET',
  60. body: project,
  61. });
  62. render(<ProjectSecurityAndPrivacy project={project} organization={organization} />);
  63. expect(
  64. screen.getByRole('checkbox', {
  65. name: 'Enable to prevent IP addresses from being stored for new events',
  66. })
  67. ).toBeEnabled();
  68. expect(
  69. screen.getByRole('checkbox', {
  70. name: 'Enable to prevent IP addresses from being stored for new events',
  71. })
  72. ).not.toBeChecked();
  73. expect(
  74. screen.getByRole('checkbox', {name: 'Enable server-side data scrubbing'})
  75. ).toBeDisabled();
  76. expect(
  77. screen.getByRole('checkbox', {name: 'Enable server-side data scrubbing'})
  78. ).toBeChecked();
  79. });
  80. it('disables fields when missing project:write access', function () {
  81. const {organization} = initializeOrg({
  82. organization: {
  83. access: [], // Remove all access
  84. },
  85. });
  86. const project = ProjectFixture();
  87. render(<ProjectSecurityAndPrivacy project={project} organization={organization} />);
  88. // Check that the data scrubber toggle is disabled
  89. expect(
  90. screen.getByRole('checkbox', {
  91. name: 'Enable server-side data scrubbing',
  92. })
  93. ).toBeDisabled();
  94. });
  95. });