mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add test for csp_meta_tag
This commit is contained in:
parent
ac68550ae6
commit
3f186e3045
1 changed files with 31 additions and 0 deletions
31
actionview/test/template/csp_helper_test.rb
Normal file
31
actionview/test/template/csp_helper_test.rb
Normal file
|
@ -0,0 +1,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
|
Loading…
Reference in a new issue