Sha256: 097edc165132163779a0b56ef9a0e7cd0390d151e494a893034ab614a796100c

Contents?: true

Size: 1.86 KB

Versions: 9

Compression:

Stored size: 1.86 KB

Contents

# frozen_string_literal: true
require "spec_helper"

module SecureHeaders
  describe Configuration do
    before(:each) do
      reset_config
    end

    it "has a default config" do
      expect(Configuration.default).to_not be_nil
    end

    it "has an 'noop' override" do
      Configuration.default
      expect(Configuration.overrides(Configuration::NOOP_OVERRIDE)).to_not be_nil
    end

    it "dup results in a copy of the default config" do
      Configuration.default
      original_configuration = Configuration.send(:default_config)
      configuration = Configuration.dup
      expect(original_configuration).not_to be(configuration)
      Configuration::CONFIG_ATTRIBUTES.each do |attr|
        expect(original_configuration.send(attr)).to eq(configuration.send(attr))
      end
    end

    it "stores an override" do
      Configuration.override(:test_override) do |config|
        config.x_frame_options = "DENY"
      end

      expect(Configuration.overrides(:test_override)).to_not be_nil
    end

    it "deprecates the secure_cookies configuration" do
      expect {
        Configuration.default do |config|
          config.secure_cookies = true
        end
      }.to raise_error(ArgumentError)
    end

    it "gives cookies a default config" do
      expect(Configuration.default.cookies).to eq({httponly: true, secure: true, samesite: {lax: true}})
    end

    it "allows OPT_OUT" do
      Configuration.default do |config|
        config.cookies = OPT_OUT
      end

      config = Configuration.dup
      expect(config.cookies).to eq(OPT_OUT)
    end

    it "allows me to be explicit too" do
      Configuration.default do |config|
        config.cookies = {httponly: true, secure: true, samesite: {lax: false}}
      end

      config = Configuration.dup
      expect(config.cookies).to eq({httponly: true, secure: true, samesite: {lax: false}})
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
secure_headers-6.3.0 spec/lib/secure_headers/configuration_spec.rb
secure_headers-6.2.0 spec/lib/secure_headers/configuration_spec.rb
secure_headers-6.1.2 spec/lib/secure_headers/configuration_spec.rb
secure_headers-6.1.1 spec/lib/secure_headers/configuration_spec.rb
secure_headers-6.1.0 spec/lib/secure_headers/configuration_spec.rb
secure_headers-6.0.0 spec/lib/secure_headers/configuration_spec.rb
secure_headers-6.0.0.alpha03 spec/lib/secure_headers/configuration_spec.rb
secure_headers-6.0.0.alpha02 spec/lib/secure_headers/configuration_spec.rb
secure_headers-6.0.0.alpha01 spec/lib/secure_headers/configuration_spec.rb