oauth 0.5.0 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of oauth might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.rdoc +13 -2
- data/bin/oauth +8 -2
- data/lib/oauth.rb +2 -2
- data/lib/oauth/cli.rb +37 -359
- data/lib/oauth/cli/authorize_command.rb +71 -0
- data/lib/oauth/cli/base_command.rb +208 -0
- data/lib/oauth/cli/help_command.rb +22 -0
- data/lib/oauth/cli/query_command.rb +25 -0
- data/lib/oauth/cli/sign_command.rb +81 -0
- data/lib/oauth/cli/version_command.rb +7 -0
- data/lib/oauth/client/action_controller_request.rb +1 -1
- data/lib/oauth/client/em_http.rb +0 -1
- data/lib/oauth/client/net_http.rb +0 -1
- data/lib/oauth/consumer.rb +26 -3
- data/lib/oauth/helper.rb +10 -6
- data/lib/oauth/request_proxy/action_controller_request.rb +2 -2
- data/lib/oauth/request_proxy/action_dispatch_request.rb +7 -0
- data/lib/oauth/request_proxy/base.rb +6 -2
- data/lib/oauth/tokens/request_token.rb +4 -4
- data/lib/oauth/version.rb +1 -1
- metadata +82 -90
- data/lib/oauth/core_ext.rb +0 -31
- data/test/cases/oauth_case.rb +0 -19
- data/test/cases/spec/1_0-final/test_construct_request_url.rb +0 -62
- data/test/cases/spec/1_0-final/test_normalize_request_parameters.rb +0 -88
- data/test/cases/spec/1_0-final/test_parameter_encodings.rb +0 -86
- data/test/cases/spec/1_0-final/test_signature_base_strings.rb +0 -77
- data/test/integration/consumer_test.rb +0 -307
- data/test/test_access_token.rb +0 -26
- data/test/test_action_controller_request_proxy.rb +0 -157
- data/test/test_consumer.rb +0 -226
- data/test/test_curb_request_proxy.rb +0 -77
- data/test/test_em_http_client.rb +0 -80
- data/test/test_em_http_request_proxy.rb +0 -115
- data/test/test_helper.rb +0 -33
- data/test/test_hmac_sha1.rb +0 -20
- data/test/test_net_http_client.rb +0 -298
- data/test/test_net_http_request_proxy.rb +0 -72
- data/test/test_oauth_helper.rb +0 -94
- data/test/test_rack_request_proxy.rb +0 -40
- data/test/test_request_token.rb +0 -56
- data/test/test_rest_client_request_proxy.rb +0 -81
- data/test/test_rsa_sha1.rb +0 -59
- data/test/test_server.rb +0 -41
- data/test/test_signature.rb +0 -15
- data/test/test_signature_base.rb +0 -32
- data/test/test_signature_hmac_sha1.rb +0 -40
- data/test/test_signature_plain_text.rb +0 -31
- data/test/test_token.rb +0 -14
- data/test/test_typhoeus_request_proxy.rb +0 -101
data/test/test_signature.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require File.expand_path('../test_helper', __FILE__)
|
4
|
-
|
5
|
-
class TestOauth < Minitest::Test
|
6
|
-
|
7
|
-
def test_parameter_escaping_kcode_invariant
|
8
|
-
%w(n N e E s S u U).each do |kcode|
|
9
|
-
assert_equal '%E3%81%82', OAuth::Helper.escape('あ'),
|
10
|
-
"Failed to correctly escape Japanese under $KCODE = #{kcode}"
|
11
|
-
assert_equal '%C3%A9', OAuth::Helper.escape('é'),
|
12
|
-
"Failed to correctly escape e+acute under $KCODE = #{kcode}"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/test/test_signature_base.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_helper', __FILE__)
|
2
|
-
require 'oauth/signature/base'
|
3
|
-
require 'net/http'
|
4
|
-
|
5
|
-
class SignatureBaseTest < Minitest::Test
|
6
|
-
|
7
|
-
def test_that_initialize_requires_one_request_argument
|
8
|
-
assert_raises ArgumentError do
|
9
|
-
OAuth::Signature::Base.new()
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_that_initialize_requires_a_valid_request_argument
|
14
|
-
request = nil
|
15
|
-
assert_raises TypeError do
|
16
|
-
OAuth::Signature::Base.new(request) { |token|
|
17
|
-
# just a stub
|
18
|
-
}
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_that_initialize_succeeds_when_the_request_proxy_is_valid
|
23
|
-
# this isn't quite valid, but it will do.
|
24
|
-
raw_request = Net::HTTP::Get.new('/test')
|
25
|
-
request = OAuth::RequestProxy.proxy(raw_request)
|
26
|
-
|
27
|
-
OAuth::Signature::Base.new(request) { |token|
|
28
|
-
# just a stub
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_helper', __FILE__)
|
2
|
-
require 'oauth/signature/hmac/sha1'
|
3
|
-
|
4
|
-
class SignatureHMACSHA1Test < Test::Unit::TestCase
|
5
|
-
def test_that_verify_returns_true_when_the_request_signature_is_right
|
6
|
-
request = OAuth::RequestProxy::MockRequest.new(
|
7
|
-
'method' => 'POST',
|
8
|
-
'uri' => 'https://photos.example.net/initialize',
|
9
|
-
'parameters' => {
|
10
|
-
'oauth_consumer_key' => 'dpf43f3p2l4k3l03',
|
11
|
-
'oauth_signature_method' => 'HMAC-SHA1',
|
12
|
-
'oauth_timestamp' => '137131200',
|
13
|
-
'oauth_nonce' => 'wIjqoS',
|
14
|
-
'oauth_callback' => 'http://printer.example.com/ready',
|
15
|
-
'oauth_version' => '1.0',
|
16
|
-
'oauth_signature' => 'xcHYBV3AbyoDz7L4dV10P3oLCjY='
|
17
|
-
}
|
18
|
-
)
|
19
|
-
assert OAuth::Signature::HMAC::SHA1.new(request, :consumer_secret => 'kd94hf93k423kf44').verify
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_that_verify_returns_false_when_the_request_signature_is_wrong
|
23
|
-
# Test a bug in the OAuth::Signature::Base#== method: when the Base64.decode64 method is
|
24
|
-
# used on the "self" and "other" signature (as in version 0.4.7), the result may be incorrectly "true".
|
25
|
-
request = OAuth::RequestProxy::MockRequest.new(
|
26
|
-
'method' => 'POST',
|
27
|
-
'uri' => 'https://photos.example.net/initialize',
|
28
|
-
'parameters' => {
|
29
|
-
'oauth_consumer_key' => 'dpf43f3p2l4k3l03',
|
30
|
-
'oauth_signature_method' => 'HMAC-SHA1',
|
31
|
-
'oauth_timestamp' => '137131200',
|
32
|
-
'oauth_nonce' => 'wIjqoS',
|
33
|
-
'oauth_callback' => 'http://printer.example.com/ready',
|
34
|
-
'oauth_version' => '1.0',
|
35
|
-
'oauth_signature' => 'xcHYBV3AbyoDz7L4dV10P3oLCjZ='
|
36
|
-
}
|
37
|
-
)
|
38
|
-
assert !OAuth::Signature::HMAC::SHA1.new(request, :consumer_secret => 'kd94hf93k423kf44').verify
|
39
|
-
end
|
40
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_helper', __FILE__)
|
2
|
-
require 'oauth/signature/plaintext'
|
3
|
-
|
4
|
-
class TestSignaturePlaintext < Minitest::Test
|
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
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_helper', __FILE__)
|
2
|
-
require 'oauth/token'
|
3
|
-
|
4
|
-
class TestToken < Minitest::Test
|
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
|
@@ -1,101 +0,0 @@
|
|
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 < Minitest::Test
|
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_simple_put_request_works_with_arguments
|
65
|
-
request = Typhoeus::Request.new('/test', :method => :patch)
|
66
|
-
params = {'key' => 'value'}
|
67
|
-
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params})
|
68
|
-
|
69
|
-
expected_parameters = {'key' => 'value'}
|
70
|
-
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
71
|
-
assert_equal 'http://example.com/test', request_proxy.normalized_uri
|
72
|
-
assert_equal 'PATCH', request_proxy.method
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_that_proxy_simple_put_request_works_with_form_data
|
76
|
-
request = Typhoeus::Request.new('/test', :method => :patch, :params => {'key' => 'value'})
|
77
|
-
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'})
|
78
|
-
|
79
|
-
expected_parameters = {'key' => ['value']}
|
80
|
-
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
81
|
-
assert_equal 'http://example.com/test', request_proxy.normalized_uri
|
82
|
-
assert_equal 'PATCH', request_proxy.method
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_that_proxy_post_request_works_with_mixed_parameter_sources
|
86
|
-
request = Typhoeus::Request.new('/test?key=value',
|
87
|
-
:method => :post,
|
88
|
-
:params => {'key2' => 'value2'},
|
89
|
-
:headers => {'Content-Type' => 'application/x-www-form-urlencoded'})
|
90
|
-
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value', :parameters => {'key3' => 'value3'}})
|
91
|
-
|
92
|
-
expected_parameters = {'key' => ['value'], 'key2' => ['value2'], 'key3' => 'value3'}
|
93
|
-
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
94
|
-
assert_equal 'http://example.com/test', request_proxy.normalized_uri
|
95
|
-
assert_equal 'POST', request_proxy.method
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
rescue LoadError => e
|
100
|
-
warn "! problem loading typhoeus, skipping these tests: #{e}"
|
101
|
-
end
|