Sha256: 874dc711e77cd31fa9a6f3d3948d995acf829dcba4f57a70d5fe698f01479403

Contents?: true

Size: 1.05 KB

Versions: 44

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper.rb'

describe Rack::OAuth2::Server::Token::JWTBearer do
  let(:request) { Rack::MockRequest.new app }
  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
  let(:params) do
    {
      grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
      client_id: 'client_id',
      assertion: 'header.payload.signature'
    }
  end
  subject { request.post('/', params: params) }

  its(:status)       { should == 200 }
  its(:content_type) { should == 'application/json' }
  its(:body)         { should include '"access_token":"access_token"' }
  its(:body)         { should include '"token_type":"bearer"' }

  context 'when assertion is missing' do
    before do
      params.delete_if do |key, value|
        key == :assertion
      end
    end
    its(:status)       { should == 400 }
    its(:content_type) { should == 'application/json' }
    its(:body)         { should include '"error":"invalid_request"' }
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
rack-oauth2-1.13.0.beta spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.12.0 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.11.0 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.10.1 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.10.0 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.9.3 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.9.2 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.9.1 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.9.0 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.8.2 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.8.1 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.8.0 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.7.1 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.7.0 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.6.4 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.6.3 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.6.2 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.6.1 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.6.0 spec/rack/oauth2/server/token/jwt_bearer_spec.rb
rack-oauth2-1.5.1 spec/rack/oauth2/server/token/jwt_bearer_spec.rb