File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,22 @@ module SecureHeaders
109109 expect ( hash [ CSP ::HEADER_NAME ] ) . to eq ( "default-src 'self'; script-src mycdn.com 'unsafe-inline' anothercdn.com" )
110110 end
111111
112+ it "dups global configuration just once when overriding n times" do
113+ Configuration . default do |config |
114+ config . csp = {
115+ default_src : %w( 'self' )
116+ }
117+ end
118+
119+ SecureHeaders . append_content_security_policy_directives ( @request , script_src : %w( anothercdn.com ) )
120+ new_config = SecureHeaders . config_for ( @request )
121+ expect ( new_config ) . to_not be ( SecureHeaders ::Configuration . get )
122+
123+ SecureHeaders . override_content_security_policy_directives ( @request , script_src : %w( yet.anothercdn.com ) )
124+ current_config = SecureHeaders . config_for ( @request )
125+ expect ( current_config ) . to be ( new_config )
126+ end
127+
112128 it "overrides individual directives" do
113129 Configuration . default do |config |
114130 config . csp = {
You can’t perform that action at this time.
0 commit comments