Sha256: 270ed96aebba79dfb46f13bf8ee166e4ebeca711492503b3e2e2f636c83fcd0c

Contents?: true

Size: 1.26 KB

Versions: 33

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true
require "spec_helper"

module SecureHeaders
  describe StrictTransportSecurity do
    describe "#value" do
      specify { expect(StrictTransportSecurity.make_header).to eq([StrictTransportSecurity::HEADER_NAME, StrictTransportSecurity::DEFAULT_VALUE]) }
      specify { expect(StrictTransportSecurity.make_header("max-age=1234; includeSubdomains; preload")).to eq([StrictTransportSecurity::HEADER_NAME, "max-age=1234; includeSubdomains; preload"]) }

      context "with an invalid configuration" do
        context "with a string argument" do
          it "raises an exception with an invalid max-age" do
            expect do
              StrictTransportSecurity.validate_config!("max-age=abc123")
            end.to raise_error(STSConfigError)
          end

          it "raises an exception if max-age is not supplied" do
            expect do
              StrictTransportSecurity.validate_config!("includeSubdomains")
            end.to raise_error(STSConfigError)
          end

          it "raises an exception with an invalid format" do
            expect do
              StrictTransportSecurity.validate_config!("max-age=123includeSubdomains")
            end.to raise_error(STSConfigError)
          end
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
secure_headers-7.0.0 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.7.0 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.6.0 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.5.0 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.4.0 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.3.4 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.3.3 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.3.2 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.3.1 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-5.2.0 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.3.0 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-5.1.0 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.2.0 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.1.2 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.1.1 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.1.0 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.0.0 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.0.0.alpha03 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.0.0.alpha02 spec/lib/secure_headers/headers/strict_transport_security_spec.rb
secure_headers-6.0.0.alpha01 spec/lib/secure_headers/headers/strict_transport_security_spec.rb