Sha256: 715357c418cb910a6d30cf8ffc200d39cb5331bf203bd02b998ef886a244397f

Contents?: true

Size: 1.47 KB

Versions: 44

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper.rb'

describe Rack::OAuth2::Server::Token::AuthorizationCode do
  subject { response }
  let(:request) { Rack::MockRequest.new app }
  let :response do
    request.post('/', params: {
      grant_type: 'authorization_code',
      client_id: 'client_id',
      code: 'authorization_code',
      redirect_uri: 'http://client.example.com/callback'
    })
  end
  let :id_token do
    OpenIDConnect::ResponseObject::IdToken.new(
      iss: 'https://server.example.com',
      sub: 'user_id',
      aud: 'client_id',
      exp: 1313424327,
      iat: 1313420327,
      nonce: 'nonce',
      secret: 'secret'
    ).to_jwt private_key
  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
      end
    end
    its(:status) { should == 200 }
    its(:body)   { should include "\"id_token\":\"#{id_token}\"" }

    context 'when id_token is String' do
      let(:id_token) { 'id_token' }
      its(:body)   { should include "\"id_token\":\"id_token\"" }
    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

44 entries across 44 versions & 1 rubygems

Version Path
openid_connect-2.3.1 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-2.3.0 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-2.2.1 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-2.2.0 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-2.1.0 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-2.0.0 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-2.0.0.rc1 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-1.4.2 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-1.4.1 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-1.4.0 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-1.3.1 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-1.3.0 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-1.2.0 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-1.1.8 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-1.1.7 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-1.1.6 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-1.1.5 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-1.1.4 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-1.1.3 spec/rack/oauth2/server/token/authorization_code_spec.rb
openid_connect-1.1.2 spec/rack/oauth2/server/token/authorization_code_spec.rb