Sha256: 09073a0707091feadf7d338094ea1171b7163074a0e546abcdff6d2ce707db58

Contents?: true

Size: 1.77 KB

Versions: 16

Compression:

Stored size: 1.77 KB

Contents

require File.expand_path('../test_helper', __FILE__)
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

16 entries across 15 versions & 7 rubygems

Version Path
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/oauth-0.4.7/test/test_rack_request_proxy.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/oauth-0.4.7/test/test_rack_request_proxy.rb
oauth-ap-0.4.8 test/test_rack_request_proxy.rb
oauth-instructure-0.4.10 test/test_rack_request_proxy.rb
oauth_weshays-0.4.8.pre2 test/test_rack_request_proxy.rb
oauth_weshays-0.4.8.pre test/test_rack_request_proxy.rb
oauth-instructure-0.4.9 test/test_rack_request_proxy.rb
oauth-instructure-0.4.8 test/test_rack_request_proxy.rb
oauth-0.4.7 test/test_rack_request_proxy.rb
motionbox-oauth-0.4.5 test/test_rack_request_proxy.rb
oauth-0.4.6 test/test_rack_request_proxy.rb
oauth-0.4.5 test/test_rack_request_proxy.rb
sayso-oauth-0.4.4.001 test/test_rack_request_proxy.rb
oauth-0.4.4 test/test_rack_request_proxy.rb
oauth-0.4.3 test/test_rack_request_proxy.rb
oauth-0.4.2 test/test_rack_request_proxy.rb