Sha256: 563cb33866cd110a78080b29ce4f3485a796a893182232a91fc6f1f2887b41b9

Contents?: true

Size: 1.28 KB

Versions: 5

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require "spec_helper"

RSpec.describe Doorkeeper::OAuth::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) { described_class.from_access_token(access_token) }

    context "when token 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 "when token 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 "when 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

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
doorkeeper-mongodb-5.3.0 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-mongodb-5.2.3 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-sequel-2.4.0 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-mongodb-5.2.2 spec/lib/oauth/invalid_token_response_spec.rb
doorkeeper-sequel-2.3.0 spec/lib/oauth/invalid_token_response_spec.rb