Skip to content

Commit a678cff

Browse files
authored
Add test for checking capitalization of header keys
1 parent 8c51196 commit a678cff

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

spec/lib/secure_headers_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ module SecureHeaders
99

1010
let(:request) { Rack::Request.new("HTTP_X_FORWARDED_SSL" => "on") }
1111

12+
it "has a HEADER_NAME with no capital letters" do
13+
# Iterate through all headerable attributes
14+
Configuration::HEADERABLE_ATTRIBUTES.each do |attr|
15+
klass = Configuration::CONFIG_ATTRIBUTES_TO_HEADER_CLASSES[attr]
16+
next if [SecureHeaders::ContentSecurityPolicy].include? klass
17+
expect(klass::HEADER_NAME).to eq(klass::HEADER_NAME.downcase)
18+
end
19+
20+
# Now to iterate through the CSP and CSP-Report-Only classes, since they're registered differently
21+
klass = SecureHeaders::ContentSecurityPolicyConfig
22+
expect(klass::HEADER_NAME).to eq(klass::HEADER_NAME.downcase)
23+
24+
klass = SecureHeaders::ContentSecurityPolicyReportOnlyConfig
25+
expect(klass::HEADER_NAME).to eq(klass::HEADER_NAME.downcase)
26+
end
27+
1228
it "raises a NotYetConfiguredError if default has not been set" do
1329
expect do
1430
SecureHeaders.header_hash_for(request)

0 commit comments

Comments
 (0)