Sha256: f7990bdc5bd311aa72539454968e2e358d3f908f22101cda94cbbd70a9733dc3

Contents?: true

Size: 856 Bytes

Versions: 58

Compression:

Stored size: 856 Bytes

Contents

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

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

  describe 'json response' do
    before do
      mock_app { |e| [200, {'Content-Type' => 'application/json'}, []]}
    end

    it "denies get requests with json responses with a remote referrer" do
      get('/', {}, 'HTTP_REFERER' => 'http://evil.com').should_not be_ok
    end

    it "accepts get requests with json responses with a local referrer" do
      get('/', {}, 'HTTP_REFERER' => '/').should be_ok
    end

    it "accepts get requests with json responses with no referrer" do
      get('/', {}).should be_ok
    end
  end

  describe 'not json response' do

    it "accepts get requests with 304 headers" do
      mock_app { |e| [304, {}, []]}
      get('/', {}).status.should == 304
    end

  end
end

Version data entries

58 entries across 58 versions & 4 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.6.9 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.6.8 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.6.7 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.6.6 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.6.5 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.6.4 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.6.3 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.6.2 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.6.1 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.6.0 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.5.17 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.5.16 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.5.15 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb
classiccms-0.5.14 vendor/bundle/gems/rack-protection-1.2.0/spec/json_csrf_spec.rb