Sha256: 93978f20588fcdba8e3d7495e80e03b95329b6d47a2fe6498d63d5a23c5ace3b

Contents?: true

Size: 1.27 KB

Versions: 15

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

require "spec_helper"

module Doorkeeper::OAuth
  describe Client do
    describe :find do
      let(:method) { double }

      it "finds the client via uid" do
        client = double
        expect(method).to receive(:call).with("uid").and_return(client)
        expect(Client.find("uid", method)).to be_a(Client)
      end

      it "returns nil if client was not found" do
        expect(method).to receive(:call).with("uid").and_return(nil)
        expect(Client.find("uid", method)).to be_nil
      end
    end

    describe :authenticate do
      it "returns the authenticated client via credentials" do
        credentials = Client::Credentials.new("some-uid", "some-secret")
        authenticator = double
        expect(authenticator).to receive(:call).with("some-uid", "some-secret").and_return(double)
        expect(Client.authenticate(credentials, authenticator)).to be_a(Client)
      end

      it "returns nil if client was not authenticated" do
        credentials = Client::Credentials.new("some-uid", "some-secret")
        authenticator = double
        expect(authenticator).to receive(:call).with("some-uid", "some-secret").and_return(nil)
        expect(Client.authenticate(credentials, authenticator)).to be_nil
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
doorkeeper-5.1.2 spec/lib/oauth/client_spec.rb
doorkeeper-5.2.6 spec/lib/oauth/client_spec.rb
doorkeeper-5.1.1 spec/lib/oauth/client_spec.rb
doorkeeper-5.2.5 spec/lib/oauth/client_spec.rb
doorkeeper-sequel-2.2.0 spec/lib/oauth/client_spec.rb
doorkeeper-5.2.4 spec/lib/oauth/client_spec.rb
doorkeeper-5.2.3 spec/lib/oauth/client_spec.rb
doorkeeper-5.2.2 spec/lib/oauth/client_spec.rb
doorkeeper-sequel-2.1.0 spec/lib/oauth/client_spec.rb
doorkeeper-5.2.1 spec/lib/oauth/client_spec.rb
doorkeeper-5.2.0 spec/lib/oauth/client_spec.rb
doorkeeper-5.2.0.rc3 spec/lib/oauth/client_spec.rb
doorkeeper-5.2.0.rc2 spec/lib/oauth/client_spec.rb
doorkeeper-5.2.0.rc1 spec/lib/oauth/client_spec.rb
doorkeeper-5.1.0 spec/lib/oauth/client_spec.rb