Sha256: 4a2b5e021ad708d325538e86c864d95b392e33c19ae3082cc1783d6f7c235469

Contents?: true

Size: 1012 Bytes

Versions: 2

Compression:

Stored size: 1012 Bytes

Contents

require 'spec_helper'
require 'rack/test'

require 'rack_strip_client_ip'

describe RackStripClientIp::Middleware do
  include Rack::Test::Methods

  def app
    RackStripClientIp::Middleware.new( proc {|env| @inner_app_env = env.dup; [200, {}, "Inner app response"] } )
  end

  it "should pass the request to the inner app" do
    get "/"
    expect(last_response.status).to eq(200)
    expect(last_response.body).to match(/Inner app response/)
    expect(@inner_app_env).not_to be_nil
  end

  it "should remove the Client-Ip header" do
    get "/", {}, {"HTTP_CLIENT_IP" => "1.2.3.4"}
    expect(@inner_app_env["HTTP_CLIENT_IP"]).to be_nil
  end

  it "should match the Client-Ip header in a case-insensitive manner" do
    get "/", {}, {"HtTp_CLieNT_Ip" => "1.2.3.4"}
    expect(@inner_app_env["HtTp_CLieNT_Ip"]).to be_nil
  end

  it "should pass other headers through unmodified" do
    get "/", {}, {"HTTP_CLIENT_IP" => "1.2.3.4", "Foo" => "bar"}
    expect(@inner_app_env["Foo"]).to eq("bar")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack_strip_client_ip-0.0.2 spec/middleware_spec.rb
rack_strip_client_ip-0.0.1 spec/middleware_spec.rb