oauth 0.1.1 → 0.2.0
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.
- data/History.txt +9 -0
- data/License.txt +1 -1
- data/Manifest.txt +25 -7
- data/config/hoe.rb +1 -1
- data/lib/oauth.rb +1 -12
- data/lib/oauth/client.rb +4 -0
- data/lib/oauth/client/action_controller_request.rb +51 -0
- data/lib/oauth/client/helper.rb +74 -0
- data/lib/oauth/client/net_http.rb +72 -0
- data/lib/oauth/consumer.rb +112 -43
- data/lib/oauth/{key.rb → helper.rb} +6 -7
- data/lib/oauth/request_proxy.rb +24 -0
- data/lib/oauth/request_proxy/action_controller_request.rb +65 -0
- data/lib/oauth/request_proxy/base.rb +50 -0
- data/lib/oauth/request_proxy/net_http.rb +64 -0
- data/lib/oauth/server.rb +12 -9
- data/lib/oauth/signature.rb +15 -142
- data/lib/oauth/signature/base.rb +69 -0
- data/lib/oauth/signature/hmac/base.rb +12 -0
- data/lib/oauth/signature/hmac/md5.rb +9 -0
- data/lib/oauth/signature/hmac/rmd160.rb +9 -0
- data/lib/oauth/signature/hmac/sha1.rb +10 -0
- data/lib/oauth/signature/hmac/sha2.rb +9 -0
- data/lib/oauth/signature/md5.rb +13 -0
- data/lib/oauth/signature/plaintext.rb +19 -0
- data/lib/oauth/signature/rsa/sha1.rb +20 -0
- data/lib/oauth/signature/sha1.rb +13 -0
- data/lib/oauth/token.rb +54 -14
- data/lib/oauth/version.rb +2 -2
- data/test/test_action_controller_request_proxy.rb +10 -0
- data/test/test_consumer.rb +144 -57
- data/test/test_helper.rb +4 -0
- data/test/test_hmac_sha1.rb +21 -0
- data/test/test_net_http_client.rb +139 -0
- data/test/test_net_http_request_proxy.rb +38 -0
- data/test/test_server.rb +1 -8
- data/test/test_signature.rb +11 -113
- data/test/test_signature_base.rb +32 -0
- data/test/test_token.rb +14 -0
- data/website/index.html +9 -8
- data/website/index.txt +5 -6
- metadata +37 -13
- data/lib/oauth/consumer_credentials.rb +0 -12
- data/lib/oauth/oauth_test_helper.rb +0 -24
- data/lib/oauth/request.rb +0 -258
- data/test/test_oauth.rb +0 -11
- data/test/test_request.rb +0 -282
data/test/test_helper.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require 'oauth/signature/hmac/sha1'
|
3
|
+
|
4
|
+
class TestSignatureHmacSha1 < Test::Unit::TestCase
|
5
|
+
def test_that_hmac_sha1_implements_hmac_sha1
|
6
|
+
assert OAuth::Signature.available_methods.include?('hmac-sha1')
|
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_timestamp=1191242096&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1')
|
11
|
+
|
12
|
+
consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03', 'kd94hf93k423kf44')
|
13
|
+
token = OAuth::Token.new('nnch734d00sl2jdk', 'pfkkdhi9sl3r4s00')
|
14
|
+
|
15
|
+
signature = OAuth::Signature.sign(request, { :consumer => consumer,
|
16
|
+
:token => token,
|
17
|
+
:uri => 'http://photos.example.net/photos' } )
|
18
|
+
|
19
|
+
assert_equal 'tR3+Ty81lMeYAr/Fid0kMTYa/WM=', signature
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require 'oauth/client/net_http'
|
3
|
+
|
4
|
+
class NetHTTPClientTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@consumer = OAuth::Consumer.new('consumer_key_86cad9', '5888bf0345e5d237')
|
8
|
+
@token = OAuth::Token.new('token_411a7f', '3196ffd991c8ebdb')
|
9
|
+
@request_uri = URI.parse('http://example.com/test?key=value')
|
10
|
+
@request_parameters = { 'key' => 'value' }
|
11
|
+
@nonce = 225579211881198842005988698334675835446
|
12
|
+
@timestamp = "1199645624"
|
13
|
+
@http = Net::HTTP.new(@request_uri.host, @request_uri.port)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_that_using_auth_headers_on_get_requests_works
|
17
|
+
request = Net::HTTP::Get.new(@request_uri.path + "?" + request_parameters_to_s)
|
18
|
+
request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp})
|
19
|
+
|
20
|
+
assert_equal 'GET', request.method
|
21
|
+
assert_equal '/test?key=value', request.path
|
22
|
+
assert_equal "OAuth realm=\"\", oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"1oO2izFav1GP4kEH2EskwXkCRFg%3D\", oauth_version=\"1.0\"", request['authorization']
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_that_using_auth_headers_on_post_requests_works
|
26
|
+
request = Net::HTTP::Post.new(@request_uri.path)
|
27
|
+
request.set_form_data( @request_parameters )
|
28
|
+
request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp})
|
29
|
+
|
30
|
+
assert_equal 'POST', request.method
|
31
|
+
assert_equal '/test', request.path
|
32
|
+
assert_equal 'key=value', request.body
|
33
|
+
assert_equal "OAuth realm=\"\", oauth_nonce=\"225579211881198842005988698334675835446\", oauth_signature_method=\"HMAC-SHA1\", oauth_token=\"token_411a7f\", oauth_timestamp=\"1199645624\", oauth_consumer_key=\"consumer_key_86cad9\", oauth_signature=\"26g7wHTtNO6ZWJaLltcueppHYiI%3D\", oauth_version=\"1.0\"", request['authorization']
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_that_using_post_params_works
|
37
|
+
request = Net::HTTP::Post.new(@request_uri.path)
|
38
|
+
request.set_form_data( @request_parameters )
|
39
|
+
request.oauth!(@http, @consumer, @token, {:scheme => 'body', :nonce => @nonce, :timestamp => @timestamp})
|
40
|
+
|
41
|
+
assert_equal 'POST', request.method
|
42
|
+
assert_equal '/test', request.path
|
43
|
+
assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=26g7wHTtNO6ZWJaLltcueppHYiI%3d&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", request.body.split("&").sort.join("&")
|
44
|
+
assert_equal nil, request['authorization']
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_that_using_get_params_works
|
48
|
+
request = Net::HTTP::Get.new(@request_uri.path + "?" + request_parameters_to_s)
|
49
|
+
request.oauth!(@http, @consumer, @token, {:scheme => 'query_string', :nonce => @nonce, :timestamp => @timestamp})
|
50
|
+
|
51
|
+
assert_equal 'GET', request.method
|
52
|
+
uri = URI.parse(request.path)
|
53
|
+
assert_equal '/test', uri.path
|
54
|
+
assert_equal nil, uri.fragment
|
55
|
+
assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=1oO2izFav1GP4kEH2EskwXkCRFg=&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", uri.query.split("&").sort.join("&")
|
56
|
+
assert_equal nil, request['authorization']
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_that_using_get_params_works_with_post_requests
|
60
|
+
request = Net::HTTP::Post.new(@request_uri.path + "?" + request_parameters_to_s)
|
61
|
+
request.oauth!(@http, @consumer, @token, {:scheme => 'query_string', :nonce => @nonce, :timestamp => @timestamp})
|
62
|
+
|
63
|
+
assert_equal 'POST', request.method
|
64
|
+
uri = URI.parse(request.path)
|
65
|
+
assert_equal '/test', uri.path
|
66
|
+
assert_equal nil, uri.fragment
|
67
|
+
assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=26g7wHTtNO6ZWJaLltcueppHYiI=&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", uri.query.split("&").sort.join('&')
|
68
|
+
assert_equal nil, request.body
|
69
|
+
assert_equal nil, request['authorization']
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_that_using_get_params_works_with_post_requests_that_have_post_bodies
|
73
|
+
request = Net::HTTP::Post.new(@request_uri.path + "?" + request_parameters_to_s)
|
74
|
+
request.set_form_data( { 'key2' => 'value2' } )
|
75
|
+
request.oauth!(@http, @consumer, @token, {:scheme => :query_string, :nonce => @nonce, :timestamp => @timestamp})
|
76
|
+
|
77
|
+
assert_equal 'POST', request.method
|
78
|
+
uri = URI.parse(request.path)
|
79
|
+
assert_equal '/test', uri.path
|
80
|
+
assert_equal nil, uri.fragment
|
81
|
+
assert_equal "key=value&oauth_consumer_key=consumer_key_86cad9&oauth_nonce=225579211881198842005988698334675835446&oauth_signature=4kSU8Zd1blWo3W6qJH7eaRTMkg0=&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1199645624&oauth_token=token_411a7f&oauth_version=1.0", uri.query.split("&").sort.join('&')
|
82
|
+
assert_equal "key2=value2", request.body
|
83
|
+
assert_equal nil, request['authorization']
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
def test_example_from_specs
|
88
|
+
consumer=OAuth::Consumer.new("dpf43f3p2l4k3l03","kd94hf93k423kf44")
|
89
|
+
token = OAuth::Token.new('nnch734d00sl2jdk', 'pfkkdhi9sl3r4s00')
|
90
|
+
request_uri = URI.parse('http://photos.example.net/photos?file=vacation.jpg&size=original')
|
91
|
+
nonce = 'kllo9940pd9333jh'
|
92
|
+
timestamp = "1191242096"
|
93
|
+
http = Net::HTTP.new(request_uri.host, request_uri.port)
|
94
|
+
|
95
|
+
request = Net::HTTP::Get.new(request_uri.path + "?" + request_uri.query)
|
96
|
+
signature_base_string=request.signature_base_string(http, consumer, token, {:nonce => nonce, :timestamp => timestamp})
|
97
|
+
assert_equal 'GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal',signature_base_string
|
98
|
+
|
99
|
+
# request = Net::HTTP::Get.new(request_uri.path + "?" + request_uri.query)
|
100
|
+
request.oauth!(http, consumer, token, {:nonce => nonce, :timestamp => timestamp,:realm=>"http://photos.example.net/"})
|
101
|
+
|
102
|
+
assert_equal 'GET', request.method
|
103
|
+
assert_equal 'OAuth realm="http://photos.example.net/", oauth_nonce="kllo9940pd9333jh", oauth_signature_method="HMAC-SHA1", oauth_token="nnch734d00sl2jdk", oauth_timestamp="1191242096", oauth_consumer_key="dpf43f3p2l4k3l03", oauth_signature="tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D", oauth_version="1.0"', request['authorization']
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_step_by_step_token_request
|
108
|
+
consumer=OAuth::Consumer.new(
|
109
|
+
"key",
|
110
|
+
"secret")
|
111
|
+
request_uri = URI.parse('http://term.ie/oauth/example/request_token.php')
|
112
|
+
nonce = rand(2**128).to_s
|
113
|
+
timestamp = Time.now.to_i.to_s
|
114
|
+
http = Net::HTTP.new(request_uri.host, request_uri.port)
|
115
|
+
|
116
|
+
request = Net::HTTP::Get.new(request_uri.path)
|
117
|
+
signature_base_string=request.signature_base_string(http, consumer, nil, {:scheme=>:query_string,:nonce => nonce, :timestamp => timestamp})
|
118
|
+
assert_equal "GET&http%3A%2F%2Fterm.ie%2Foauth%2Fexample%2Frequest_token.php&oauth_consumer_key%3Dkey%26oauth_nonce%3D#{nonce}%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D#{timestamp}%26oauth_token%3D%26oauth_version%3D1.0",signature_base_string
|
119
|
+
|
120
|
+
# request = Net::HTTP::Get.new(request_uri.path)
|
121
|
+
request.oauth!(http, consumer, nil, {:scheme=>:query_string,:nonce => nonce, :timestamp => timestamp})
|
122
|
+
assert_equal 'GET', request.method
|
123
|
+
assert_nil request.body
|
124
|
+
assert_nil request['authorization']
|
125
|
+
# assert_equal 'OAuth oauth_nonce="kllo9940pd9333jh", oauth_signature_method="HMAC-SHA1", oauth_token="", oauth_timestamp="'+timestamp+'", oauth_consumer_key="key", oauth_signature="tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D", oauth_version="1.0"', request['authorization']
|
126
|
+
|
127
|
+
response=http.request(request)
|
128
|
+
assert_equal "200",response.code
|
129
|
+
# assert_equal request['authorization'],response.body
|
130
|
+
assert_equal "oauth_token=requestkey&oauth_token_secret=requestsecret",response.body
|
131
|
+
end
|
132
|
+
|
133
|
+
protected
|
134
|
+
|
135
|
+
def request_parameters_to_s
|
136
|
+
@request_parameters.map { |k,v| "#{k}=#{v}" }.join("&")
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require 'oauth/request_proxy/net_http'
|
3
|
+
|
4
|
+
class NetHTTPRequestProxyTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_that_proxy_simple_get_request_works
|
7
|
+
request = Net::HTTP::Get.new('/test?key=value')
|
8
|
+
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value'})
|
9
|
+
|
10
|
+
expected_parameters = {'key' => ['value']}
|
11
|
+
assert_equal expected_parameters, request_proxy.parameters
|
12
|
+
assert_equal 'http://example.com/test', request_proxy.uri
|
13
|
+
assert_equal 'GET', request_proxy.method
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_that_proxy_simple_post_request_works
|
17
|
+
request = Net::HTTP::Post.new('/test')
|
18
|
+
params = {'key' => 'value'}
|
19
|
+
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params})
|
20
|
+
|
21
|
+
expected_parameters = {'key' => ['value']}
|
22
|
+
assert_equal expected_parameters, request_proxy.parameters
|
23
|
+
assert_equal 'http://example.com/test', request_proxy.uri
|
24
|
+
assert_equal 'POST', request_proxy.method
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_that_proxy_post_and_get_request_works
|
28
|
+
request = Net::HTTP::Post.new('/test?key=value')
|
29
|
+
params = {'key2' => 'value2'}
|
30
|
+
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value', :parameters => params})
|
31
|
+
|
32
|
+
expected_parameters = {'key' => ['value'], 'key2' => ['value2']}
|
33
|
+
assert_equal expected_parameters, request_proxy.parameters
|
34
|
+
assert_equal 'http://example.com/test', request_proxy.uri
|
35
|
+
assert_equal 'POST', request_proxy.method
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/test/test_server.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'test/unit'
|
2
|
-
require 'oauth'
|
2
|
+
require 'oauth/server'
|
3
3
|
class ServerTest < Test::Unit::TestCase
|
4
4
|
def setup
|
5
5
|
@server=OAuth::Server.new "http://test.com"
|
@@ -37,11 +37,4 @@ class ServerTest < Test::Unit::TestCase
|
|
37
37
|
assert_equal "http://test.com/oauth/access_token",@consumer.access_token_url
|
38
38
|
end
|
39
39
|
|
40
|
-
def test_verify_request
|
41
|
-
@consumer=@server.create_consumer
|
42
|
-
@request=@consumer.signed_request :get,@consumer.request_token_path
|
43
|
-
assert @request.signed?
|
44
|
-
|
45
|
-
assert @request.verify?(@consumer.secret)
|
46
|
-
end
|
47
40
|
end
|
data/test/test_signature.rb
CHANGED
@@ -1,113 +1,11 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
class
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
:oauth_nonce=>"kllo9940pd9333jh"
|
13
|
-
}
|
14
|
-
|
15
|
-
@request=OAuth::Request.new( :get,'http://photos.example.net','/photos?file=vacation.jpg&size=original', @test_params)
|
16
|
-
@signature=OAuth::Signature.create(@request,@consumer_secret,@token_secret)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_base_string
|
20
|
-
from_spec="GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal"
|
21
|
-
assert_equal from_spec,@signature.base_string
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_base_string_with_post_params
|
25
|
-
@request=OAuth::Request.new( :post,'http://photos.example.net','/photos', @test_params,'file=vacation.jpg&size=original')
|
26
|
-
@signature=OAuth::Signature.create(@request,@consumer_secret,@token_secret)
|
27
|
-
from_spec="POST&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal"
|
28
|
-
assert_equal from_spec,@signature.base_string
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_signature_key
|
32
|
-
assert_equal "kd94hf93k423kf44&pfkkdhi9sl3r4s00",@signature.key
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_signature
|
36
|
-
assert_equal "tR3+Ty81lMeYAr/Fid0kMTYa/WM=",@signature.sign
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_sign_hmac_sha1
|
40
|
-
assert !@request.signed?
|
41
|
-
assert !@signature.verify?
|
42
|
-
@signature.sign!
|
43
|
-
assert @request.signed?
|
44
|
-
assert @signature.verify?
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_sign_hmac_md5
|
48
|
-
@request.signature_method="hmac-md5"
|
49
|
-
@signature=OAuth::Signature.create(@request,@consumer_secret,@token_secret)
|
50
|
-
|
51
|
-
assert !@request.signed?
|
52
|
-
assert !@signature.verify?
|
53
|
-
@signature.sign!
|
54
|
-
assert @request.signed?
|
55
|
-
assert @signature.verify?
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_sign_hmac_sha2
|
59
|
-
@request.signature_method="hmac-sha2"
|
60
|
-
@signature=OAuth::Signature.create(@request,@consumer_secret,@token_secret)
|
61
|
-
|
62
|
-
assert !@request.signed?
|
63
|
-
assert !@signature.verify?
|
64
|
-
@signature.sign!
|
65
|
-
assert @request.signed?
|
66
|
-
assert @signature.verify?
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_sign_hmac_rmd160
|
70
|
-
@request.signature_method="hmac-rmd160"
|
71
|
-
@signature=OAuth::Signature.create(@request,@consumer_secret,@token_secret)
|
72
|
-
|
73
|
-
assert !@request.signed?
|
74
|
-
assert !@signature.verify?
|
75
|
-
@signature.sign!
|
76
|
-
assert @request.signed?
|
77
|
-
assert @signature.verify?
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_sign_plain_with_https
|
81
|
-
@request.site='https://photos.example.net'
|
82
|
-
@request.signature_method="plaintext"
|
83
|
-
@signature=OAuth::Signature.create(@request,@consumer_secret,@token_secret)
|
84
|
-
|
85
|
-
assert !@request.signed?
|
86
|
-
assert !@signature.verify?
|
87
|
-
@signature.sign!
|
88
|
-
assert @request.signed?
|
89
|
-
assert @signature.verify?
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_sign_plain_with_http
|
93
|
-
@request.signature_method="plaintext"
|
94
|
-
assert_raise(OAuth::Signature::InsecureSignatureMethod) do
|
95
|
-
OAuth::Signature.create(@request,@consumer_secret,@token_secret)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_sign_sha1
|
100
|
-
@request.signature_method="sha1"
|
101
|
-
assert_raise(OAuth::Signature::InsecureSignatureMethod) do
|
102
|
-
OAuth::Signature.create(@request,@consumer_secret,@token_secret)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_sign_md5
|
107
|
-
@request.signature_method="md5"
|
108
|
-
assert_raise(OAuth::Signature::InsecureSignatureMethod) do
|
109
|
-
OAuth::Signature.create(@request,@consumer_secret,@token_secret)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestOauth < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_truth
|
9
|
+
assert true
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
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
|
data/test/test_token.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
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
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>Ruby OAuth GEM</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/oauth"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/oauth" class="numbers">0.
|
36
|
+
<a href="http://rubyforge.org/projects/oauth" class="numbers">0.2.0</a>
|
37
37
|
</div>
|
38
38
|
<h2>What</h2>
|
39
39
|
|
@@ -41,7 +41,7 @@
|
|
41
41
|
<p>This is a RubyGem for implementing both OAuth clients and servers in Ruby applications.</p>
|
42
42
|
|
43
43
|
|
44
|
-
<p>See the <a href="http://oauth.
|
44
|
+
<p>See the <a href="http://oauth.net/core/1.0/">OAuth specs</a></p>
|
45
45
|
|
46
46
|
|
47
47
|
<h2>Installing</h2>
|
@@ -50,6 +50,9 @@
|
|
50
50
|
<p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">oauth</span></pre></p>
|
51
51
|
|
52
52
|
|
53
|
+
<p>You can also install it from the <a href="http://rubyforge.org/projects/oauth/">oauth rubyforge project</a>.</p>
|
54
|
+
|
55
|
+
|
53
56
|
<h2>The basics</h2>
|
54
57
|
|
55
58
|
|
@@ -65,9 +68,7 @@
|
|
65
68
|
<p>Create a new consumer instance by passing it a configuration hash:</p>
|
66
69
|
|
67
70
|
|
68
|
-
<pre><code>@consumer=OAuth::Consumer.new( {
|
69
|
-
:consumer_key=>"key",
|
70
|
-
:consumer_secret=>"secret",
|
71
|
+
<pre><code>@consumer=OAuth::Consumer.new( "key","secret", {
|
71
72
|
:site=>"https://agree2"
|
72
73
|
})</code></pre>
|
73
74
|
|
@@ -108,7 +109,7 @@ redirect_to @request_token.authorize_url</code></pre>
|
|
108
109
|
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people’s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
|
109
110
|
|
110
111
|
|
111
|
-
<p>The trunk repository is <code>
|
112
|
+
<p>The trunk repository is <code>http://oauth.rubyforge.org/svn/trunk/</code> for anonymous access.</p>
|
112
113
|
|
113
114
|
|
114
115
|
<h2>License</h2>
|
@@ -120,9 +121,9 @@ redirect_to @request_token.authorize_url</code></pre>
|
|
120
121
|
<h2>Contact</h2>
|
121
122
|
|
122
123
|
|
123
|
-
<p>Comments are welcome. Send an email to <a href="mailto:pelleb@gmail.com">Pelle Braendgaard</a> email via the <a href="http://groups.google.com/group/oauth">
|
124
|
+
<p>Comments are welcome. Send an email to <a href="mailto:pelleb@gmail.com">Pelle Braendgaard</a> email via the <a href="http://groups.google.com/group/oauth-ruby">OAuth Ruby mailing list</a></p>
|
124
125
|
<p class="coda">
|
125
|
-
<a href="FIXME email">FIXME full name</a>,
|
126
|
+
<a href="FIXME email">FIXME full name</a>, 21st January 2008<br>
|
126
127
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
127
128
|
</p>
|
128
129
|
</div>
|