Sha256: 43bfd88550f5f7e98252a2b8cb01c94f88034c7a9667c87374d5794d4b4ff491
Contents?: true
Size: 1.47 KB
Versions: 19
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true require "spec_helper" module SecureHeaders describe PublicKeyPins do specify { expect(PublicKeyPins.new(max_age: 1234, report_only: true).name).to eq("Public-Key-Pins-Report-Only") } specify { expect(PublicKeyPins.new(max_age: 1234).name).to eq("Public-Key-Pins") } specify { expect(PublicKeyPins.new(max_age: 1234).value).to eq("max-age=1234") } specify { expect(PublicKeyPins.new(max_age: 1234).value).to eq("max-age=1234") } specify do config = { max_age: 1234, pins: [{ sha256: "base64encodedpin1" }, { sha256: "base64encodedpin2" }] } header_value = "max-age=1234; pin-sha256=\"base64encodedpin1\"; pin-sha256=\"base64encodedpin2\"" expect(PublicKeyPins.new(config).value).to eq(header_value) end context "with an invalid configuration" do it "raises an exception when max-age is not provided" do expect do PublicKeyPins.validate_config!(foo: "bar") end.to raise_error(PublicKeyPinsConfigError) end it "raises an exception with an invalid max-age" do expect do PublicKeyPins.validate_config!(max_age: "abc123") end.to raise_error(PublicKeyPinsConfigError) end it "raises an exception with less than 2 pins" do expect do config = { max_age: 1234, pins: [{ sha256: "base64encodedpin" }] } PublicKeyPins.validate_config!(config) end.to raise_error(PublicKeyPinsConfigError) end end end end
Version data entries
19 entries across 19 versions & 1 rubygems