Sha256: af37bf344e4e229996079a7f8a2263859bd95b2c07e38e5113a41fd8950fba29

Contents?: true

Size: 1.79 KB

Versions: 3

Compression:

Stored size: 1.79 KB

Contents

require File.expand_path(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.normalized_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.normalized_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.normalized_uri
    assert_equal 'POST', request_proxy.method
  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
qoobaa-oauth-0.3.8 test/test_rack_request_proxy.rb
drogus-oauth-0.3.7 test/test_rack_request_proxy.rb
drogus-oauth-0.3.6 test/test_rack_request_proxy.rb