|
181 | 181 | is_expected.to be true
|
182 | 182 | end
|
183 | 183 | end
|
| 184 | + |
| 185 | + describe "#integrity" do |
| 186 | + it "contains the key :enabled" do |
| 187 | + expect(config.integrity).to have_key(:enabled) |
| 188 | + end |
| 189 | + |
| 190 | + it "contains the key :hash_functions" do |
| 191 | + expect(config.integrity).to have_key(:hash_functions) |
| 192 | + end |
| 193 | + |
| 194 | + it "contains the key :cross_origin" do |
| 195 | + expect(config.integrity).to have_key(:cross_origin) |
| 196 | + end |
| 197 | + |
| 198 | + it "is by default disabled" do |
| 199 | + expect(config.integrity[:enabled]).to be false |
| 200 | + end |
| 201 | + |
| 202 | + it "returns default cross_origin configuration" do |
| 203 | + expect(config.integrity[:cross_origin]).to eq "anonymous" |
| 204 | + end |
| 205 | + |
| 206 | + it "returns default hash_functions" do |
| 207 | + expect(config.integrity[:hash_functions]).to eq ["sha384"] |
| 208 | + end |
| 209 | + end |
| 210 | + end |
| 211 | + |
| 212 | + context "with shakapacker config file containing integrity" do |
| 213 | + let(:config) do |
| 214 | + Shakapacker::Configuration.new( |
| 215 | + root_path: ROOT_PATH, |
| 216 | + config_path: Pathname.new(File.expand_path("./test_app/config/shakapacker_integrity.yml", __dir__)), |
| 217 | + env: "production" |
| 218 | + ) |
| 219 | + end |
| 220 | + |
| 221 | + it "has integrity enabled" do |
| 222 | + expect(config.integrity[:enabled]).to be true |
| 223 | + end |
| 224 | + |
| 225 | + it "has all hash functions set" do |
| 226 | + expect(config.integrity[:hash_functions]).to eq ["sha256", "sha384", "sha512"] |
| 227 | + end |
| 228 | + |
| 229 | + it "has cross_origin set to use-credentials" do |
| 230 | + expect(config.integrity[:cross_origin]).to eq "use-credentials" |
| 231 | + end |
184 | 232 | end
|
185 | 233 |
|
186 | 234 | context "with shakapacker config file containing public_output_path entry" do
|
|
373 | 421 | end
|
374 | 422 | end
|
375 | 423 | end
|
376 |
| - |
377 | 424 | end
|
0 commit comments