@@ -23,6 +23,35 @@ module SecureHeaders
2323 end
2424
2525 describe "#validate_config!" do
26+ it "accepts all keys" do
27+ # (pulled from README)
28+ config = {
29+ # "meta" values. these will shaped the header, but the values are not included in the header.
30+ report_only : true , # default: false
31+ preserve_schemes : true , # default: false. Schemes are removed from host sources to save bytes and discourage mixed content.
32+
33+ # directive values: these values will directly translate into source directives
34+ default_src : %w( https: 'self' ) ,
35+ frame_src : %w( 'self' *.twimg.com itunes.apple.com ) ,
36+ connect_src : %w( wws: ) ,
37+ font_src : %w( 'self' data: ) ,
38+ img_src : %w( mycdn.com data: ) ,
39+ media_src : %w( utoob.com ) ,
40+ object_src : %w( 'self' ) ,
41+ script_src : %w( 'self' ) ,
42+ style_src : %w( 'unsafe-inline' ) ,
43+ base_uri : %w( 'self' ) ,
44+ child_src : %w( 'self' ) ,
45+ form_action : %w( 'self' github.com ) ,
46+ frame_ancestors : %w( 'none' ) ,
47+ plugin_types : %w( application/x-shockwave-flash ) ,
48+ block_all_mixed_content : true , # see [http://www.w3.org/TR/mixed-content/](http://www.w3.org/TR/mixed-content/)
49+ report_uri : %w( https://example.com/uri-directive )
50+ }
51+
52+ CSP . validate_config! ( config )
53+ end
54+
2655 it "requires a :default_src value" do
2756 expect do
2857 CSP . validate_config! ( script_src : %('self') )
@@ -35,6 +64,12 @@ module SecureHeaders
3564 end . to raise_error ( ContentSecurityPolicyConfigError )
3665 end
3766
67+ it "requires :preserve_schemes to be a truthy value" do
68+ expect do
69+ CSP . validate_config! ( default_opts . merge ( preserve_schemes : "steve" ) )
70+ end . to raise_error ( ContentSecurityPolicyConfigError )
71+ end
72+
3873 it "requires :block_all_mixed_content to be a boolean value" do
3974 expect do
4075 CSP . validate_config! ( default_opts . merge ( block_all_mixed_content : "steve" ) )
0 commit comments