Sha256: 8da25e14cfa765608a2b831603edf5c4552c793e613a0f46351d423b7ebc64fc

Contents?: true

Size: 1.1 KB

Versions: 20

Compression:

Stored size: 1.1 KB

Contents

# encoding: UTF-8

require "spec_helper"

describe Timber::Events::HTTPRequest, :rails_23 => true do
  describe ".initialize" do
    context "with a header filters" do
      around(:each) do |example|
        old_http_header_filters = Timber::Config.instance.http_header_filters
        Timber::Config.instance.http_header_filters += ['api-key']
        example.run
        Timber::Config.instance.http_header_filters = old_http_header_filters
      end

      it "should sanitize headers when a config option is set" do
        event = described_class.new(:headers => {'Api-Key' => 'abcde'}, :host => 'my.host.com', :method => 'GET', :path => '/path', :scheme => 'https')
        expect(event.headers).to eq({'api-key' => '[sanitized]'})
      end
    end

    it "should handle header encoding" do
      referer = 'http://www.metrojobb.se/jobb/1013893-skadeadministratör'.force_encoding('ASCII-8BIT')
      event = described_class.new(:headers => {'Referer' => referer}, :host => 'my.host.com', :method => 'GET', :path => '/path', :scheme => 'https')
      expect(event.headers.key?("referer")).to eq(false)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
timber-2.5.0 spec/timber/events/http_request_spec.rb
timber-2.4.0 spec/timber/events/http_request_spec.rb
timber-2.3.4 spec/timber/events/http_request_spec.rb
timber-2.3.3 spec/timber/events/http_request_spec.rb
timber-2.3.2 spec/timber/events/http_request_spec.rb
timber-2.3.1 spec/timber/events/http_request_spec.rb
timber-2.3.0 spec/timber/events/http_request_spec.rb
timber-2.2.3 spec/timber/events/http_request_spec.rb
timber-2.2.2 spec/timber/events/http_request_spec.rb
timber-2.2.1 spec/timber/events/http_request_spec.rb
timber-2.2.0 spec/timber/events/http_request_spec.rb
timber-2.1.10 spec/timber/events/http_request_spec.rb
timber-2.1.9 spec/timber/events/http_request_spec.rb
timber-2.1.8 spec/timber/events/http_request_spec.rb
timber-2.1.7 spec/timber/events/http_request_spec.rb
timber-2.1.6 spec/timber/events/http_request_spec.rb
timber-2.1.5 spec/timber/events/http_request_spec.rb
timber-2.1.4 spec/timber/events/http_request_spec.rb
timber-2.1.3 spec/timber/events/http_request_spec.rb
timber-2.1.2 spec/timber/events/http_request_spec.rb