test_organization_security_privacy.py 3.7 KB

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