File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
rails_4_1_8/app/controllers Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -3,4 +3,18 @@ class OtherThingsController < ApplicationController
33 def index
44
55 end
6+
7+ def other_action
8+ render :text => 'yooooo'
9+ end
10+
11+ def secure_header_options_for ( header , options )
12+ if params [ :action ] == "other_action"
13+ if header == :csp
14+ options . merge ( :style_src => 'self' )
15+ end
16+ else
17+ options
18+ end
19+ end
620end
Original file line number Diff line number Diff line change 1212 expect ( response . headers [ 'X-Frame-Options' ] ) . to eq ( SecureHeaders ::XFrameOptions ::Constants ::DEFAULT_VALUE )
1313 end
1414
15- it "sets the X-WebKit- CSP header" do
15+ it "sets the CSP header" do
1616 get :index
1717 expect ( response . headers [ 'Content-Security-Policy-Report-Only' ] ) . to eq ( "default-src 'self'; img-src 'self' data:;" )
1818 end
1919
20+ it "sets per-action values based on secure_header_options_for" do
21+ # munges :style_src => self into policy
22+ get :other_action
23+ expect ( response . headers [ 'Content-Security-Policy-Report-Only' ] ) . to eq ( "default-src 'self'; img-src 'self' data:; style-src 'self';" )
24+ end
25+
2026 #mock ssl
2127 it "sets the Strict-Transport-Security header" do
2228 request . env [ 'HTTPS' ] = 'on'
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ class OtherThingsController < ApplicationController
22 def index
33
44 end
5- end
5+ end
You can’t perform that action at this time.
0 commit comments