Sha256: 46361af09f95faddd78a00ee9eba3bf7a6e95a2ea7524ca729c5d226919f1f61

Contents?: true

Size: 1.35 KB

Versions: 11

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper_integration'

describe Doorkeeper::TokenInfoController do

  describe "when requesting tokeninfo with valid token" do

    let(:doorkeeper_token) { FactoryGirl.create(:access_token) }

    before(:each) do
      controller.stub(:doorkeeper_token) { doorkeeper_token }
    end

    def do_get
      get :show
    end

    describe "successful request" do

      it "responds with tokeninfo" do
        do_get
        expect(response.body).to eq(doorkeeper_token.to_json)
      end

      it "responds with a 200 status" do
        do_get
        expect(response.status).to eq 200
      end
    end

    describe "invalid token response" do
      before(:each) do
        controller.stub(:doorkeeper_token => nil)
      end
      it "responds with 401 when doorkeeper_token is not valid" do
        do_get
        expect(response.status).to eq 401
      end

      it "responds with 401 when doorkeeper_token is invalid, expired or revoked" do
        controller.stub(:doorkeeper_token => doorkeeper_token)
        doorkeeper_token.stub(:accessible? => false)
        do_get
        expect(response.status).to eq 401
      end

      it "responds body message for error" do
        do_get
        expect(response.body).to eq(Doorkeeper::OAuth::ErrorResponse.new(:name => :invalid_request, :status => :unauthorized).body.to_json)
      end
    end

  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
doorkeeper-1.0.0.rc1 spec/controllers/token_info_controller_spec.rb
doorkeeper-0.7.4 spec/controllers/token_info_controller_spec.rb
doorkeeper-0.7.3 spec/controllers/token_info_controller_spec.rb
doorkeeper-0.7.2 spec/controllers/token_info_controller_spec.rb
doorkeeper-0.7.1 spec/controllers/token_info_controller_spec.rb
doorkeeper-0.7.0 spec/controllers/token_info_controller_spec.rb
doorkeeper-0.6.7 spec/controllers/token_info_controller_spec.rb
doorkeeper-0.6.6 spec/controllers/token_info_controller_spec.rb
doorkeeper-0.6.5 spec/controllers/token_info_controller_spec.rb
doorkeeper-0.6.4 spec/controllers/token_info_controller_spec.rb
doorkeeper-0.6.3 spec/controllers/token_info_controller_spec.rb