Sha256: b901e6e0ef6702922a5eb6218abbec0c97852c8a216fafbeb84a7092b3b89b1e

Contents?: true

Size: 1.26 KB

Versions: 65

Compression:

Stored size: 1.26 KB

Contents

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

describe Rack::Protection::Base do

  subject { described_class.new(lambda {}) }

  describe "#random_string" do
    it "outputs a string of 32 characters" do
      subject.random_string.length.should == 32
    end
  end

  describe "#referrer" do
    it "Reads referrer from Referer header" do
      env = {"HTTP_HOST" => "foo.com", "HTTP_REFERER" => "http://bar.com/valid"}
      subject.referrer(env).should == "bar.com"
    end

    it "Reads referrer from Host header when Referer header is relative" do
      env = {"HTTP_HOST" => "foo.com", "HTTP_REFERER" => "/valid"}
      subject.referrer(env).should == "foo.com"
    end

    it "Reads referrer from Host header when Referer header is missing" do
      env = {"HTTP_HOST" => "foo.com"}
      subject.referrer(env).should == "foo.com"
    end

    it "Returns nil when Referer header is missing and allow_empty_referrer is false" do
      env = {"HTTP_HOST" => "foo.com"}
      subject.options[:allow_empty_referrer] = false
      subject.referrer(env).should be_nil
    end

    it "Returns nil when Referer header is invalid" do
      env = {"HTTP_HOST" => "foo.com", "HTTP_REFERER" => "http://bar.com/bad|uri"}
      subject.referrer(env).should be_nil
    end
  end
end

Version data entries

65 entries across 62 versions & 18 rubygems

Version Path
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/rack-protection-1.5.3/spec/base_spec.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/rack-protection-1.5.3/spec/base_spec.rb
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/rack-protection-1.5.3/spec/base_spec.rb
logstash-filter-csharp-0.1.0 vendor/bundle/jruby/2.3.0/gems/rack-protection-1.5.3/spec/base_spec.rb
logstash-filter-htmlentities-0.1.0 vendor/bundle/jruby/1.9/gems/rack-protection-1.5.3/spec/base_spec.rb
logstash-output-icinga-1.0.0 vendor/jruby/1.9/gems/rack-protection-1.5.3/spec/base_spec.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/rack-protection-1.5.3/spec/base_spec.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/rack-protection-1.5.3/spec/base_spec.rb
logstash-input-fifo-0.9.1 vendor/bundle/jruby/1.9/gems/rack-protection-1.5.3/spec/base_spec.rb
logstash-input-fifo-0.9.0 vendor/bundle/jruby/1.9/gems/rack-protection-1.5.3/spec/base_spec.rb
logstash-input-salesforce-3.0.0 vendor/jruby/1.9/gems/rack-protection-1.5.3/spec/base_spec.rb
arcabouco-0.2.13 vendor/bundle/gems/rack-protection-1.5.3/spec/base_spec.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/rack-protection-1.5.3/spec/base_spec.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/rack-protection-1.5.3/spec/base_spec.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/rack-protection-1.5.3/spec/base_spec.rb
logstash-filter-delta-1.1.0 vendor/bundle/jruby/2.2.0/gems/rack-protection-1.5.3/spec/base_spec.rb
logstash-filter-delta-1.0.1 vendor/bundle/jruby/2.2.0/gems/rack-protection-1.5.3/spec/base_spec.rb
logstash-filter-base64-1.0.4 vendor/bundle/jruby/2.2.0/gems/rack-protection-1.5.3/spec/base_spec.rb
logstash-filter-base64-1.0.3 vendor/bundle/jruby/2.2.0/gems/rack-protection-1.5.3/spec/base_spec.rb
logstash-filter-delta-1.0.0 vendor/bundle/jruby/2.2.0/gems/rack-protection-1.5.3/spec/base_spec.rb