Permalink
Browse files

use token object in authorization endpoint's token response

  • Loading branch information...
1 parent c69ab1a commit 73defb6f091e66609e90d4c9e5ed1200ddf11906 @nov nov committed Apr 20, 2011
Showing with 6 additions and 30 deletions.
  1. +1 −1 VERSION
  2. +2 −8 lib/rack/oauth2/server/authorize/token.rb
  3. +3 −21 spec/rack/oauth2/server/authorize/token_spec.rb
View
@@ -1 +1 @@
-0.6.0.alpha
+0.6.0
@@ -18,16 +18,10 @@ def initialize(env)
end
class Response < Authorize::Response
- attr_required :access_token, :token_type
- attr_optional :expires_in, :scope
+ attr_required :access_token
def protocol_params
- super.merge(
- :access_token => access_token,
- :token_type => token_type,
- :expires_in => expires_in,
- :scope => Array(scope).join(' ')
- )
+ super.merge access_token.token_response
end
def protocol_params_location
@@ -4,29 +4,26 @@
let(:request) { Rack::MockRequest.new app }
let(:redirect_uri) { 'http://client.example.com/callback' }
let(:access_token) { 'access_token' }
- let(:token_type) { 'bearer' }
let(:response) { request.get("/?response_type=token&client_id=client&redirect_uri=#{redirect_uri}") }
context "when approved" do
let :app do
Rack::OAuth2::Server::Authorize.new do |request, response|
response.redirect_uri = redirect_uri
- response.access_token = access_token
- response.token_type = token_type
+ response.access_token = Rack::OAuth2::AccessToken::Bearer.new(:access_token => access_token)
response.approve!
end
end
it 'should redirect with authorization code in fragment' do
response.status.should == 302
- response.location.should == "#{redirect_uri}#access_token=#{access_token}&token_type=#{token_type}"
+ response.location.should == "#{redirect_uri}#access_token=#{access_token}&token_type=bearer"
end
context 'when redirect_uri is missing' do
let :app do
Rack::OAuth2::Server::Authorize.new do |request, response|
- response.access_token = access_token
- response.token_type = token_type
+ response.access_token = Rack::OAuth2::AccessToken::Bearer.new(:access_token => access_token)
response.approve!
end
end
@@ -39,28 +36,13 @@
let :app do
Rack::OAuth2::Server::Authorize.new do |request, response|
response.redirect_uri = redirect_uri
- response.token_type = token_type
response.approve!
end
end
it do
expect { response }.should raise_error AttrRequired::AttrMissing
end
end
-
- context 'when token_type is missing' do
- let :app do
- Rack::OAuth2::Server::Authorize.new do |request, response|
- response.redirect_uri = redirect_uri
- response.access_token = access_token
- response.approve!
- end
- end
-
- it do
- expect { response }.should raise_error AttrRequired::AttrMissing
- end
- end
end
context 'when denied' do

0 comments on commit 73defb6

Please sign in to comment.