@@ -54,7 +54,7 @@ module SecureHeaders
5454 describe "#header_hash_for" do
5555 it "allows you to opt out of individual headers via API" do
5656 Configuration . default do |config |
57- config . csp = { default_src : %w( 'self' ) , script_src : %w( 'self' ) }
57+ config . csp = { default_src : %w( 'self' ) , script_src : %w( 'self' ) }
5858 config . csp_report_only = config . csp
5959 end
6060 SecureHeaders . opt_out_of_header ( request , :csp )
@@ -174,11 +174,11 @@ module SecureHeaders
174174 end
175175
176176 Configuration . named_append ( :moar_default_sources ) do |request |
177- { default_src : %w( https: ) , style_src : %w( 'self' ) }
177+ { default_src : %w( https: ) , style_src : %w( 'self' ) }
178178 end
179179
180180 Configuration . named_append ( :how_about_a_script_src_too ) do |request |
181- { script_src : %w( 'unsafe-inline' ) }
181+ { script_src : %w( 'unsafe-inline' ) }
182182 end
183183
184184 SecureHeaders . use_content_security_policy_named_append ( request , :moar_default_sources )
@@ -318,7 +318,7 @@ module SecureHeaders
318318 default_src : %w( 'self' ) ,
319319 script_src : %w( 'self' )
320320 }
321- config . csp_report_only = config . csp . merge ( { script_src : %w( foo.com ) } )
321+ config . csp_report_only = config . csp . merge ( { script_src : %w( foo.com ) } )
322322 end
323323
324324 hash = SecureHeaders . header_hash_for ( request )
@@ -342,42 +342,42 @@ module SecureHeaders
342342 end
343343
344344 it "allows appending to the enforced policy" do
345- SecureHeaders . append_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } , :enforced )
345+ SecureHeaders . append_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } , :enforced )
346346 hash = SecureHeaders . header_hash_for ( request )
347347 expect ( hash [ "content-security-policy" ] ) . to eq ( "default-src 'self'; script-src 'self' anothercdn.com" )
348348 expect ( hash [ "content-security-policy-report-only" ] ) . to eq ( "default-src 'self'; script-src 'self'" )
349349 end
350350
351351 it "allows appending to the report only policy" do
352- SecureHeaders . append_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } , :report_only )
352+ SecureHeaders . append_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } , :report_only )
353353 hash = SecureHeaders . header_hash_for ( request )
354354 expect ( hash [ "content-security-policy" ] ) . to eq ( "default-src 'self'; script-src 'self'" )
355355 expect ( hash [ "content-security-policy-report-only" ] ) . to eq ( "default-src 'self'; script-src 'self' anothercdn.com" )
356356 end
357357
358358 it "allows appending to both policies" do
359- SecureHeaders . append_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } , :both )
359+ SecureHeaders . append_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } , :both )
360360 hash = SecureHeaders . header_hash_for ( request )
361361 expect ( hash [ "content-security-policy" ] ) . to eq ( "default-src 'self'; script-src 'self' anothercdn.com" )
362362 expect ( hash [ "content-security-policy-report-only" ] ) . to eq ( "default-src 'self'; script-src 'self' anothercdn.com" )
363363 end
364364
365365 it "allows overriding the enforced policy" do
366- SecureHeaders . override_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } , :enforced )
366+ SecureHeaders . override_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } , :enforced )
367367 hash = SecureHeaders . header_hash_for ( request )
368368 expect ( hash [ "content-security-policy" ] ) . to eq ( "default-src 'self'; script-src anothercdn.com" )
369369 expect ( hash [ "content-security-policy-report-only" ] ) . to eq ( "default-src 'self'; script-src 'self'" )
370370 end
371371
372372 it "allows overriding the report only policy" do
373- SecureHeaders . override_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } , :report_only )
373+ SecureHeaders . override_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } , :report_only )
374374 hash = SecureHeaders . header_hash_for ( request )
375375 expect ( hash [ "content-security-policy" ] ) . to eq ( "default-src 'self'; script-src 'self'" )
376376 expect ( hash [ "content-security-policy-report-only" ] ) . to eq ( "default-src 'self'; script-src anothercdn.com" )
377377 end
378378
379379 it "allows overriding both policies" do
380- SecureHeaders . override_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } , :both )
380+ SecureHeaders . override_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } , :both )
381381 hash = SecureHeaders . header_hash_for ( request )
382382 expect ( hash [ "content-security-policy" ] ) . to eq ( "default-src 'self'; script-src anothercdn.com" )
383383 expect ( hash [ "content-security-policy-report-only" ] ) . to eq ( "default-src 'self'; script-src anothercdn.com" )
@@ -392,7 +392,7 @@ module SecureHeaders
392392 script_src : %w( 'self' )
393393 }
394394 end
395- SecureHeaders . append_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } )
395+ SecureHeaders . append_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } )
396396
397397 hash = SecureHeaders . header_hash_for ( request )
398398 expect ( hash [ "content-security-policy" ] ) . to eq ( "default-src 'self'; script-src 'self' anothercdn.com" )
@@ -408,7 +408,7 @@ module SecureHeaders
408408 script_src : %w( 'self' )
409409 }
410410 end
411- SecureHeaders . append_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } )
411+ SecureHeaders . append_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } )
412412
413413 hash = SecureHeaders . header_hash_for ( request )
414414 expect ( hash [ "content-security-policy-report-only" ] ) . to eq ( "default-src 'self'; script-src 'self' anothercdn.com" )
@@ -427,7 +427,7 @@ module SecureHeaders
427427 script_src : %w( 'self' )
428428 }
429429 end
430- SecureHeaders . append_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } )
430+ SecureHeaders . append_content_security_policy_directives ( request , { script_src : %w( anothercdn.com ) } )
431431
432432 hash = SecureHeaders . header_hash_for ( request )
433433 expect ( hash [ "content-security-policy" ] ) . to eq ( "default-src enforced.com; script-src 'self' anothercdn.com" )
@@ -670,4 +670,3 @@ module SecureHeaders
670670 end
671671 end
672672end
673-
0 commit comments