Sha256: 15177e841bf5f54175db25a7031af90a2aab746a37a5d9818344b4cacbb9da11
Contents?: true
Size: 2 KB
Versions: 2
Compression:
Stored size: 2 KB
Contents
require 'spec_helper_integration' module Doorkeeper::OAuth describe PasswordAccessTokenRequest do let(:server) { double :server, :default_scopes => Doorkeeper::OAuth::Scopes.new, :access_token_expires_in => 2.hours, :refresh_token_enabled? => false } let(:credentials) { Client::Credentials.new(client.uid, client.secret) } let(:client) { FactoryGirl.create(:application) } let(:owner) { double :owner, :id => 99 } subject do PasswordAccessTokenRequest.new(server, credentials, owner) end it 'issues a new token for the client' do expect { subject.authorize }.to change { client.access_tokens.count }.by(1) end it 'issues a new token without a client' do expect { subject.credentials = nil subject.authorize }.to change { Doorkeeper::AccessToken.count }.by(1) end it 'does not issue a new token with an invalid client' do expect { subject.client = nil subject.authorize }.to_not change { Doorkeeper::AccessToken.count } subject.error.should == :invalid_client end it 'requires the owner' do subject.resource_owner = nil subject.validate subject.error.should == :invalid_resource_owner end it 'optionally accepts the client' do subject.credentials = nil subject.should be_valid end describe "with scopes" do subject do PasswordAccessTokenRequest.new(server, client, owner, :scope => 'public') end it 'validates the current scope' do server.stub :scopes => Doorkeeper::OAuth::Scopes.from_string('another') subject.validate subject.error.should == :invalid_scope end it 'creates the token with scopes' do server.stub :scopes => Doorkeeper::OAuth::Scopes.from_string("public") expect { subject.authorize }.to change { Doorkeeper::AccessToken.count }.by(1) Doorkeeper::AccessToken.last.scopes.should include('public') end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
doorkeeper-1.0.0.rc2 | spec/lib/oauth/password_access_token_request_spec.rb |
doorkeeper-1.0.0.rc1 | spec/lib/oauth/password_access_token_request_spec.rb |