Sha256: 5ef99bbb6427a7660be9f0b0c225d98decbea94c20b0b7ed3a4a464cbd6c09ae

Contents?: true

Size: 1.86 KB

Versions: 12

Compression:

Stored size: 1.86 KB

Contents

require 'spec_helper.rb'

describe Rack::OAuth2::Server::Token::RefreshToken do
  subject { response }
  let(:request) { Rack::MockRequest.new app }
  let :response do
    request.post('/', :params => {
      :grant_type => "refresh_token",
      :client_id => "client_id",
      :refresh_token => "refresh_token"
    })
  end
  let :id_token do
    OpenIDConnect::ResponseObject::IdToken.new(
      :iss => 'https://server.example.com',
      :user_id => 'user_id',
      :aud => 'client_id',
      :exp => 1313424327,
      :secret => 'secret'
    )
  end

  context "when id_token is given" do
    let :app do
      Rack::OAuth2::Server::Token.new do |request, response|
        response.access_token = Rack::OAuth2::AccessToken::Bearer.new(:access_token => 'access_token')
        response.id_token = id_token
        response.private_key = private_key
      end
    end
    its(:status) { should == 200 }
    its(:body)   { should include "\"id_token\":\"#{id_token.to_jwt(private_key)}\"" }

    context 'when id_token is String' do
      let(:id_token) { 'id_token' }
      its(:body)     { should include "\"id_token\":\"id_token\"" }
    end

    context 'when private_key is missing' do
      let :app do
        Rack::OAuth2::Server::Token.new do |request, response|
          response.access_token = Rack::OAuth2::AccessToken::Bearer.new(:access_token => 'access_token')
          response.id_token = id_token
        end
      end
      it do
        expect { response }.should raise_error AttrRequired::AttrMissing, "'private_key' required."
      end
    end
  end

  context "otherwise" do
    let :app do
      Rack::OAuth2::Server::Token.new do |request, response|
        response.access_token = Rack::OAuth2::AccessToken::Bearer.new(:access_token => 'access_token')
      end
    end
    its(:status) { should == 200 }
    its(:body)   { should_not include "id_token" }
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
openid_connect-0.0.27 spec/rack/oauth2/server/token/refresh_token_spec.rb
openid_connect-0.0.26 spec/rack/oauth2/server/token/refresh_token_spec.rb
openid_connect-0.0.25 spec/rack/oauth2/server/token/refresh_token_spec.rb
openid_connect-0.0.24 spec/rack/oauth2/server/token/refresh_token_spec.rb
openid_connect-0.0.23 spec/rack/oauth2/server/token/refresh_token_spec.rb
openid_connect-0.0.22 spec/rack/oauth2/server/token/refresh_token_spec.rb
openid_connect-0.0.21 spec/rack/oauth2/server/token/refresh_token_spec.rb
openid_connect-0.0.20 spec/rack/oauth2/server/token/refresh_token_spec.rb
openid_connect-0.0.19 spec/rack/oauth2/server/token/refresh_token_spec.rb
openid_connect-0.0.18 spec/rack/oauth2/server/token/refresh_token_spec.rb
openid_connect-0.0.17 spec/rack/oauth2/server/token/refresh_token_spec.rb
openid_connect-0.0.16 spec/rack/oauth2/server/token/refresh_token_spec.rb