content_security_policy_spec.rb 1.1 KB

123456789101112131415161718192021222324252627
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe 'Content-Security-Policy' do
  4. it 'sets the expected CSP headers' do
  5. allow(SecureRandom).to receive(:base64).with(16).and_return('ZbA+JmE7+bK8F5qvADZHuQ==')
  6. get '/'
  7. expect(response.headers['Content-Security-Policy'].split(';').map(&:strip)).to contain_exactly(
  8. "base-uri 'none'",
  9. "default-src 'none'",
  10. "frame-ancestors 'none'",
  11. "font-src 'self' https://cb6e6126.ngrok.io",
  12. "img-src 'self' https: data: blob: https://cb6e6126.ngrok.io",
  13. "style-src 'self' https://cb6e6126.ngrok.io 'nonce-ZbA+JmE7+bK8F5qvADZHuQ=='",
  14. "media-src 'self' https: data: https://cb6e6126.ngrok.io",
  15. "frame-src 'self' https:",
  16. "manifest-src 'self' https://cb6e6126.ngrok.io",
  17. "form-action 'self'",
  18. "child-src 'self' blob: https://cb6e6126.ngrok.io",
  19. "worker-src 'self' blob: https://cb6e6126.ngrok.io",
  20. "connect-src 'self' data: blob: https://cb6e6126.ngrok.io https://cb6e6126.ngrok.io ws://localhost:4000",
  21. "script-src 'self' https://cb6e6126.ngrok.io 'wasm-unsafe-eval'"
  22. )
  23. end
  24. end