Sha256: 4a03704168a3c1c7b34e4cd2339dbab93d373ace0881e7c295f9f2d97c07ab88

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe Rack::OAuth2::Server::Authorize::Extension::IdToken do
  subject { response }
  let(:request)      { Rack::MockRequest.new app }
  let(:response)     { request.get('/?response_type=id_token&client_id=client&state=state') }
  let(:redirect_uri) { 'http://client.example.com/callback' }
  let :id_token do
    OpenIDConnect::ResponseObject::IdToken.new(
      :iss => 'https://server.example.com',
      :user_id => 'user_id',
      :aud => 'client_id',
      :exp => 1313424327
    ).to_jwt private_key
  end

  context 'when id_token is given' do
    let :app do
      Rack::OAuth2::Server::Authorize.new do |request, response|
        response.redirect_uri = redirect_uri
        response.id_token = id_token
        response.approve!
      end
    end
    its(:status)   { should == 302 }
    its(:location) { should_not include '?' }
    its(:location) { should include '#' }
    its(:location) { should include "id_token=#{id_token}" }
    its(:location) { should include 'state=state' }

    context 'when id_token is String' do
      let(:id_token) { 'id_token' }
      its(:location) { should include 'id_token=id_token' }
    end
  end

  context 'otherwise' do
    let :app do
      Rack::OAuth2::Server::Authorize.new do |request, response|
        response.redirect_uri = redirect_uri
        response.approve!
      end
    end
    it do
      expect { response }.should raise_error AttrRequired::AttrMissing, "'id_token' required."
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
openid_connect-0.1.1 spec/rack/oauth2/server/authorize/extension/id_token_spec.rb
openid_connect-0.1.0 spec/rack/oauth2/server/authorize/extension/id_token_spec.rb
openid_connect-0.0.33 spec/rack/oauth2/server/authorize/extension/id_token_spec.rb
openid_connect-0.0.32 spec/rack/oauth2/server/authorize/extension/id_token_spec.rb