Sha256: f3ab902131a032f0b6fc5530dd9343002e17d5f97f986e97e86e3a345fb66e0a
Contents?: true
Size: 1.93 KB
Versions: 30
Compression:
Stored size: 1.93 KB
Contents
# frozen_string_literal: true require "spec_helper" module SecureHeaders describe ExpectCertificateTransparency do specify { expect(ExpectCertificateTransparency.new(max_age: 1234, enforce: true).value).to eq("enforce, max-age=1234") } specify { expect(ExpectCertificateTransparency.new(max_age: 1234, enforce: false).value).to eq("max-age=1234") } specify { expect(ExpectCertificateTransparency.new(max_age: 1234, enforce: "yolocopter").value).to eq("max-age=1234") } specify { expect(ExpectCertificateTransparency.new(max_age: 1234, report_uri: "https://report-uri.io/expect-ct").value).to eq("max-age=1234, report-uri=\"https://report-uri.io/expect-ct\"") } specify do config = { enforce: true, max_age: 1234, report_uri: "https://report-uri.io/expect-ct" } header_value = "enforce, max-age=1234, report-uri=\"https://report-uri.io/expect-ct\"" expect(ExpectCertificateTransparency.new(config).value).to eq(header_value) end context "with an invalid configuration" do it "raises an exception when configuration isn't a hash" do expect do ExpectCertificateTransparency.validate_config!(%w(a)) end.to raise_error(ExpectCertificateTransparencyConfigError) end it "raises an exception when max-age is not provided" do expect do ExpectCertificateTransparency.validate_config!(foo: "bar") end.to raise_error(ExpectCertificateTransparencyConfigError) end it "raises an exception with an invalid max-age" do expect do ExpectCertificateTransparency.validate_config!(max_age: "abc123") end.to raise_error(ExpectCertificateTransparencyConfigError) end it "raises an exception with an invalid enforce value" do expect do ExpectCertificateTransparency.validate_config!(enforce: "brokenstring") end.to raise_error(ExpectCertificateTransparencyConfigError) end end end end
Version data entries
30 entries across 30 versions & 1 rubygems