Sha256: fe566f7ec893d9d4a981ea23766bfad63f5f6562228f8169d5e0c9488698a604

Contents?: true

Size: 1.18 KB

Versions: 44

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

describe Rack::OAuth2::AccessToken::Authenticator do
  let(:resource_endpoint) { 'https://server.example.com/resources/fake' }
  let(:request) { HTTP::Message.new_request(:get, URI.parse(resource_endpoint)) }
  let(:authenticator) { Rack::OAuth2::AccessToken::Authenticator.new(token) }

  shared_examples_for :authenticator do
    it 'should let the token authenticate the request' do
      token.should_receive(:authenticate).with(request)
      authenticator.filter_request(request)
    end
  end

  context 'when Legacy token is given' do
    let(:token) do
      Rack::OAuth2::AccessToken::Legacy.new(
        :access_token => 'access_token'
      )
    end
    it_behaves_like :authenticator
  end

  context 'when Bearer token is given' do
    let(:token) do
      Rack::OAuth2::AccessToken::Bearer.new(
        :access_token => 'access_token'
      )
    end
    it_behaves_like :authenticator
  end

  context 'when MAC token is given' do
    let(:token) do
      Rack::OAuth2::AccessToken::MAC.new(
        :access_token => 'access_token',
        :mac_key => 'secret',
        :mac_algorithm => 'hmac-sha-256'
      )
    end
    it_behaves_like :authenticator
  end
end

Version data entries

44 entries across 44 versions & 2 rubygems

Version Path
rack-oauth2-1.0.8 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-revibe-1.0.7 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.0.7 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.0.6 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.0.5 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.0.4 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.0.3 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.0.2 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.0.1 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-1.0.0 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-0.14.9 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-0.14.8 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-0.14.7 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-0.14.6 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-0.14.5 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-0.14.4 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-0.14.3 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-0.14.2 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-0.14.1 spec/rack/oauth2/access_token/authenticator_spec.rb
rack-oauth2-0.14.0 spec/rack/oauth2/access_token/authenticator_spec.rb