Skip to content

Commit f2cc4c9

Browse files
authored
move trusted types validate config to appropriate test file
1 parent 79a2b5d commit f2cc4c9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

spec/lib/secure_headers/headers/content_security_policy_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ module SecureHeaders
151151
expect(csp.value).to eq("default-src 'self'; require-trusted-types-for script")
152152
end
153153

154-
it "does not support style for require-trusted-types-for directive" do
155-
expect { ContentSecurityPolicy.new({require_trusted_types_for: %(script style)}) }.to raise_error(ContentSecurityPolicyConfigError)
156-
end
157-
158154
it "includes prefetch-src" do
159155
csp = ContentSecurityPolicy.new(default_src: %w('self'), prefetch_src: %w(foo.com))
160156
expect(csp.value).to eq("default-src 'self'; prefetch-src foo.com")

spec/lib/secure_headers/headers/policy_management_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ module SecureHeaders
122122
end.to raise_error(ContentSecurityPolicyConfigError)
123123
end
124124

125+
it "rejects style for trusted types" do
126+
expect do
127+
ContentSecurityPolicy.validate_config!(ContentSecurityPolicyConfig.new(default_opts.merge(style_src: %w('self'), require_trusted_types_for: %w(script style), trusted_types: %w(abcpolicy))))
128+
end
129+
end
130+
125131
# this is mostly to ensure people don't use the antiquated shorthands common in other configs
126132
it "performs light validation on source lists" do
127133
expect do

0 commit comments

Comments
 (0)