<commit_before>require File.dirname(__FILE__) + '/test_helper.rb'
require 'oauth/request_proxy/action_controller_request.rb'
require 'action_controller'
require 'action_controller/test_process'

class ActionControllerRequestProxyTest < Test::Unit::TestCase

  def request_proxy(request_method = :get, uri_params = {}, body_params = {})
    request = ActionController::TestRequest.new

    case request_method
    when :post
      request.env['REQUEST_METHOD'] = 'POST'
    when :put
      request.env['REQUEST_METHOD'] = 'PUT'
    end

    request.env['RAW_POST_DATA'] = body_params.to_query
    request.env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'

    yield request if block_given?
    OAuth::RequestProxy.proxy(request, :parameters=>uri_params)
  end

  def test_that_proxy_simple_get_request_works_with_query_params
    request_proxy = request_proxy(:get, {'key'=>'value'})

    expected_parameters = [["key", "value"]]
    assert_equal expected_parameters, request_proxy.parameters_for_signature
    assert_equal 'GET', request_proxy.method
  end

  def test_that_proxy_simple_post_request_works_with_query_params
    request_proxy = request_proxy(:post, {'key'=>'value'})

    expected_parameters = [["key", "value"]]
    assert_equal expected_parameters, request_proxy.parameters_for_signature
    assert_equal 'POST', request_proxy.method
  end
<commit_msg>Provide REQUEST_URI in the request_proxy env, needed for rails 2.3.2<commit_after>require File.dirname(__FILE__) + '/test_helper.rb'
require 'oauth/request_proxy/action_controller_request.rb'
require 'action_controller'
require 'action_controller/test_process'

class ActionControllerRequestProxyTest < Test::Unit::TestCase

  def request_proxy(request_method = :get, uri_params = {}, body_params = {})
    request = ActionController::TestRequest.new

    case request_method
    when :post
      request.env['REQUEST_METHOD'] = 'POST'
    when :put
      request.env['REQUEST_METHOD'] = 'PUT'
    end

    request.env['REQUEST_URI'] = '/'
    request.env['RAW_POST_DATA'] = body_params.to_query
    request.env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'

    yield request if block_given?
    OAuth::RequestProxy.proxy(request, :parameters=>uri_params)
  end

  def test_that_proxy_simple_get_request_works_with_query_params
    request_proxy = request_proxy(:get, {'key'=>'value'})

    expected_parameters = [["key", "value"]]
    assert_equal expected_parameters, request_proxy.parameters_for_signature
    assert_equal 'GET', request_proxy.method
  end

  def test_that_proxy_simple_post_request_works_with_query_params
    request_proxy = request_proxy(:post, {'key'=>'value'})

    expected_parameters = [["key", "value"]]
    assert_equal expected_parameters, request_proxy.parameters_for_signature
    assert_equal 'POST', request_proxy.method
  end

{'fraction_non_alphanumeric': 0.1074438202247191, 'fraction_numerical': 0.001053370786516854, 'mean_word_length': 5.4603174603174605, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6604207', 'n_tokens_mistral': 871, 'n_tokens_neox': 853, 'n_words': 152}