Skip to content

Commit 3558578

Browse files
committed
Add test for boolean values.
1 parent caa7d92 commit 3558578

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

spec/lib/secure_headers/headers/content_security_policy_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ module SecureHeaders
7171
expect(csp.value).to eq("default-src example.org")
7272
end
7373

74+
it "does add a boolean directive if the value is true" do
75+
csp = ContentSecurityPolicy.new(default_src: ["https://example.org"], block_all_mixed_content: true, upgrade_insecure_requests: true)
76+
expect(csp.value).to eq("default-src example.org; block-all-mixed-content; upgrade-insecure-requests")
77+
end
78+
79+
it "does not add a boolean directive if the value is false" do
80+
csp = ContentSecurityPolicy.new(default_src: ["https://example.org"], block_all_mixed_content: true, upgrade_insecure_requests: false)
81+
expect(csp.value).to eq("default-src example.org; block-all-mixed-content")
82+
end
83+
7484
it "deduplicates any source expressions" do
7585
csp = ContentSecurityPolicy.new(default_src: %w(example.org example.org example.org))
7686
expect(csp.value).to eq("default-src example.org")

0 commit comments

Comments
 (0)