Sha256: c9bffdecac4c52c954755318e17c0def2f79b20cf94d607a69a805e458ebdc8b

Contents?: true

Size: 1.09 KB

Versions: 11

Compression:

Stored size: 1.09 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 = 'access_token'
      response.token_type = :bearer
    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

11 entries across 11 versions & 1 rubygems

Version Path
rack-oauth2-0.5.1 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.5.0 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.4.6 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.4.5 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.4.4 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.4.3 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.4.2 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.4.1 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.4.0 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.3.1 spec/rack/oauth2/server/token/password_spec.rb
rack-oauth2-0.3.0 spec/rack/oauth2/server/token/password_spec.rb