Sha256: d1597bac4ee505c2f3412738e3f2feea455ec7aa426b61565b556b824c7bfa9b

Contents?: true

Size: 1.22 KB

Versions: 49

Compression:

Stored size: 1.22 KB

Contents

require File.dirname(__FILE__) + "/../../spec_helper"

describe Rack::Test::Session do
  context "HTTP Digest authentication" do

    def app
      app = Rack::Auth::Digest::MD5.new(Rack::Test::FakeApp.new) do |username|
        { 'alice' => 'correct-password' }[username]
      end
      app.realm = 'WallysWorld'
      app.opaque = 'this-should-be-secret'
      app
    end

    def be_challenge
      simple_matcher "a HTTP Digest challenge response" do |response|
        response.status == 401 &&
        response['WWW-Authenticate'] =~ /^Digest / &&
        response.body.empty?
      end
    end

    it 'incorrectly authenticates GETs' do
      digest_authorize 'foo', 'bar'
      get '/'
      last_response.should be_challenge
    end

    it "correctly authenticates GETs" do
      digest_authorize "alice", "correct-password"
      response = get "/"
      response.should be_ok
    end

    it "correctly authenticates POSTs" do
      digest_authorize "alice", "correct-password"
      response = post "/"
      response.should be_ok
    end

    it "returns a re-challenge if authenticating incorrectly" do
      digest_authorize "alice", "incorrect-password"
      response = get "/"
      response.should be_challenge
    end

  end
end

Version data entries

49 entries across 49 versions & 3 rubygems

Version Path
tdreyno-middleman-0.2.4 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.2.5 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.2.6 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.2.7 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.2.8 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.2.9 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.3.0 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.3.1 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.3.10 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.3.2 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.3.3 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.3.4 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.3.7 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.3.8 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.4.1 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.5.0 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.5.2 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.5.3 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.5.4 vendor/rack-test/spec/rack/test/digest_auth_spec.rb
tdreyno-middleman-0.5.5 vendor/rack-test/spec/rack/test/digest_auth_spec.rb