test_organization_security_privacy.py 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. from sentry.testutils import AcceptanceTestCase
  2. from sentry.testutils.silo import region_silo_test
  3. from sentry.utils import json
  4. @region_silo_test
  5. class OrganizationSecurityAndPrivacyTest(AcceptanceTestCase):
  6. def setUp(self):
  7. super().setUp()
  8. self.user = self.create_user("owner@example.com")
  9. self.org = self.create_organization(owner=self.user, name="Rowdy Tiger")
  10. self.login_as(self.user)
  11. self.path = f"/settings/{self.org.slug}/security-and-privacy/"
  12. def load_organization_helper(self, snapshot_name=None):
  13. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  14. if snapshot_name is not None:
  15. self.browser.snapshot("organization settings security and privacy -- " + snapshot_name)
  16. assert self.browser.wait_until(
  17. '[data-test-id="organization-settings-security-and-privacy"]'
  18. )
  19. def renders_2fa_setting(self):
  20. return self.browser.wait_until("#require2FA")
  21. def test_renders_2fa_setting_for_owner(self):
  22. self.browser.get(self.path)
  23. self.load_organization_helper()
  24. assert self.renders_2fa_setting()
  25. def test_renders_2fa_setting_for_manager(self):
  26. manager_user = self.create_user("manager@example.com")
  27. self.create_member(organization=self.org, user=manager_user, role="manager")
  28. self.login_as(manager_user)
  29. self.browser.get(self.path)
  30. self.load_organization_helper()
  31. assert self.renders_2fa_setting()
  32. def test_setting_2fa_without_2fa_enabled(self):
  33. self.browser.get(self.path)
  34. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  35. assert not self.browser.element_exists(
  36. '[data-test-id="organization-settings-security-and-privacy"] .error'
  37. )
  38. self.browser.click("#require2FA")
  39. self.browser.wait_until("[role='dialog']")
  40. self.browser.click("[role='dialog'] [data-test-id='confirm-button']")
  41. self.browser.wait_until_not("[role='dialog']")
  42. self.browser.wait_until_test_id("toast-error")
  43. self.load_organization_helper("setting 2fa without 2fa enabled")
  44. def test_renders_advanced_data_scrubbing_without_rule(self):
  45. self.browser.get(self.path)
  46. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  47. assert self.browser.wait_until('[data-test-id="advanced-data-scrubbing"]')
  48. self.load_organization_helper("advanced-data-scrubbing-without-rule")
  49. def test_renders_advanced_data_scrubbing_with_rules(self):
  50. relayPiiConfig = json.dumps(
  51. {
  52. "rules": {
  53. "0": {
  54. "type": "password",
  55. "redaction": {"method": "replace", "text": "Scrubbed"},
  56. },
  57. "1": {"type": "creditcard", "redaction": {"method": "mask"}},
  58. },
  59. "applications": {"password": ["0"], "$message": ["1"]},
  60. }
  61. )
  62. self.org.update_option("sentry:relay_pii_config", relayPiiConfig)
  63. self.browser.get(self.path)
  64. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  65. assert self.browser.wait_until('[data-test-id="advanced-data-scrubbing"]')
  66. assert self.browser.wait_until('[data-test-id="advanced-data-scrubbing-rules"]')
  67. self.load_organization_helper("advanced-data-scrubbing-with-rules")
  68. def test_renders_advanced_data_scrubbing_add_rule_modal(self):
  69. self.browser.get(self.path)
  70. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  71. assert self.browser.wait_until('[data-test-id="advanced-data-scrubbing"]')
  72. self.browser.click_when_visible("[aria-label='Add Rule']")
  73. self.load_organization_helper("advanced-data-scrubbing-add-rule-modal")