aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/csp_helper_test.rb
blob: 8bad25ba7dbeef8a4174d5f74f817c40a6c18696 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

require "abstract_unit"

class CspHelperWithCspEnabledTest < ActionView::TestCase
  tests ActionView::Helpers::CspHelper

  def content_security_policy_nonce
    "iyhD0Yc0W+c="
  end

  def content_security_policy?
    true
  end

  def test_csp_meta_tag
    assert_equal "<meta name=\"csp-nonce\" content=\"iyhD0Yc0W+c=\" />", csp_meta_tag
  end
end

class CspHelperWithCspDisabledTest < ActionView::TestCase
  tests ActionView::Helpers::CspHelper

  def content_security_policy?
    false
  end

  def test_csp_meta_tag
    assert_nil csp_meta_tag
  end
end