Sha256: c8990e3e0f6516b5cd88882162b48ded04d0ec6e581d2f5bd242cbdf5bce0f49
Contents?: true
Size: 1.88 KB
Versions: 3
Compression:
Stored size: 1.88 KB
Contents
require 'spec_helper' require 'active_support/all' require 'active_model' require 'doorkeeper/oauth/client_credentials_request' module Doorkeeper::OAuth describe ClientCredentialsRequest do let(:server) { stub :default_scopes => nil } let(:client) { stub } let(:token_creator) { mock :issuer, :create => true, :token => stub } subject { ClientCredentialsRequest.new(server, client) } before do subject.issuer = token_creator end it 'issues an access token for the current client' do token_creator.should_receive(:create).with(client, nil) subject.authorize end it 'has successful response when issue was created' do subject.authorize subject.response.should be_a(ClientCredentialsRequest::Response) end it 'has an error response if issue was not created' do subject.issuer = stub :create => false, :error => :invalid subject.authorize subject.response.should be_a(Doorkeeper::OAuth::ErrorResponse) end it 'delegates the error to issuer' do subject.issuer = stub :create => false, :error => :invalid subject.authorize subject.error.should == :invalid end context 'with scopes' do let(:default_scopes) { Doorkeeper::OAuth::Scopes.from_string("public email") } before do server.stub(:default_scopes).and_return(default_scopes) end it 'issues an access token with default scopes if none was requested' do token_creator.should_receive(:create).with(client, default_scopes) subject.authorize end it 'issues an access token with requested scopes' do subject = ClientCredentialsRequest.new(server, client, :scope => "email") subject.issuer = token_creator token_creator.should_receive(:create).with(client, Doorkeeper::OAuth::Scopes.from_string("email")) subject.authorize end end end end
Version data entries
3 entries across 3 versions & 1 rubygems