Sha256: 4f28fd167f60e6d29382b17e82f86d3b6456f87c531e34c27ad05510a0120d17

Contents?: true

Size: 1.11 KB

Versions: 60

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper.rb'

describe Rack::OAuth2::Server::Token::Password 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 => 'password',
      :client_id => 'client_id',
      :username => 'nov',
      :password => 'secret'
    }
  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"' }

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

Version data entries

60 entries across 60 versions & 2 rubygems

Version Path
rack-oauth2-1.1.1 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-1.1.0 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-1.0.10 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-1.0.9 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-1.0.8 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-revibe-1.0.7 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-1.0.7 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-1.0.6 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-1.0.5 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-1.0.4 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-1.0.3 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-1.0.2 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-1.0.1 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-1.0.0 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.14.9 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.14.8 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.14.7 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.14.6 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.14.5 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.14.4 spec/rack/oauth2/server/token/password_spec.rb