Commit c82e8133 authored by Michael Moll's avatar Michael Moll

New upstream version 0.5.4

parent b3090193
......@@ -5,8 +5,6 @@ rvm:
- "2.4.0"
- "2.3"
- "2.2"
- "2.1"
- "2.0"
addons:
code_climate:
......
=== CURRENT
=== 0.5.4 2017-12-08
* Fixes UnknownRequestType on Rails 5.1 for ActionDispatch::Request (xprazak2)
* Various cleanups (charliesome)
=== 0.5.3 2017-05-24
......
......@@ -51,6 +51,7 @@ When user returns create an access_token
Now that you have an access token, you can use Typhoeus to interact with the OAuth provider if you choose.
require 'typhoeus'
require 'oauth/request_proxy/typhoeus_request'
oauth_params = {:consumer => oauth_consumer, :token => access_token}
hydra = Typhoeus::Hydra.new
......
......@@ -4,7 +4,6 @@ $LOAD_PATH << root unless $LOAD_PATH.include?(root)
require 'oauth/version'
require 'oauth/oauth'
require 'oauth/core_ext'
require 'oauth/client/helper'
require 'oauth/signature/hmac/sha1'
......
......@@ -131,7 +131,7 @@ class OAuth::CLI
options[:method] = v
end
opts.on("--nonce NONCE", "Specifies the none to use.") do |v|
opts.on("--nonce NONCE", "Specifies the nonce to use.") do |v|
options[:oauth_nonce] = v
end
......
if defined? ActionDispatch
require 'oauth/request_proxy/rack_request'
require 'oauth/request_proxy/action_dispatch_request'
require 'action_dispatch/testing/test_process'
else
require 'oauth/request_proxy/action_controller_request'
......
# these are to backport methods from 1.8.7/1.9.1 to 1.8.6
class Object
unless method_defined?(:tap)
def tap
yield self
self
end
end
end
class String
unless method_defined?(:bytesize)
def bytesize
self.size
end
end
unless method_defined?(:bytes)
def bytes
require 'enumerator'
Enumerable::Enumerator.new(self, :each_byte)
end
end
end
# TODO: Work around URI.escape obsolete method
#
# 21/May/2016 - We are silencing a warning introduced in 2009
# https://github.com/ruby/ruby/commit/238b979f1789f95262a267d8df6239806f2859cc
#
# The only clear alternative to this problem is to invoke CGI.escape instead
# but that one does not take a secondary argument so we can pass OAuth::RESERVED_CHARACTERS
# As of today, ignoring this secondary argument would introduce 44 errors on our tests
# 181 runs, 511 assertions, 44 failures, 0 errors, 0 skips
#
# If you have a proper way to work around this so we don't need to override ruby core code
# Please send us a Pull Request
module URI
module Escape
def escape(*arg)
DEFAULT_PARSER.escape(*arg)
end
def unescape(*arg)
DEFAULT_PARSER.unescape(*arg)
end
end
end
......@@ -15,11 +15,11 @@ module OAuth
end
def _escape(string)
URI.escape(string, OAuth::RESERVED_CHARACTERS)
URI::DEFAULT_PARSER.escape(string, OAuth::RESERVED_CHARACTERS)
end
def unescape(value)
URI.unescape(value.gsub('+', '%2B'))
URI::DEFAULT_PARSER.unescape(value.gsub('+', '%2B'))
end
# Generate a random key of up to +size+ bytes. The value returned is Base64 encoded with non-word
......
......@@ -23,7 +23,7 @@ then # rails 3.x
ActionDispatch::Request::HTTP_METHOD_LOOKUP["patch"] = :patch
end
else # rails 4.x - already has patch
else # rails 4.x and later - already has patch
require 'action_dispatch/http/request'
end
......
require 'oauth/request_proxy/rack_request'
module OAuth::RequestProxy
class ActionDispatchRequest < OAuth::RequestProxy::RackRequest
proxies ActionDispatch::Request
end
end
module OAuth
VERSION = "0.5.3"
VERSION = "0.5.4"
end
......@@ -28,9 +28,9 @@ Gem::Specification.new do |spec|
spec.add_development_dependency("rake")
spec.add_development_dependency("minitest")
spec.add_development_dependency("byebug")
spec.add_development_dependency("actionpack", "~> 4.0")
spec.add_development_dependency("actionpack", ">= 5.0")
spec.add_development_dependency("iconv")
spec.add_development_dependency("rack", "~> 1.0")
spec.add_development_dependency("rack", "~> 2.0")
spec.add_development_dependency("rack-test")
spec.add_development_dependency("mocha", ">= 0.9.12")
spec.add_development_dependency("typhoeus", ">= 0.1.13")
......
......@@ -5,7 +5,7 @@ require 'oauth/request_proxy/action_controller_request'
class ActionControllerRequestProxyTest < Minitest::Test
def request_proxy(request_method = :get, uri_params = {}, body_params = {})
request = ActionDispatch::TestRequest.new
request = ActionDispatch::TestRequest.create
request.request_uri = '/'
case request_method
......
require File.expand_path('../../test_helper', __FILE__)
require 'oauth/request_proxy/action_dispatch_request'
class ActionRequestProxyTest < Minitest::Test
def test_that_proxy_simple_get_request_works
request = ActionDispatch::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 = ActionDispatch::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 = ActionDispatch::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
......@@ -280,7 +280,7 @@ Usage: oauth <command> [ARGS]
options for signing and querying
--method METHOD Specifies the method (e.g. GET) to use when signing.
--nonce NONCE Specifies the none to use.
--nonce NONCE Specifies the nonce to use.
--parameters PARAMS Specifies the parameters to use when signing.
--signature-method METHOD Specifies the signature method to use; defaults to HMAC-SHA1.
--token TOKEN Specifies the token to use.
......
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