Sha256: 6b075870bb6b5125a636b40b6e2c5ee1f0dabc93bc37f8e9ad55e9b2b0345209

Contents?: true

Size: 1.4 KB

Versions: 15

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'
require 'active_model'
require 'doorkeeper'
require 'doorkeeper/oauth/invalid_token_response'

module Doorkeeper::OAuth
  describe InvalidTokenResponse do
    describe "#name" do
      it  { expect(subject.name).to eq(:invalid_token) }
    end

    describe "#status" do
      it { expect(subject.status).to eq(:unauthorized) }
    end

    describe :from_access_token do
      let(:response) { InvalidTokenResponse.from_access_token(access_token) }

      context "revoked" do
        let(:access_token) { double(revoked?: true, expired?: true) }

        it "sets a description" do
          expect(response.description).to include("revoked")
        end

        it "sets the reason" do
          expect(response.reason).to eq(:revoked)
        end
      end

      context "expired" do
        let(:access_token) { double(revoked?: false, expired?: true) }

        it "sets a description" do
          expect(response.description).to include("expired")
        end

        it "sets the reason" do
          expect(response.reason).to eq(:expired)
        end
      end

      context "unknown" do
        let(:access_token) { double(revoked?: false, expired?: false) }

        it "sets a description" do
          expect(response.description).to include("invalid")
        end

        it "sets the reason" do
          expect(response.reason).to eq(:unknown)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
doorkeeper-mongodb-4.2.0 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-sequel-1.5.0 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-4.4.3 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-4.4.2 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-4.4.1 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-4.4.0 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-mongodb-4.1.0 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-4.3.2 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-4.3.1 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-4.3.0 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-sequel-1.4.0 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-mongodb-4.0.1 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-mongodb-4.0.0 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-sequel-1.3.1 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-sequel-1.3.0 spec/lib/oauth/invalid_token_response_spec.rb