Sha256: e0cfce2bb1e6aa2cde862b68d77e9dc530974b2662fca12931ac37d20a7665ab

Contents?: true

Size: 1.09 KB

Versions: 15

Compression:

Stored size: 1.09 KB

Contents

# encoding: UTF-8

require "spec_helper"

describe Timber::Events::HTTPServerRequest, :rails_23 => true do
  describe ".initialize" do
    context "with a header filters" do
      around(:each) do |example|
        old_header_filters = Timber::Config.instance.header_filters
        Timber::Config.instance.header_filters += ['api-key']
        example.run
        Timber::Config.instance.header_filters = old_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["referer"].encoding.to_s).to eq("UTF-8")
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
timber-2.0.24 spec/timber/events/http_server_request_spec.rb
timber-2.0.23 spec/timber/events/http_server_request_spec.rb
timber-2.0.22 spec/timber/events/http_server_request_spec.rb
timber-2.0.21 spec/timber/events/http_server_request_spec.rb
timber-2.0.20 spec/timber/events/http_server_request_spec.rb
timber-2.0.19 spec/timber/events/http_server_request_spec.rb
timber-2.0.17 spec/timber/events/http_server_request_spec.rb
timber-2.0.16 spec/timber/events/http_server_request_spec.rb
timber-2.0.15 spec/timber/events/http_server_request_spec.rb
timber-2.0.14 spec/timber/events/http_server_request_spec.rb
timber-2.0.12 spec/timber/events/http_server_request_spec.rb
timber-2.0.11 spec/timber/events/http_server_request_spec.rb
timber-2.0.10 spec/timber/events/http_server_request_spec.rb
timber-2.0.9 spec/timber/events/http_server_request_spec.rb
timber-2.0.8 spec/timber/events/http_server_request_spec.rb