diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-18 16:30:31 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-18 16:30:31 +0200 |
| commit | 0c6783816e0a7a8acad922296d3eb8cc454fb981 (patch) | |
| tree | 54c59e86afa188de6429ff0e1f07d1b6e4f36350 /test | |
| parent | 6b6e50909cc77de1797e88be5445c5b643b008a9 (diff) | |
Emit a report-only Content-Security-Policy with nonced inline scripts
- dark-mode restore now travels nonced, the admin constants likewise
- AUTH_TOKEN deleted in favour of the csrf meta tag
- new report collector at /csp_reports
Diffstat (limited to 'test')
| -rw-r--r-- | test/controllers/csp_reports_controller_test.rb | 8 | ||||
| -rw-r--r-- | test/integration/csp_header_test.rb | 12 |
2 files changed, 20 insertions, 0 deletions
diff --git a/test/controllers/csp_reports_controller_test.rb b/test/controllers/csp_reports_controller_test.rb new file mode 100644 index 0000000..7dd8c9e --- /dev/null +++ b/test/controllers/csp_reports_controller_test.rb | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | require 'test_helper' | ||
| 2 | |||
| 3 | class CspReportsControllerTest < ActionController::TestCase | ||
| 4 | test "accepts anonymous reports without CSRF" do | ||
| 5 | post :create, body: '{"csp-report":{"violated-directive":"script-src"}}' | ||
| 6 | assert_response :no_content | ||
| 7 | end | ||
| 8 | end | ||
diff --git a/test/integration/csp_header_test.rb b/test/integration/csp_header_test.rb new file mode 100644 index 0000000..73707ed --- /dev/null +++ b/test/integration/csp_header_test.rb | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | require 'test_helper' | ||
| 2 | |||
| 3 | class CspHeaderTest < ActionDispatch::IntegrationTest | ||
| 4 | test "public responses carry the report-only CSP header with a nonce" do | ||
| 5 | get "/" | ||
| 6 | |||
| 7 | header = response.headers["Content-Security-Policy-Report-Only"] | ||
| 8 | assert header.present? | ||
| 9 | assert_includes header, "script-src" | ||
| 10 | assert_includes header, "nonce-" | ||
| 11 | end | ||
| 12 | end | ||
