Sha256: 18789f51aa7cf8b49c0b017e1283b1a989069cd41cd07884ad6e713069054878

Contents?: true

Size: 1.74 KB

Versions: 7

Compression:

Stored size: 1.74 KB

Contents

require File.dirname(__FILE__) + '/test_helper.rb'
require 'oauth/request_proxy/rack_request'
require 'rack/request'
require 'rack/mock'

class RackRequestProxyTest < Test::Unit::TestCase

  def test_that_proxy_simple_get_request_works
    request = Rack::Request.new(Rack::MockRequest.env_for('http://example.com/test?key=value'))
    request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value'})

    expected_parameters = {'key' => 'value'}
    assert_equal expected_parameters, request_proxy.parameters
    assert_equal 'http://example.com/test', request_proxy.uri
    assert_equal 'GET', request_proxy.method
  end

  def test_that_proxy_simple_post_request_works
    request = Rack::Request.new(Rack::MockRequest.env_for('http://example.com/test', :method => 'POST'))
    params = {'key' => 'value'}
    request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params})

    expected_parameters = {'key' => 'value'}
    assert_equal expected_parameters, request_proxy.parameters
    assert_equal 'http://example.com/test', request_proxy.uri
    assert_equal 'POST', request_proxy.method
  end

  def test_that_proxy_post_and_get_request_works
    request = Rack::Request.new(Rack::MockRequest.env_for('http://example.com/test?key=value', :method => 'POST', :input => 'key2=value2'))
    params = {'key2' => 'value2'}
    request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value', :parameters => params})

    expected_parameters = {'key' => 'value', 'key2' => 'value2'}
    assert_equal expected_parameters, request_proxy.parameters
    assert_equal 'http://example.com/test', request_proxy.uri
    assert_equal 'POST', request_proxy.method
  end

end

Version data entries

7 entries across 7 versions & 4 rubygems

Version Path
pelle-oauth-0.2.6 test/test_rack_request_proxy.rb
pelle-oauth-0.2.7 test/test_rack_request_proxy.rb
rares-oauth-0.2.7 test/test_rack_request_proxy.rb
stmpjmpr-oauth-0.2.7 test/test_rack_request_proxy.rb
oauth-0.2.6 test/test_rack_request_proxy.rb
oauth-0.2.4 test/test_rack_request_proxy.rb
oauth-0.2.7 test/test_rack_request_proxy.rb