Sha256: c583eadd805ba61c288dea7ce1819ac2114e59fc5f5770df9ad78ff24c7c5fa7

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 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_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["referer"].encoding.to_s).to eq("UTF-8")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
timber-2.1.0.rc3 spec/timber/events/http_server_request_spec.rb
timber-2.1.0.rc2 spec/timber/events/http_server_request_spec.rb
timber-2.1.0.rc1 spec/timber/events/http_server_request_spec.rb