motionbox-oauth 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +46 -0
- data/HISTORY +160 -0
- data/LICENSE +20 -0
- data/README.rdoc +75 -0
- data/Rakefile +37 -0
- data/TODO +32 -0
- data/bin/oauth +5 -0
- data/examples/yql.rb +44 -0
- data/lib/digest/hmac.rb +104 -0
- data/lib/oauth.rb +13 -0
- data/lib/oauth/cli.rb +378 -0
- data/lib/oauth/client.rb +4 -0
- data/lib/oauth/client/action_controller_request.rb +65 -0
- data/lib/oauth/client/em_http.rb +124 -0
- data/lib/oauth/client/helper.rb +91 -0
- data/lib/oauth/client/net_http.rb +120 -0
- data/lib/oauth/consumer.rb +382 -0
- data/lib/oauth/core_ext.rb +31 -0
- data/lib/oauth/errors.rb +3 -0
- data/lib/oauth/errors/error.rb +4 -0
- data/lib/oauth/errors/problem.rb +14 -0
- data/lib/oauth/errors/unauthorized.rb +12 -0
- data/lib/oauth/helper.rb +88 -0
- data/lib/oauth/oauth.rb +13 -0
- data/lib/oauth/oauth_test_helper.rb +25 -0
- data/lib/oauth/request_proxy.rb +24 -0
- data/lib/oauth/request_proxy/action_controller_request.rb +62 -0
- data/lib/oauth/request_proxy/base.rb +174 -0
- data/lib/oauth/request_proxy/curb_request.rb +55 -0
- data/lib/oauth/request_proxy/em_http_request.rb +74 -0
- data/lib/oauth/request_proxy/jabber_request.rb +41 -0
- data/lib/oauth/request_proxy/mock_request.rb +44 -0
- data/lib/oauth/request_proxy/net_http.rb +72 -0
- data/lib/oauth/request_proxy/rack_request.rb +44 -0
- data/lib/oauth/request_proxy/typhoeus_request.rb +53 -0
- data/lib/oauth/server.rb +66 -0
- data/lib/oauth/signature.rb +45 -0
- data/lib/oauth/signature/base.rb +110 -0
- data/lib/oauth/signature/hmac/base.rb +15 -0
- data/lib/oauth/signature/hmac/md5.rb +8 -0
- data/lib/oauth/signature/hmac/rmd160.rb +8 -0
- data/lib/oauth/signature/hmac/sha1.rb +9 -0
- data/lib/oauth/signature/hmac/sha2.rb +8 -0
- data/lib/oauth/signature/md5.rb +13 -0
- data/lib/oauth/signature/plaintext.rb +23 -0
- data/lib/oauth/signature/rsa/sha1.rb +46 -0
- data/lib/oauth/signature/sha1.rb +13 -0
- data/lib/oauth/token.rb +7 -0
- data/lib/oauth/tokens/access_token.rb +71 -0
- data/lib/oauth/tokens/consumer_token.rb +33 -0
- data/lib/oauth/tokens/request_token.rb +32 -0
- data/lib/oauth/tokens/server_token.rb +9 -0
- data/lib/oauth/tokens/token.rb +17 -0
- data/oauth.gemspec +150 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/cases/oauth_case.rb +19 -0
- data/test/cases/spec/1_0-final/test_construct_request_url.rb +62 -0
- data/test/cases/spec/1_0-final/test_normalize_request_parameters.rb +88 -0
- data/test/cases/spec/1_0-final/test_parameter_encodings.rb +86 -0
- data/test/cases/spec/1_0-final/test_signature_base_strings.rb +77 -0
- data/test/integration/consumer_test.rb +307 -0
- data/test/keys/rsa.cert +11 -0
- data/test/keys/rsa.pem +16 -0
- data/test/test_access_token.rb +26 -0
- data/test/test_action_controller_request_proxy.rb +133 -0
- data/test/test_consumer.rb +171 -0
- data/test/test_curb_request_proxy.rb +77 -0
- data/test/test_em_http_client.rb +80 -0
- data/test/test_em_http_request_proxy.rb +115 -0
- data/test/test_helper.rb +26 -0
- data/test/test_hmac_sha1.rb +20 -0
- data/test/test_net_http_client.rb +280 -0
- data/test/test_net_http_request_proxy.rb +72 -0
- data/test/test_oauth_helper.rb +71 -0
- data/test/test_rack_request_proxy.rb +40 -0
- data/test/test_request_token.rb +51 -0
- data/test/test_rsa_sha1.rb +59 -0
- data/test/test_server.rb +40 -0
- data/test/test_signature.rb +22 -0
- data/test/test_signature_base.rb +32 -0
- data/test/test_signature_plain_text.rb +31 -0
- data/test/test_token.rb +14 -0
- data/test/test_typhoeus_request_proxy.rb +80 -0
- metadata +284 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
|
3
|
+
class StubbedToken < OAuth::RequestToken
|
4
|
+
define_method :build_authorize_url_promoted do |root_domain, params|
|
5
|
+
build_authorize_url root_domain, params
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class TestRequestToken < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
# setup a fake req. token. mocking Consumer would be more appropriate...
|
12
|
+
@request_token = OAuth::RequestToken.new(
|
13
|
+
OAuth::Consumer.new("key", "secret", {}),
|
14
|
+
"key",
|
15
|
+
"secret"
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_request_token_builds_authorize_url_connectly_with_additional_params
|
20
|
+
auth_url = @request_token.authorize_url({:oauth_callback => "github.com"})
|
21
|
+
assert_not_nil auth_url
|
22
|
+
assert_match(/oauth_token/, auth_url)
|
23
|
+
assert_match(/oauth_callback/, auth_url)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_request_token_builds_authorize_url_connectly_with_no_or_nil_params
|
27
|
+
# we should only have 1 key in the url returned if we didn't pass anything.
|
28
|
+
# this is the only required param to authenticate the client.
|
29
|
+
auth_url = @request_token.authorize_url(nil)
|
30
|
+
assert_not_nil auth_url
|
31
|
+
assert_match(/\?oauth_token=/, auth_url)
|
32
|
+
|
33
|
+
auth_url = @request_token.authorize_url
|
34
|
+
assert_not_nil auth_url
|
35
|
+
assert_match(/\?oauth_token=/, auth_url)
|
36
|
+
end
|
37
|
+
|
38
|
+
#TODO: mock out the Consumer to test the Consumer/AccessToken interaction.
|
39
|
+
def test_get_access_token
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_build_authorize_url
|
43
|
+
@stubbed_token = StubbedToken.new(nil, nil, nil)
|
44
|
+
assert_respond_to @stubbed_token, :build_authorize_url_promoted
|
45
|
+
url = @stubbed_token.build_authorize_url_promoted(
|
46
|
+
"http://github.com/oauth/authorize",
|
47
|
+
{:foo => "bar bar"})
|
48
|
+
assert url
|
49
|
+
assert_equal "http://github.com/oauth/authorize?foo=bar+bar", url
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'oauth/consumer'
|
3
|
+
require 'oauth/signature/rsa/sha1'
|
4
|
+
|
5
|
+
class TestSignatureRsaSha1 < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@request = Net::HTTP::Get.new('/photos?file=vacaction.jpg&size=original&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_timestamp=1196666512&oauth_nonce=13917289812797014437&oauth_signature_method=RSA-SHA1')
|
9
|
+
|
10
|
+
@consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03', OpenSSL::PKey::RSA.new(IO.read(File.dirname(__FILE__) + "/keys/rsa.pem")))
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_that_rsa_sha1_implements_rsa_sha1
|
15
|
+
assert OAuth::Signature.available_methods.include?('rsa-sha1')
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_that_get_request_from_oauth_test_cases_produces_matching_signature_base_string
|
19
|
+
sbs = OAuth::Signature.signature_base_string(@request, { :consumer => @consumer,
|
20
|
+
:uri => 'http://photos.example.net/photos' } )
|
21
|
+
|
22
|
+
assert_equal 'GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacaction.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3D13917289812797014437%26oauth_signature_method%3DRSA-SHA1%26oauth_timestamp%3D1196666512%26oauth_version%3D1.0%26size%3Doriginal', sbs
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_that_get_request_from_oauth_test_cases_produces_matching_signature
|
26
|
+
signature = OAuth::Signature.sign(@request, { :consumer => @consumer,
|
27
|
+
:uri => 'http://photos.example.net/photos' } )
|
28
|
+
|
29
|
+
assert_equal 'jvTp/wX1TYtByB1m+Pbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2/9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW//e+RinhejgCuzoH26dyF8iY2ZZ/5D1ilgeijhV/vBka5twt399mXwaYdCwFYE=', signature
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_that_get_request_from_oauth_test_cases_produces_matching_signature_using_private_key_file
|
34
|
+
@consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03',nil)
|
35
|
+
|
36
|
+
signature = OAuth::Signature.sign(@request, { :consumer => @consumer,
|
37
|
+
:private_key_file=>File.dirname(__FILE__) + "/keys/rsa.pem",
|
38
|
+
:uri => 'http://photos.example.net/photos' } )
|
39
|
+
|
40
|
+
assert_equal 'jvTp/wX1TYtByB1m+Pbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2/9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW//e+RinhejgCuzoH26dyF8iY2ZZ/5D1ilgeijhV/vBka5twt399mXwaYdCwFYE=', signature
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_that_get_request_from_oauth_test_cases_verifies_signature
|
44
|
+
@request = Net::HTTP::Get.new('/photos?oauth_signature_method=RSA-SHA1&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_timestamp=1196666512&oauth_nonce=13917289812797014437&file=vacaction.jpg&size=original&oauth_signature=jvTp%2FwX1TYtByB1m%2BPbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2%2F9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW%2F%2Fe%2BRinhejgCuzoH26dyF8iY2ZZ%2F5D1ilgeijhV%2FvBka5twt399mXwaYdCwFYE%3D')
|
45
|
+
@consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03',OpenSSL::X509::Certificate.new(IO.read(File.dirname(__FILE__) + "/keys/rsa.cert")))
|
46
|
+
|
47
|
+
assert OAuth::Signature.verify(@request, { :consumer => @consumer,
|
48
|
+
:uri => 'http://photos.example.net/photos' } )
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_that_get_request_from_oauth_test_cases_verifies_signature_with_pem
|
53
|
+
@request = Net::HTTP::Get.new('/photos?oauth_signature_method=RSA-SHA1&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_timestamp=1196666512&oauth_nonce=13917289812797014437&file=vacaction.jpg&size=original&oauth_signature=jvTp%2FwX1TYtByB1m%2BPbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2%2F9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW%2F%2Fe%2BRinhejgCuzoH26dyF8iY2ZZ%2F5D1ilgeijhV%2FvBka5twt399mXwaYdCwFYE%3D')
|
54
|
+
assert OAuth::Signature.verify(@request, { :consumer => @consumer,
|
55
|
+
:uri => 'http://photos.example.net/photos' } )
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
data/test/test_server.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'oauth/server'
|
3
|
+
class ServerTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@server=OAuth::Server.new "http://test.com"
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_default_paths
|
9
|
+
assert_equal "/oauth/request_token",@server.request_token_path
|
10
|
+
assert_equal "/oauth/authorize",@server.authorize_path
|
11
|
+
assert_equal "/oauth/access_token",@server.access_token_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_default_urls
|
15
|
+
assert_equal "http://test.com/oauth/request_token",@server.request_token_url
|
16
|
+
assert_equal "http://test.com/oauth/authorize",@server.authorize_url
|
17
|
+
assert_equal "http://test.com/oauth/access_token",@server.access_token_url
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_generate_consumer_credentials
|
21
|
+
consumer=@server.generate_consumer_credentials
|
22
|
+
assert_not_nil consumer.key
|
23
|
+
assert_not_nil consumer.secret
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_create_consumer
|
27
|
+
@consumer=@server.create_consumer
|
28
|
+
assert_not_nil @consumer
|
29
|
+
assert_not_nil @consumer.key
|
30
|
+
assert_not_nil @consumer.secret
|
31
|
+
assert_equal "http://test.com",@consumer.site
|
32
|
+
assert_equal "/oauth/request_token",@consumer.request_token_path
|
33
|
+
assert_equal "/oauth/authorize",@consumer.authorize_path
|
34
|
+
assert_equal "/oauth/access_token",@consumer.access_token_path
|
35
|
+
assert_equal "http://test.com/oauth/request_token",@consumer.request_token_url
|
36
|
+
assert_equal "http://test.com/oauth/authorize",@consumer.authorize_url
|
37
|
+
assert_equal "http://test.com/oauth/access_token",@consumer.access_token_url
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path('../test_helper', __FILE__)
|
4
|
+
|
5
|
+
class TestOauth < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_parameter_escaping_kcode_invariant
|
8
|
+
ruby19 = RUBY_VERSION =~ /^1\.9/
|
9
|
+
old = $KCODE if !ruby19
|
10
|
+
begin
|
11
|
+
%w(n N e E s S u U).each do |kcode|
|
12
|
+
$KCODE = kcode if !ruby19
|
13
|
+
assert_equal '%E3%81%82', OAuth::Helper.escape('あ'),
|
14
|
+
"Failed to correctly escape Japanese under $KCODE = #{kcode}"
|
15
|
+
assert_equal '%C3%A9', OAuth::Helper.escape('é'),
|
16
|
+
"Failed to correctly escape e+acute under $KCODE = #{kcode}"
|
17
|
+
end
|
18
|
+
ensure
|
19
|
+
$KCODE = old if !ruby19
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'oauth/signature/base'
|
3
|
+
require 'net/http'
|
4
|
+
class SignatureBaseTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_that_initialize_requires_one_request_argument
|
7
|
+
assert_raises ArgumentError do
|
8
|
+
OAuth::Signature::Base.new()
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_that_initialize_requires_a_valid_request_argument
|
13
|
+
request = nil
|
14
|
+
assert_raises TypeError do
|
15
|
+
OAuth::Signature::Base.new(request) { |token|
|
16
|
+
# just a stub
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_that_initialize_succeeds_when_the_request_proxy_is_valid
|
22
|
+
# this isn't quite valid, but it will do.
|
23
|
+
raw_request = Net::HTTP::Get.new('/test')
|
24
|
+
request = OAuth::RequestProxy.proxy(raw_request)
|
25
|
+
assert_nothing_raised do
|
26
|
+
OAuth::Signature::Base.new(request) { |token|
|
27
|
+
# just a stub
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'oauth/signature/plaintext'
|
3
|
+
|
4
|
+
class TestSignaturePlaintext < Test::Unit::TestCase
|
5
|
+
def test_that_plaintext_implements_plaintext
|
6
|
+
assert OAuth::Signature.available_methods.include?('plaintext')
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_that_get_request_from_oauth_test_cases_produces_matching_signature
|
10
|
+
request = Net::HTTP::Get.new('/photos?file=vacation.jpg&size=original&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_token=nnch734d00sl2jdk&oauth_signature=kd94hf93k423kf44%26&oauth_timestamp=1191242096&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=PLAINTEXT')
|
11
|
+
|
12
|
+
consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03','kd94hf93k423kf44')
|
13
|
+
token = OAuth::Token.new('nnch734d00sl2jdk', nil)
|
14
|
+
|
15
|
+
assert OAuth::Signature.verify(request, { :consumer => consumer,
|
16
|
+
:token => token,
|
17
|
+
:uri => 'http://photos.example.net/photos' } )
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_that_get_request_from_oauth_test_cases_produces_matching_signature_part_two
|
21
|
+
request = Net::HTTP::Get.new('/photos?file=vacation.jpg&size=original&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_token=nnch734d00sl2jdk&oauth_signature=kd94hf93k423kf44%26pfkkdhi9sl3r4s00&oauth_timestamp=1191242096&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=PLAINTEXT')
|
22
|
+
|
23
|
+
consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03','kd94hf93k423kf44')
|
24
|
+
token = OAuth::Token.new('nnch734d00sl2jdk', 'pfkkdhi9sl3r4s00')
|
25
|
+
|
26
|
+
assert OAuth::Signature.verify(request, { :consumer => consumer,
|
27
|
+
:token => token,
|
28
|
+
:uri => 'http://photos.example.net/photos' } )
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/test/test_token.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'oauth/token'
|
3
|
+
|
4
|
+
class TestToken < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_token_constructor_produces_valid_token
|
10
|
+
token = OAuth::Token.new('xyz', '123')
|
11
|
+
assert_equal 'xyz', token.token
|
12
|
+
assert_equal '123', token.secret
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
|
3
|
+
begin
|
4
|
+
|
5
|
+
require 'oauth/request_proxy/typhoeus_request'
|
6
|
+
require 'typhoeus'
|
7
|
+
|
8
|
+
class TyphoeusRequestProxyTest < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def test_that_proxy_simple_get_request_works
|
11
|
+
request = ::Typhoeus::Request.new('/test?key=value')
|
12
|
+
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value'})
|
13
|
+
|
14
|
+
expected_parameters = {'key' => ['value']}
|
15
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
16
|
+
assert_equal 'http://example.com/test', request_proxy.normalized_uri
|
17
|
+
assert_equal 'GET', request_proxy.method
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_that_proxy_simple_post_request_works_with_arguments
|
21
|
+
request = Typhoeus::Request.new('/test', :method => :post)
|
22
|
+
params = {'key' => 'value'}
|
23
|
+
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params})
|
24
|
+
|
25
|
+
expected_parameters = {'key' => 'value'}
|
26
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
27
|
+
assert_equal 'http://example.com/test', request_proxy.normalized_uri
|
28
|
+
assert_equal 'POST', request_proxy.method
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_that_proxy_simple_post_request_works_with_form_data
|
32
|
+
request = Typhoeus::Request.new('/test', :method => :post,
|
33
|
+
:params => {'key' => 'value'},
|
34
|
+
:headers => {'Content-Type' => 'application/x-www-form-urlencoded'})
|
35
|
+
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'})
|
36
|
+
|
37
|
+
expected_parameters = {'key' => 'value'}
|
38
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
39
|
+
assert_equal 'http://example.com/test', request_proxy.normalized_uri
|
40
|
+
assert_equal 'POST', request_proxy.method
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_that_proxy_simple_put_request_works_with_arguments
|
44
|
+
request = Typhoeus::Request.new('/test', :method => :put)
|
45
|
+
params = {'key' => 'value'}
|
46
|
+
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params})
|
47
|
+
|
48
|
+
expected_parameters = {'key' => 'value'}
|
49
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
50
|
+
assert_equal 'http://example.com/test', request_proxy.normalized_uri
|
51
|
+
assert_equal 'PUT', request_proxy.method
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_that_proxy_simple_put_request_works_with_form_data
|
55
|
+
request = Typhoeus::Request.new('/test', :method => :put, :params => {'key' => 'value'})
|
56
|
+
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'})
|
57
|
+
|
58
|
+
expected_parameters = {'key' => ['value']}
|
59
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
60
|
+
assert_equal 'http://example.com/test', request_proxy.normalized_uri
|
61
|
+
assert_equal 'PUT', request_proxy.method
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_that_proxy_post_request_works_with_mixed_parameter_sources
|
65
|
+
request = Typhoeus::Request.new('/test?key=value',
|
66
|
+
:method => :post,
|
67
|
+
:params => {'key2' => 'value2'},
|
68
|
+
:headers => {'Content-Type' => 'application/x-www-form-urlencoded'})
|
69
|
+
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value', :parameters => {'key3' => 'value3'}})
|
70
|
+
|
71
|
+
expected_parameters = {'key' => ['value'], 'key2' => 'value2', 'key3' => 'value3'}
|
72
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
73
|
+
assert_equal 'http://example.com/test', request_proxy.normalized_uri
|
74
|
+
assert_equal 'POST', request_proxy.method
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
rescue LoadError => e
|
79
|
+
warn "! problem loading typhoeus, skipping these tests: #{e}"
|
80
|
+
end
|
metadata
ADDED
@@ -0,0 +1,284 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motionbox-oauth
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 5
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 4
|
9
|
+
- 5
|
10
|
+
version: 0.4.5
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Pelle Braendgaard
|
14
|
+
- Blaine Cook
|
15
|
+
- Larry Halff
|
16
|
+
- Jesse Clark
|
17
|
+
- Jon Crosby
|
18
|
+
- Seth Fitzsimmons
|
19
|
+
- Matt Sanford
|
20
|
+
- Aaron Quint
|
21
|
+
autorequire:
|
22
|
+
bindir: bin
|
23
|
+
cert_chain: []
|
24
|
+
|
25
|
+
date: 2011-06-25 00:00:00 Z
|
26
|
+
dependencies:
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
hash: 3
|
36
|
+
segments:
|
37
|
+
- 0
|
38
|
+
version: "0"
|
39
|
+
type: :development
|
40
|
+
version_requirements: *id001
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jeweler
|
43
|
+
prerelease: false
|
44
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
hash: 3
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
version: "0"
|
53
|
+
type: :development
|
54
|
+
version_requirements: *id002
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: actionpack
|
57
|
+
prerelease: false
|
58
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 9
|
64
|
+
segments:
|
65
|
+
- 2
|
66
|
+
- 3
|
67
|
+
- 5
|
68
|
+
version: 2.3.5
|
69
|
+
type: :development
|
70
|
+
version_requirements: *id003
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: rack
|
73
|
+
prerelease: false
|
74
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
hash: 23
|
80
|
+
segments:
|
81
|
+
- 1
|
82
|
+
- 0
|
83
|
+
- 0
|
84
|
+
version: 1.0.0
|
85
|
+
type: :development
|
86
|
+
version_requirements: *id004
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: mocha
|
89
|
+
prerelease: false
|
90
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
hash: 43
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
- 9
|
99
|
+
- 8
|
100
|
+
version: 0.9.8
|
101
|
+
type: :development
|
102
|
+
version_requirements: *id005
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: typhoeus
|
105
|
+
prerelease: false
|
106
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
hash: 1
|
112
|
+
segments:
|
113
|
+
- 0
|
114
|
+
- 1
|
115
|
+
- 13
|
116
|
+
version: 0.1.13
|
117
|
+
type: :development
|
118
|
+
version_requirements: *id006
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: em-http-request
|
121
|
+
prerelease: false
|
122
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
hash: 3
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
- 2
|
131
|
+
- 10
|
132
|
+
version: 0.2.10
|
133
|
+
type: :development
|
134
|
+
version_requirements: *id007
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
name: curb
|
137
|
+
prerelease: false
|
138
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
hash: 103
|
144
|
+
segments:
|
145
|
+
- 0
|
146
|
+
- 6
|
147
|
+
- 6
|
148
|
+
- 0
|
149
|
+
version: 0.6.6.0
|
150
|
+
type: :development
|
151
|
+
version_requirements: *id008
|
152
|
+
description: OAuth Core Ruby implementation
|
153
|
+
email: oauth-ruby@googlegroups.com
|
154
|
+
executables:
|
155
|
+
- oauth
|
156
|
+
extensions: []
|
157
|
+
|
158
|
+
extra_rdoc_files:
|
159
|
+
- LICENSE
|
160
|
+
- README.rdoc
|
161
|
+
- TODO
|
162
|
+
files:
|
163
|
+
- .gemtest
|
164
|
+
- Gemfile
|
165
|
+
- Gemfile.lock
|
166
|
+
- HISTORY
|
167
|
+
- LICENSE
|
168
|
+
- README.rdoc
|
169
|
+
- Rakefile
|
170
|
+
- TODO
|
171
|
+
- bin/oauth
|
172
|
+
- examples/yql.rb
|
173
|
+
- lib/digest/hmac.rb
|
174
|
+
- lib/oauth.rb
|
175
|
+
- lib/oauth/cli.rb
|
176
|
+
- lib/oauth/client.rb
|
177
|
+
- lib/oauth/client/action_controller_request.rb
|
178
|
+
- lib/oauth/client/em_http.rb
|
179
|
+
- lib/oauth/client/helper.rb
|
180
|
+
- lib/oauth/client/net_http.rb
|
181
|
+
- lib/oauth/consumer.rb
|
182
|
+
- lib/oauth/core_ext.rb
|
183
|
+
- lib/oauth/errors.rb
|
184
|
+
- lib/oauth/errors/error.rb
|
185
|
+
- lib/oauth/errors/problem.rb
|
186
|
+
- lib/oauth/errors/unauthorized.rb
|
187
|
+
- lib/oauth/helper.rb
|
188
|
+
- lib/oauth/oauth.rb
|
189
|
+
- lib/oauth/oauth_test_helper.rb
|
190
|
+
- lib/oauth/request_proxy.rb
|
191
|
+
- lib/oauth/request_proxy/action_controller_request.rb
|
192
|
+
- lib/oauth/request_proxy/base.rb
|
193
|
+
- lib/oauth/request_proxy/curb_request.rb
|
194
|
+
- lib/oauth/request_proxy/em_http_request.rb
|
195
|
+
- lib/oauth/request_proxy/jabber_request.rb
|
196
|
+
- lib/oauth/request_proxy/mock_request.rb
|
197
|
+
- lib/oauth/request_proxy/net_http.rb
|
198
|
+
- lib/oauth/request_proxy/rack_request.rb
|
199
|
+
- lib/oauth/request_proxy/typhoeus_request.rb
|
200
|
+
- lib/oauth/server.rb
|
201
|
+
- lib/oauth/signature.rb
|
202
|
+
- lib/oauth/signature/base.rb
|
203
|
+
- lib/oauth/signature/hmac/base.rb
|
204
|
+
- lib/oauth/signature/hmac/md5.rb
|
205
|
+
- lib/oauth/signature/hmac/rmd160.rb
|
206
|
+
- lib/oauth/signature/hmac/sha1.rb
|
207
|
+
- lib/oauth/signature/hmac/sha2.rb
|
208
|
+
- lib/oauth/signature/md5.rb
|
209
|
+
- lib/oauth/signature/plaintext.rb
|
210
|
+
- lib/oauth/signature/rsa/sha1.rb
|
211
|
+
- lib/oauth/signature/sha1.rb
|
212
|
+
- lib/oauth/token.rb
|
213
|
+
- lib/oauth/tokens/access_token.rb
|
214
|
+
- lib/oauth/tokens/consumer_token.rb
|
215
|
+
- lib/oauth/tokens/request_token.rb
|
216
|
+
- lib/oauth/tokens/server_token.rb
|
217
|
+
- lib/oauth/tokens/token.rb
|
218
|
+
- oauth.gemspec
|
219
|
+
- tasks/deployment.rake
|
220
|
+
- tasks/environment.rake
|
221
|
+
- tasks/website.rake
|
222
|
+
- test/cases/oauth_case.rb
|
223
|
+
- test/cases/spec/1_0-final/test_construct_request_url.rb
|
224
|
+
- test/cases/spec/1_0-final/test_normalize_request_parameters.rb
|
225
|
+
- test/cases/spec/1_0-final/test_parameter_encodings.rb
|
226
|
+
- test/cases/spec/1_0-final/test_signature_base_strings.rb
|
227
|
+
- test/integration/consumer_test.rb
|
228
|
+
- test/keys/rsa.cert
|
229
|
+
- test/keys/rsa.pem
|
230
|
+
- test/test_access_token.rb
|
231
|
+
- test/test_action_controller_request_proxy.rb
|
232
|
+
- test/test_consumer.rb
|
233
|
+
- test/test_curb_request_proxy.rb
|
234
|
+
- test/test_em_http_client.rb
|
235
|
+
- test/test_em_http_request_proxy.rb
|
236
|
+
- test/test_helper.rb
|
237
|
+
- test/test_hmac_sha1.rb
|
238
|
+
- test/test_net_http_client.rb
|
239
|
+
- test/test_net_http_request_proxy.rb
|
240
|
+
- test/test_oauth_helper.rb
|
241
|
+
- test/test_rack_request_proxy.rb
|
242
|
+
- test/test_request_token.rb
|
243
|
+
- test/test_rsa_sha1.rb
|
244
|
+
- test/test_server.rb
|
245
|
+
- test/test_signature.rb
|
246
|
+
- test/test_signature_base.rb
|
247
|
+
- test/test_signature_plain_text.rb
|
248
|
+
- test/test_token.rb
|
249
|
+
- test/test_typhoeus_request_proxy.rb
|
250
|
+
homepage:
|
251
|
+
licenses: []
|
252
|
+
|
253
|
+
post_install_message:
|
254
|
+
rdoc_options: []
|
255
|
+
|
256
|
+
require_paths:
|
257
|
+
- lib
|
258
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
259
|
+
none: false
|
260
|
+
requirements:
|
261
|
+
- - ">="
|
262
|
+
- !ruby/object:Gem::Version
|
263
|
+
hash: 3
|
264
|
+
segments:
|
265
|
+
- 0
|
266
|
+
version: "0"
|
267
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
268
|
+
none: false
|
269
|
+
requirements:
|
270
|
+
- - ">="
|
271
|
+
- !ruby/object:Gem::Version
|
272
|
+
hash: 3
|
273
|
+
segments:
|
274
|
+
- 0
|
275
|
+
version: "0"
|
276
|
+
requirements: []
|
277
|
+
|
278
|
+
rubyforge_project: oauth
|
279
|
+
rubygems_version: 1.8.24
|
280
|
+
signing_key:
|
281
|
+
specification_version: 3
|
282
|
+
summary: OAuth Core Ruby implementation
|
283
|
+
test_files: []
|
284
|
+
|