Sha256: b1651d5aa7451da6b273c524919f1a5157360a69cb05372beb67aef254c1e16d

Contents?: true

Size: 1.48 KB

Versions: 19

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'
require 'active_support/core_ext/string'
require 'doorkeeper/oauth/client'

class Doorkeeper::OAuth::Client
  describe 'Methods' do
    let(:client_id) { "some-uid" }
    let(:client_secret) { "some-secret" }

    subject do
      Class.new do
        include Methods
      end.new
    end

    describe :from_params do
      it 'returns credentials from parameters when Authorization header is not available' do
        request     = stub :parameters => { :client_id => client_id, :client_secret => client_secret }
        uid, secret = subject.from_params(request)

        uid.should    == "some-uid"
        secret.should == "some-secret"
      end

      it 'is blank when there are no credentials' do
        request     = stub :parameters => {}
        uid, secret = subject.from_params(request)

        uid.should    be_blank
        secret.should be_blank
      end
    end

    describe :from_basic do
      let(:credentials) { Base64.encode64("#{client_id}:#{client_secret}") }

      it 'decodes the credentials' do
        request     = stub :authorization => "Basic #{credentials}"
        uid, secret = subject.from_basic(request)

        uid.should    == "some-uid"
        secret.should == "some-secret"
      end

      it 'is blank if Authorization is not Basic' do
        request     = stub :authorization => "#{credentials}"
        uid, secret = subject.from_basic(request)

        uid.should    be_blank
        secret.should be_blank
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
doorkeeper-0.7.4 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.7.3 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.7.2 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.7.1 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.7.0 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.6.7 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.6.6 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.6.5 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.6.4 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.6.3 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.6.2 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.6.1 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.6.0 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.6.0.rc1 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.5.0 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.5.0.rc1 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.4.2 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.4.1 spec/lib/oauth/client/methods_spec.rb
doorkeeper-0.4.0 spec/lib/oauth/client/methods_spec.rb