2020-03-19 19:54:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-28 05:27:38 +03:00
|
|
|
RSpec.describe "content security policy integration" do
|
2020-03-19 19:54:42 +00:00
|
|
|
it "adds the csp headers correctly" do
|
2024-03-07 15:20:31 +00:00
|
|
|
Fabricate(:admin) # to avoid 'new installation' screen
|
|
|
|
|
2020-03-19 19:54:42 +00:00
|
|
|
SiteSetting.content_security_policy = false
|
|
|
|
get "/"
|
|
|
|
expect(response.headers["Content-Security-Policy"]).to eq(nil)
|
|
|
|
|
|
|
|
SiteSetting.content_security_policy = true
|
|
|
|
get "/"
|
|
|
|
expect(response.headers["Content-Security-Policy"]).to be_present
|
2024-03-07 15:20:31 +00:00
|
|
|
|
|
|
|
expect(response.headers["Content-Security-Policy"]).to match(
|
|
|
|
/script-src 'nonce-[^']+' 'strict-dynamic';/,
|
|
|
|
)
|
2020-03-19 19:54:42 +00:00
|
|
|
end
|
|
|
|
end
|