Sha256: 8fa14e624c9a27c6e635e1353877be29ff4ee57348fada26c3ce396176a18fb2
Contents?: true
Size: 1.44 KB
Versions: 36
Compression:
Stored size: 1.44 KB
Contents
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
36 entries across 36 versions & 1 rubygems