2023-07-21 20:34:15 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe 'Content-Security-Policy' do
|
|
|
|
it 'sets the expected CSP headers' do
|
|
|
|
allow(SecureRandom).to receive(:base64).with(16).and_return('ZbA+JmE7+bK8F5qvADZHuQ==')
|
|
|
|
|
|
|
|
get '/'
|
|
|
|
expect(response.headers['Content-Security-Policy'].split(';').map(&:strip)).to contain_exactly(
|
|
|
|
"base-uri 'none'",
|
|
|
|
"default-src 'none'",
|
|
|
|
"frame-ancestors 'none'",
|
|
|
|
"font-src 'self' https://cb6e6126.ngrok.io",
|
2023-12-20 06:17:31 +09:00
|
|
|
"img-src 'self' data: blob: https://cb6e6126.ngrok.io https://media.tenor.com",
|
2023-07-21 20:34:15 +09:00
|
|
|
"style-src 'self' https://cb6e6126.ngrok.io 'nonce-ZbA+JmE7+bK8F5qvADZHuQ=='",
|
2023-12-20 06:17:31 +09:00
|
|
|
"media-src 'self' data: https://cb6e6126.ngrok.io https://media.tenor.com",
|
2023-07-21 20:34:15 +09:00
|
|
|
"frame-src 'self' https:",
|
|
|
|
"manifest-src 'self' https://cb6e6126.ngrok.io",
|
|
|
|
"form-action 'self'",
|
|
|
|
"child-src 'self' blob: https://cb6e6126.ngrok.io",
|
|
|
|
"worker-src 'self' blob: https://cb6e6126.ngrok.io",
|
2024-01-04 08:21:22 +09:00
|
|
|
"connect-src 'self' data: blob: https://cb6e6126.ngrok.io ws://cb6e6126.ngrok.io:4000 https://media.tenor.com https://api.tenor.com",
|
2023-07-21 20:34:15 +09:00
|
|
|
"script-src 'self' https://cb6e6126.ngrok.io 'wasm-unsafe-eval'"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|