0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-05 21:57:36 +08:00
discourse/spec/services/problem_check/content_security_policy_disabled_spec.rb
David Taylor 295806c725
FEATURE: Warn admins when Content Security Policy is disabled (#40791)
When disabled, admins will be shown this warning in the dashboard:

> The content-security-policy feature has been disabled. This is an
important security feature, and should never be disabled in production
environments. <a href=''>Re-enable it here</a>.
2026-06-11 11:34:37 +01:00

25 lines
688 B
Ruby
Vendored

# frozen_string_literal: true
RSpec.describe ProblemCheck::ContentSecurityPolicyDisabled do
subject(:check) { described_class.new }
describe ".call" do
before { SiteSetting.stubs(content_security_policy: configured) }
context "when the content security policy is enabled" do
let(:configured) { true }
it { expect(check).to be_chill_about_it }
end
context "when the content security policy is disabled" do
let(:configured) { false }
it do
expect(check).to have_a_problem.with_priority("low").with_message(
I18n.t("dashboard.problem.content_security_policy_disabled", base_path: ""),
)
end
end
end
end