Sha256: 92f3254ab8ea6297be437a96eecdbb79d68aca86e08a9ccbbe81ad2d9a89b522

Contents?: true

Size: 1.97 KB

Versions: 14

Compression:

Stored size: 1.97 KB

Contents

require File.expand_path('../spec_helper.rb', __FILE__)

describe Rack::Protection::SessionHijacking do
  it_behaves_like "any rack application"

  it "accepts a session without changes to tracked parameters" do
    session = {:foo => :bar}
    get '/', {}, 'rack.session' => session
    get '/', {}, 'rack.session' => session
    session[:foo].should == :bar
  end

  it "denies requests with a changing User-Agent header" do
    session = {:foo => :bar}
    get '/', {}, 'rack.session' => session, 'HTTP_USER_AGENT' => 'a'
    get '/', {}, 'rack.session' => session, 'HTTP_USER_AGENT' => 'b'
    session.should be_empty
  end

  it "denies requests with a changing Accept-Encoding header" do
    session = {:foo => :bar}
    get '/', {}, 'rack.session' => session, 'HTTP_ACCEPT_ENCODING' => 'a'
    get '/', {}, 'rack.session' => session, 'HTTP_ACCEPT_ENCODING' => 'b'
    session.should be_empty
  end

  it "denies requests with a changing Accept-Language header" do
    session = {:foo => :bar}
    get '/', {}, 'rack.session' => session, 'HTTP_ACCEPT_LANGUAGE' => 'a'
    get '/', {}, 'rack.session' => session, 'HTTP_ACCEPT_LANGUAGE' => 'b'
    session.should be_empty
  end

  it "accepts requests with the same Accept-Language header" do
    session = {:foo => :bar}
    get '/', {}, 'rack.session' => session, 'HTTP_ACCEPT_LANGUAGE' => 'a'
    get '/', {}, 'rack.session' => session, 'HTTP_ACCEPT_LANGUAGE' => 'a'
    session.should_not be_empty
  end

  it "comparison of Accept-Language header is not case sensitive" do
    session = {:foo => :bar}
    get '/', {}, 'rack.session' => session, 'HTTP_ACCEPT_LANGUAGE' => 'a'
    get '/', {}, 'rack.session' => session, 'HTTP_ACCEPT_LANGUAGE' => 'A'
    session.should_not be_empty
  end

  it "accepts requests with a changing Version header"do
    session = {:foo => :bar}
    get '/', {}, 'rack.session' => session, 'HTTP_VERSION' => '1.0'
    get '/', {}, 'rack.session' => session, 'HTTP_VERSION' => '1.1'
    session[:foo].should == :bar
  end
end

Version data entries

14 entries across 12 versions & 3 rubygems

Version Path
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rack-protection-1.5.1/spec/session_hijacking_spec.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rack-protection-1.5.1/spec/session_hijacking_spec.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/rack-protection-1.5.1/spec/session_hijacking_spec.rb
rack-protection-1.5.1 spec/session_hijacking_spec.rb
torquebox-console-0.3.0 vendor/bundle/jruby/1.9/gems/rack-protection-1.4.0/spec/session_hijacking_spec.rb
torquebox-console-0.2.5 vendor/bundle/jruby/1.9/gems/rack-protection-1.4.0/spec/session_hijacking_spec.rb
torquebox-console-0.2.5 vendor/bundle/ruby/1.8/gems/rack-protection-1.4.0/spec/session_hijacking_spec.rb
rack-protection-1.5.0 spec/session_hijacking_spec.rb
torquebox-console-0.2.4 vendor/bundle/jruby/1.9/gems/rack-protection-1.4.0/spec/session_hijacking_spec.rb
torquebox-console-0.2.4 vendor/bundle/ruby/1.8/gems/rack-protection-1.4.0/spec/session_hijacking_spec.rb
torquebox-console-0.2.3 vendor/bundle/jruby/1.9/gems/rack-protection-1.4.0/spec/session_hijacking_spec.rb
rack-protection-1.4.0 spec/session_hijacking_spec.rb
rack-protection-1.3.2 spec/session_hijacking_spec.rb
rack-protection-1.3.1 spec/session_hijacking_spec.rb