Imported Upstream version 0.5.1

parent 4890d5ad
......@@ -67,7 +67,7 @@ module OAuth::RequestProxy
params.
join('&').split('&').
reject(&:blank?).
reject { |s| s.match(/\A\s*\z/) }.
map { |p| p.split('=').map{|esc| CGI.unescape(esc)} }.
reject { |kv| kv[0] == 'oauth_signature'}
end
......
......@@ -146,7 +146,7 @@ module OAuth::RequestProxy
if uri = request.env['REQUEST_URI']
uri.split('?', 2)[1].nil?
else
request.query_string.blank?
request.query_string.match(/\A\s*\z/)
end
end
......
......@@ -26,11 +26,11 @@ module OAuth
# construct an authorization url
def build_authorize_url(base_url, params)
uri = URI.parse(base_url.to_s)
if(!uri.query.blank? && !params.empty?)
uri.query += "&"
end
queries = {}
queries = Hash[URI.decode_www_form(uri.query)] if uri.query
# TODO doesn't handle array values correctly
uri.query = params.map { |k,v| [k, CGI.escape(v)] * "=" } * "&"
queries.merge!(params) if params
uri.query = URI.encode_www_form(queries) if !queries.empty?
uri.to_s
end
end
......
module OAuth
VERSION = "0.5.0"
VERSION = "0.5.1"
end
......@@ -2,20 +2,21 @@
# This file has been automatically generated by gem2tgz #
#########################################################
# -*- encoding: utf-8 -*-
# stub: oauth 0.5.0 ruby lib
# stub: oauth 0.5.1 ruby lib
Gem::Specification.new do |s|
s.name = "oauth"
s.version = "0.5.0"
s.version = "0.5.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons", "Matt Sanford", "Aaron Quint"]
s.date = "2016-02-20"
s.date = "2016-02-29"
s.email = "oauth-ruby@googlegroupspec.com"
s.executables = ["oauth"]
s.extra_rdoc_files = ["LICENSE", "README.rdoc", "TODO"]
s.files = ["LICENSE", "README.rdoc", "TODO", "bin/oauth", "lib/oauth.rb", "lib/oauth/cli.rb", "lib/oauth/client.rb", "lib/oauth/client/action_controller_request.rb", "lib/oauth/client/em_http.rb", "lib/oauth/client/helper.rb", "lib/oauth/client/net_http.rb", "lib/oauth/consumer.rb", "lib/oauth/core_ext.rb", "lib/oauth/errors.rb", "lib/oauth/errors/error.rb", "lib/oauth/errors/problem.rb", "lib/oauth/errors/unauthorized.rb", "lib/oauth/helper.rb", "lib/oauth/oauth.rb", "lib/oauth/oauth_test_helper.rb", "lib/oauth/request_proxy.rb", "lib/oauth/request_proxy/action_controller_request.rb", "lib/oauth/request_proxy/base.rb", "lib/oauth/request_proxy/curb_request.rb", "lib/oauth/request_proxy/em_http_request.rb", "lib/oauth/request_proxy/jabber_request.rb", "lib/oauth/request_proxy/mock_request.rb", "lib/oauth/request_proxy/net_http.rb", "lib/oauth/request_proxy/rack_request.rb", "lib/oauth/request_proxy/rest_client_request.rb", "lib/oauth/request_proxy/typhoeus_request.rb", "lib/oauth/server.rb", "lib/oauth/signature.rb", "lib/oauth/signature/base.rb", "lib/oauth/signature/hmac/sha1.rb", "lib/oauth/signature/plaintext.rb", "lib/oauth/signature/rsa/sha1.rb", "lib/oauth/token.rb", "lib/oauth/tokens/access_token.rb", "lib/oauth/tokens/consumer_token.rb", "lib/oauth/tokens/request_token.rb", "lib/oauth/tokens/server_token.rb", "lib/oauth/tokens/token.rb", "lib/oauth/version.rb", "test/cases/oauth_case.rb", "test/cases/spec/1_0-final/test_construct_request_url.rb", "test/cases/spec/1_0-final/test_normalize_request_parameters.rb", "test/cases/spec/1_0-final/test_parameter_encodings.rb", "test/cases/spec/1_0-final/test_signature_base_strings.rb", "test/integration/consumer_test.rb", "test/test_access_token.rb", "test/test_action_controller_request_proxy.rb", "test/test_consumer.rb", "test/test_curb_request_proxy.rb", "test/test_em_http_client.rb", "test/test_em_http_request_proxy.rb", "test/test_helper.rb", "test/test_hmac_sha1.rb", "test/test_net_http_client.rb", "test/test_net_http_request_proxy.rb", "test/test_oauth_helper.rb", "test/test_rack_request_proxy.rb", "test/test_request_token.rb", "test/test_rest_client_request_proxy.rb", "test/test_rsa_sha1.rb", "test/test_server.rb", "test/test_signature.rb", "test/test_signature_base.rb", "test/test_signature_hmac_sha1.rb", "test/test_signature_plain_text.rb", "test/test_token.rb", "test/test_typhoeus_request_proxy.rb"]
s.licenses = ["MIT"]
s.rubygems_version = "2.5.1"
s.summary = "OAuth Core Ruby implementation"
s.test_files = ["test/cases/oauth_case.rb", "test/cases/spec/1_0-final/test_construct_request_url.rb", "test/cases/spec/1_0-final/test_normalize_request_parameters.rb", "test/cases/spec/1_0-final/test_parameter_encodings.rb", "test/cases/spec/1_0-final/test_signature_base_strings.rb", "test/integration/consumer_test.rb", "test/test_access_token.rb", "test/test_action_controller_request_proxy.rb", "test/test_consumer.rb", "test/test_curb_request_proxy.rb", "test/test_em_http_client.rb", "test/test_em_http_request_proxy.rb", "test/test_helper.rb", "test/test_hmac_sha1.rb", "test/test_net_http_client.rb", "test/test_net_http_request_proxy.rb", "test/test_oauth_helper.rb", "test/test_rack_request_proxy.rb", "test/test_request_token.rb", "test/test_rest_client_request_proxy.rb", "test/test_rsa_sha1.rb", "test/test_server.rb", "test/test_signature.rb", "test/test_signature_base.rb", "test/test_signature_hmac_sha1.rb", "test/test_signature_plain_text.rb", "test/test_token.rb", "test/test_typhoeus_request_proxy.rb"]
......@@ -26,26 +27,24 @@ Gem::Specification.new do |s|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q<actionpack>, [">= 4.0.2"])
s.add_development_dependency(%q<byebug>, [">= 0"])
s.add_development_dependency(%q<curb>, ["= 0.7.16"])
s.add_development_dependency(%q<curb>, [">= 0"])
s.add_development_dependency(%q<em-http-request>, ["= 0.2.11"])
s.add_development_dependency(%q<iconv>, ["~> 1.0.3"])
s.add_development_dependency(%q<jeweler>, [">= 0"])
s.add_development_dependency(%q<iconv>, [">= 0"])
s.add_development_dependency(%q<minitest>, [">= 0"])
s.add_development_dependency(%q<mocha>, [">= 0.9.12"])
s.add_development_dependency(%q<rack>, ["~> 1.6.1"])
s.add_development_dependency(%q<rack>, [">= 0"])
s.add_development_dependency(%q<rack-test>, [">= 0"])
s.add_development_dependency(%q<rake>, [">= 0"])
s.add_development_dependency(%q<typhoeus>, [">= 0.1.13"])
else
s.add_dependency(%q<actionpack>, [">= 4.0.2"])
s.add_dependency(%q<byebug>, [">= 0"])
s.add_dependency(%q<curb>, ["= 0.7.16"])
s.add_dependency(%q<curb>, [">= 0"])
s.add_dependency(%q<em-http-request>, ["= 0.2.11"])
s.add_dependency(%q<iconv>, ["~> 1.0.3"])
s.add_dependency(%q<jeweler>, [">= 0"])
s.add_dependency(%q<iconv>, [">= 0"])
s.add_dependency(%q<minitest>, [">= 0"])
s.add_dependency(%q<mocha>, [">= 0.9.12"])
s.add_dependency(%q<rack>, ["~> 1.6.1"])
s.add_dependency(%q<rack>, [">= 0"])
s.add_dependency(%q<rack-test>, [">= 0"])
s.add_dependency(%q<rake>, [">= 0"])
s.add_dependency(%q<typhoeus>, [">= 0.1.13"])
......@@ -53,13 +52,12 @@ Gem::Specification.new do |s|
else
s.add_dependency(%q<actionpack>, [">= 4.0.2"])
s.add_dependency(%q<byebug>, [">= 0"])
s.add_dependency(%q<curb>, ["= 0.7.16"])
s.add_dependency(%q<curb>, [">= 0"])
s.add_dependency(%q<em-http-request>, ["= 0.2.11"])
s.add_dependency(%q<iconv>, ["~> 1.0.3"])
s.add_dependency(%q<jeweler>, [">= 0"])
s.add_dependency(%q<iconv>, [">= 0"])
s.add_dependency(%q<minitest>, [">= 0"])
s.add_dependency(%q<mocha>, [">= 0.9.12"])
s.add_dependency(%q<rack>, ["~> 1.6.1"])
s.add_dependency(%q<rack>, [">= 0"])
s.add_dependency(%q<rack-test>, [">= 0"])
s.add_dependency(%q<rake>, [">= 0"])
s.add_dependency(%q<typhoeus>, [">= 0.1.13"])
......
......@@ -27,13 +27,13 @@ require File.expand_path('../../../oauth_case', __FILE__)
class NormalizeRequestParametersTest < OAuthCase
def test_parameters_for_signature
params={'a'=>1, 'c'=>'hi there', 'f'=>'25', 'f'=>'50', 'f'=>'a', 'z'=>'p', 'z'=>'t'}
params={"a"=>1, "c"=>"hi there", "f"=>"a", "z"=>"t"}
assert_equal params,request(params).parameters_for_signature
end
def test_parameters_for_signature_removes_oauth_signature
params={'a'=>1, 'c'=>'hi there', 'f'=>'25', 'f'=>'50', 'f'=>'a', 'z'=>'p', 'z'=>'t'}
params={"a"=>1, "c"=>"hi there", "f"=>"a", "z"=>"t"}
assert_equal params,request(params.merge({'oauth_signature'=>'blalbla'})).parameters_for_signature
end
......
......@@ -291,6 +291,10 @@ class NetHTTPClientTest < Minitest::Test
protected
def assert_no_match exp, act, msg = "Expected #{act.inspect} to not match #{exp.inspect}"
assert act !~ exp, msg
end
def request_parameters_to_s
@request_parameters.map { |k,v| "#{k}=#{v}" }.join("&")
end
......
......@@ -3,9 +3,9 @@ require File.expand_path('../test_helper', __FILE__)
begin
require 'oauth/request_proxy/rest_client_request'
require 'rest-client'
class RestlClientRequestProxyTest < Test::Unit::TestCase
class RestlClientRequestProxyTest < Minitest::Test
def test_that_proxy_simple_get_request_works
request = ::RestClient::Request.new(method: :get, url: "http://example.com/test?key=value")
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value'})
......@@ -15,7 +15,7 @@ begin
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_with_arguments
request = ::RestClient::Request.new(method: :post, url: "http://example.com/test")
params = {'key' => 'value'}
......@@ -26,7 +26,7 @@ begin
assert_equal 'http://example.com/test', request_proxy.normalized_uri
assert_equal 'POST', request_proxy.method
end
def test_that_proxy_simple_post_request_works_with_form_data
request = ::RestClient::Request.new(method: :post, url: "http://example.com/test",
payload: {'key' => 'value'},
......@@ -38,7 +38,7 @@ begin
assert_equal 'http://example.com/test', request_proxy.normalized_uri
assert_equal 'POST', request_proxy.method
end
def test_that_proxy_simple_put_request_works_with_arguments
request = ::RestClient::Request.new(method: :put, url: "http://example.com/test")
params = {'key' => 'value'}
......@@ -49,7 +49,7 @@ begin
assert_equal 'http://example.com/test', request_proxy.normalized_uri
assert_equal 'PUT', request_proxy.method
end
def test_that_proxy_simple_put_request_works_with_form_data
request = ::RestClient::Request.new(method: :put, url: "http://example.com/test",
payload: {'key' => 'value'},
......@@ -61,7 +61,7 @@ begin
assert_equal 'http://example.com/test', request_proxy.normalized_uri
assert_equal 'PUT', request_proxy.method
end
def test_that_proxy_post_request_works_with_mixed_parameter_sources
request = ::RestClient::Request.new(url: 'http://example.com/test?key=value',
method: :post,
......@@ -74,8 +74,8 @@ begin
assert_equal 'http://example.com/test', request_proxy.normalized_uri
assert_equal 'POST', request_proxy.method
end
end
rescue LoadError => e
warn "! problem loading rest-client, skipping these tests: #{e}"
end
\ No newline at end of file
end
require File.expand_path('../test_helper', __FILE__)
require 'oauth/signature/hmac/sha1'
class SignatureHMACSHA1Test < Test::Unit::TestCase
class SignatureHMACSHA1Test < Minitest::Test
def test_that_verify_returns_true_when_the_request_signature_is_right
request = OAuth::RequestProxy::MockRequest.new(
'method' => 'POST',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment