oauth 0.3.2 → 0.3.3
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 +11 -0
- data/Manifest.txt +1 -0
- data/README.rdoc +2 -2
- data/Rakefile +1 -1
- data/TODO +0 -1
- data/bin/oauth +1 -1
- data/lib/oauth/cli.rb +1 -1
- data/lib/oauth/client/action_controller_request.rb +1 -0
- data/lib/oauth/client/helper.rb +9 -0
- data/lib/oauth/client/net_http.rb +16 -0
- data/lib/oauth/consumer.rb +1 -0
- data/lib/oauth/helper.rb +29 -6
- data/lib/oauth/oauth.rb +1 -1
- data/lib/oauth/request_proxy/action_controller_request.rb +3 -3
- data/lib/oauth/signature.rb +9 -0
- data/lib/oauth/tokens/request_token.rb +2 -2
- data/lib/oauth/version.rb +1 -1
- data/oauth.gemspec +5 -5
- data/test/test_action_controller_request_proxy.rb +91 -9
- data/test/test_net_http_client.rb +38 -20
- data/test/test_net_http_request_proxy.rb +43 -8
- data/test/test_oauth_helper.rb +50 -0
- data/test/test_signature.rb +19 -11
- data/website/index.html +1 -1
- metadata +9 -5
data/History.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
== 0.3.3 2009-05-04
|
2
|
+
|
3
|
+
* Corrected OAuth XMPP namespace (Seth)
|
4
|
+
* Improved error handling for invalid Authorization headers (Matt Sanford)
|
5
|
+
* Fixed signatures for non-ASCII under $KCODE other than 'u' (Matt Sanford)
|
6
|
+
* Fixed edge cases in ActionControllerRequestProxy where params were being
|
7
|
+
incorrectly signed (Marcos Wright Kuhns)
|
8
|
+
* Support for arguments in OAuth::Consumer#get_access_token (Matt Sanford)
|
9
|
+
* Add gem version to user-agent header (Matt Sanford)
|
10
|
+
* Handle input from aggressive form encoding libraries (Matt Wood)
|
11
|
+
|
1
12
|
== 0.3.2 2009-03-23
|
2
13
|
|
3
14
|
* 2xx statuses should be treated as success (Anders Conbere)
|
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
@@ -12,7 +12,7 @@ See the OAuth specs http://oauth.net/core/1.0/
|
|
12
12
|
|
13
13
|
You can also install it from the oauth rubyforge project http://rubyforge.org/projects/oauth/.
|
14
14
|
|
15
|
-
The source code is now hosted on the OAuth GitHub Project http://github.com/
|
15
|
+
The source code is now hosted on the OAuth GitHub Project http://github.com/mojodna/oauth
|
16
16
|
|
17
17
|
== The basics
|
18
18
|
|
@@ -57,7 +57,7 @@ http://groups.google.com/group/oauth-ruby
|
|
57
57
|
|
58
58
|
Read the "8 steps for fixing other people's code" http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/.
|
59
59
|
|
60
|
-
The source code is now hosted on the OAuth GitHub Project http://github.com/
|
60
|
+
The source code is now hosted on the OAuth GitHub Project http://github.com/mojodna/oauth
|
61
61
|
|
62
62
|
To submit a patch, please fork the oauth project and create a patch with tests. Once you're happy with it send a pull request and post a message to the google group.
|
63
63
|
|
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ require 'oauth/version'
|
|
7
7
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
8
8
|
$hoe = Hoe.new('oauth', OAuth::VERSION) do |p|
|
9
9
|
p.author = ['Pelle Braendgaard','Blaine Cook','Larry Halff','Jesse Clark','Jon Crosby', 'Seth Fitzsimmons']
|
10
|
-
p.email = "
|
10
|
+
p.email = "oauth-ruby@googlegroups.com"
|
11
11
|
p.description = "OAuth Core Ruby implementation"
|
12
12
|
p.summary = p.description
|
13
13
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
data/TODO
CHANGED
data/bin/oauth
CHANGED
data/lib/oauth/cli.rb
CHANGED
@@ -111,7 +111,7 @@ module OAuth
|
|
111
111
|
stdout.puts
|
112
112
|
stdout.puts "XMPP Stanza:"
|
113
113
|
stdout.puts <<-EOS
|
114
|
-
<oauth xmlns='urn:xmpp:
|
114
|
+
<oauth xmlns='urn:xmpp:oauth:0'>
|
115
115
|
<oauth_consumer_key>#{request.oauth_consumer_key}</oauth_consumer_key>
|
116
116
|
<oauth_token>#{request.oauth_token}</oauth_token>
|
117
117
|
<oauth_signature_method>#{request.oauth_signature_method}</oauth_signature_method>
|
@@ -34,6 +34,7 @@ module ActionController
|
|
34
34
|
return unless ActionController::TestRequest.use_oauth? && @oauth_options
|
35
35
|
|
36
36
|
@oauth_helper = OAuth::Client::Helper.new(self, @oauth_options.merge(:request_uri => request_uri))
|
37
|
+
@oauth_helper.amend_user_agent_header(env)
|
37
38
|
|
38
39
|
self.send("set_oauth_#{@oauth_options[:scheme]}")
|
39
40
|
end
|
data/lib/oauth/client/helper.rb
CHANGED
@@ -50,6 +50,15 @@ module OAuth::Client
|
|
50
50
|
:parameters => oauth_parameters}.merge(extra_options) )
|
51
51
|
end
|
52
52
|
|
53
|
+
def amend_user_agent_header(headers)
|
54
|
+
@oauth_ua_string ||= "OAuth gem v#{OAuth::VERSION}"
|
55
|
+
if headers['User-Agent']
|
56
|
+
headers['User-Agent'] += " (#{@oauth_ua_string})"
|
57
|
+
else
|
58
|
+
headers['User-Agent'] = @oauth_ua_string
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
53
62
|
def header
|
54
63
|
parameters = oauth_parameters
|
55
64
|
parameters.merge!('oauth_signature' => signature(options.merge(:parameters => parameters)))
|
@@ -7,6 +7,14 @@ class Net::HTTPRequest
|
|
7
7
|
|
8
8
|
attr_reader :oauth_helper
|
9
9
|
|
10
|
+
# Add the OAuth information to an HTTP request. Depending on the <tt>options[:scheme]</tt> setting
|
11
|
+
# this may add a header, additional query string parameters, or additional POST body parameters.
|
12
|
+
# The default scheme is +header+, in which the OAuth parameters as put into the +Authorization+
|
13
|
+
# header.
|
14
|
+
#
|
15
|
+
# This method also modifies the <tt>User-Agent</tt> header to add the OAuth gem version.
|
16
|
+
#
|
17
|
+
# See Also: {OAuth core spec version 1.0, section 5.4.1}[http://oauth.net/core/1.0#rfc.section.5.4.1]
|
10
18
|
def oauth!(http, consumer = nil, token = nil, options = {})
|
11
19
|
options = { :request_uri => oauth_full_request_uri(http),
|
12
20
|
:consumer => consumer,
|
@@ -17,9 +25,17 @@ class Net::HTTPRequest
|
|
17
25
|
:timestamp => nil }.merge(options)
|
18
26
|
|
19
27
|
@oauth_helper = OAuth::Client::Helper.new(self, options)
|
28
|
+
@oauth_helper.amend_user_agent_header(self)
|
20
29
|
self.send("set_oauth_#{options[:scheme]}")
|
21
30
|
end
|
22
31
|
|
32
|
+
# Create a string suitable for signing for an HTTP request. This process involves parameter
|
33
|
+
# normalization as specified in the OAuth specification. The exact normalization also depends
|
34
|
+
# on the <tt>options[:scheme]</tt> being used so this must match what will be used for the request
|
35
|
+
# itself. The default scheme is +header+, in which the OAuth parameters as put into the +Authorization+
|
36
|
+
# header.
|
37
|
+
#
|
38
|
+
# See Also: {OAuth core spec version 1.0, section 9.1.1}[http://oauth.net/core/1.0#rfc.section.9.1.1]
|
23
39
|
def signature_base_string(http, consumer = nil, token = nil, options = {})
|
24
40
|
options = { :request_uri => oauth_full_request_uri(http),
|
25
41
|
:consumer => consumer,
|
data/lib/oauth/consumer.rb
CHANGED
data/lib/oauth/helper.rb
CHANGED
@@ -5,20 +5,32 @@ module OAuth
|
|
5
5
|
module Helper
|
6
6
|
extend self
|
7
7
|
|
8
|
+
# Escape +value+ by URL encoding all non-reserved character.
|
9
|
+
#
|
10
|
+
# See Also: {OAuth core spec version 1.0, section 5.1}[http://oauth.net/core/1.0#rfc.section.5.1]
|
8
11
|
def escape(value)
|
9
12
|
URI::escape(value.to_s, OAuth::RESERVED_CHARACTERS)
|
10
13
|
end
|
11
14
|
|
15
|
+
# Generate a random key of up to +size+ bytes. The value returned is Base64 encoded with non-word
|
16
|
+
# characters removed.
|
12
17
|
def generate_key(size=32)
|
13
18
|
Base64.encode64(OpenSSL::Random.random_bytes(size)).gsub(/\W/, '')
|
14
19
|
end
|
15
20
|
|
16
21
|
alias_method :generate_nonce, :generate_key
|
17
22
|
|
18
|
-
def generate_timestamp
|
23
|
+
def generate_timestamp #:nodoc:
|
19
24
|
Time.now.to_i.to_s
|
20
25
|
end
|
21
26
|
|
27
|
+
# Normalize a +Hash+ of parameter values. Parameters are sorted by name, using lexicographical
|
28
|
+
# byte value ordering. If two or more parameters share the same name, they are sorted by their value.
|
29
|
+
# Parameters are concatenated in their sorted order into a single string. For each parameter, the name
|
30
|
+
# is separated from the corresponding value by an "=" character, even if the value is empty. Each
|
31
|
+
# name-value pair is separated by an "&" character.
|
32
|
+
#
|
33
|
+
# See Also: {OAuth core spec version 1.0, section 9.1.1}[http://oauth.net/core/1.0#rfc.section.9.1.1]
|
22
34
|
def normalize(params)
|
23
35
|
params.sort.map do |k, values|
|
24
36
|
|
@@ -33,16 +45,27 @@ module OAuth
|
|
33
45
|
end * "&"
|
34
46
|
end
|
35
47
|
|
36
|
-
# Parse an Authorization / WWW-Authenticate header into a hash
|
48
|
+
# Parse an Authorization / WWW-Authenticate header into a hash. Takes care of unescaping and
|
49
|
+
# removing surrounding quotes. Raises a OAuth::Problem if the header is not parsable into a
|
50
|
+
# valid hash. Does not validate the keys or values.
|
51
|
+
#
|
52
|
+
# hash = parse_header(headers['Authorization'] || headers['WWW-Authenticate'])
|
53
|
+
# hash['oauth_timestamp']
|
54
|
+
# #=>"1234567890"
|
55
|
+
#
|
37
56
|
def parse_header(header)
|
38
57
|
# decompose
|
39
58
|
params = header[6,header.length].split(/[,=]/)
|
40
59
|
|
41
|
-
#
|
42
|
-
|
60
|
+
# odd number of arguments - must be a malformed header.
|
61
|
+
raise OAuth::Problem.new("Invalid authorization header") if params.size % 2 != 0
|
43
62
|
|
44
|
-
|
45
|
-
|
63
|
+
params.map! do |v|
|
64
|
+
# strip and unescape
|
65
|
+
val = unescape(v.strip)
|
66
|
+
# strip quotes
|
67
|
+
val.sub(/^\"(.*)\"$/, '\1')
|
68
|
+
end
|
46
69
|
|
47
70
|
# convert into a Hash
|
48
71
|
Hash[*params.flatten]
|
data/lib/oauth/oauth.rb
CHANGED
@@ -3,5 +3,5 @@ module OAuth
|
|
3
3
|
PARAMETERS = %w(oauth_consumer_key oauth_token oauth_signature_method oauth_timestamp oauth_nonce oauth_version oauth_signature)
|
4
4
|
|
5
5
|
# reserved character regexp, per section 5.1
|
6
|
-
RESERVED_CHARACTERS = /[
|
6
|
+
RESERVED_CHARACTERS = /[^a-zA-Z0-9\-\.\_\~]/
|
7
7
|
end
|
@@ -35,16 +35,16 @@ module OAuth::RequestProxy
|
|
35
35
|
unless options[:clobber_request]
|
36
36
|
params << header_params.to_query
|
37
37
|
params << request.query_string unless request.query_string.blank?
|
38
|
-
if request.content_type == Mime::Type.lookup("application/x-www-form-urlencoded")
|
38
|
+
if request.post? && request.content_type == Mime::Type.lookup("application/x-www-form-urlencoded")
|
39
39
|
params << request.raw_post
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
params.
|
44
44
|
join('&').split('&').
|
45
|
-
reject { |kv| kv =~ /^oauth_signature=.*/}.
|
46
45
|
reject(&:blank?).
|
47
|
-
map { |p| p.split('=').map{|esc| CGI.unescape(esc)} }
|
46
|
+
map { |p| p.split('=').map{|esc| CGI.unescape(esc)} }.
|
47
|
+
reject { |kv| kv =~ /^oauth_signature=.*/}
|
48
48
|
end
|
49
49
|
|
50
50
|
protected
|
data/lib/oauth/signature.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
module OAuth
|
2
2
|
module Signature
|
3
|
+
# Returns a list of available signature methods
|
3
4
|
def self.available_methods
|
4
5
|
@available_methods ||= {}
|
5
6
|
end
|
6
7
|
|
8
|
+
# Build a signature from a +request+.
|
9
|
+
#
|
10
|
+
# Raises UnknownSignatureMethod exception if the signature method is unknown.
|
7
11
|
def self.build(request, options = {}, &block)
|
8
12
|
request = OAuth::RequestProxy.proxy(request, options)
|
9
13
|
klass = available_methods[(request.signature_method || "").downcase]
|
@@ -11,14 +15,19 @@ module OAuth
|
|
11
15
|
klass.new(request, options, &block)
|
12
16
|
end
|
13
17
|
|
18
|
+
# Sign a +request+
|
14
19
|
def self.sign(request, options = {}, &block)
|
15
20
|
self.build(request, options, &block).signature
|
16
21
|
end
|
17
22
|
|
23
|
+
# Verify the signature of +request+
|
18
24
|
def self.verify(request, options = {}, &block)
|
19
25
|
self.build(request, options, &block).verify
|
20
26
|
end
|
21
27
|
|
28
|
+
# Create the signature base string for +request+. This string is the normalized parameter information.
|
29
|
+
#
|
30
|
+
# See Also: {OAuth core spec version 1.0, section 9.1.1}[http://oauth.net/core/1.0#rfc.section.9.1.1]
|
22
31
|
def self.signature_base_string(request, options = {}, &block)
|
23
32
|
self.build(request, options, &block).signature_base_string
|
24
33
|
end
|
@@ -10,8 +10,8 @@ module OAuth
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# exchange for AccessToken on server
|
13
|
-
def get_access_token(options = {})
|
14
|
-
response = consumer.token_request(consumer.http_method, (consumer.access_token_url? ? consumer.access_token_url : consumer.access_token_path), self, options)
|
13
|
+
def get_access_token(options = {}, *arguments)
|
14
|
+
response = consumer.token_request(consumer.http_method, (consumer.access_token_url? ? consumer.access_token_url : consumer.access_token_path), self, options, *arguments)
|
15
15
|
OAuth::AccessToken.from_hash(consumer, response)
|
16
16
|
end
|
17
17
|
|
data/lib/oauth/version.rb
CHANGED
data/oauth.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{oauth}
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons"]
|
9
|
-
s.date = %q{2009-
|
8
|
+
s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons", "Matt Sanford"]
|
9
|
+
s.date = %q{2009-05-04}
|
10
10
|
s.default_executable = %q{oauth}
|
11
11
|
s.description = %q{OAuth Core Ruby implementation}
|
12
12
|
s.email = %q{oauth-ruby@googlegroups.com}
|
13
13
|
s.executables = ["oauth"]
|
14
14
|
s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc", "website/index.txt"]
|
15
|
-
s.files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc", "Rakefile", "TODO", "bin/oauth", "examples/yql.rb", "lib/oauth.rb", "lib/oauth/oauth.rb", "lib/oauth/cli.rb", "lib/oauth/client.rb", "lib/oauth/client/action_controller_request.rb", "lib/oauth/client/helper.rb", "lib/oauth/client/net_http.rb", "lib/oauth/consumer.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_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/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/server.rb", "lib/oauth/signature.rb", "lib/oauth/signature/base.rb", "lib/oauth/signature/hmac/base.rb", "lib/oauth/signature/hmac/md5.rb", "lib/oauth/signature/hmac/rmd160.rb", "lib/oauth/signature/hmac/sha1.rb", "lib/oauth/signature/hmac/sha2.rb", "lib/oauth/signature/md5.rb", "lib/oauth/signature/plaintext.rb", "lib/oauth/signature/rsa/sha1.rb", "lib/oauth/signature/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", "oauth.gemspec", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "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/keys/rsa.cert", "test/keys/rsa.pem", "test/test_access_token.rb", "test/test_action_controller_request_proxy.rb", "test/test_consumer.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_rack_request_proxy.rb", "test/test_request_token.rb", "test/test_rsa_sha1.rb", "test/test_server.rb", "test/test_signature.rb", "test/test_signature_base.rb", "test/test_signature_plain_text.rb", "test/test_token.rb", "website/index.html", "website/index.txt", "website/javascripts/rounded_corners_lite.inc.js", "website/stylesheets/screen.css", "website/template.rhtml"]
|
15
|
+
s.files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc", "Rakefile", "TODO", "bin/oauth", "examples/yql.rb", "lib/oauth.rb", "lib/oauth/oauth.rb", "lib/oauth/cli.rb", "lib/oauth/client.rb", "lib/oauth/client/action_controller_request.rb", "lib/oauth/client/helper.rb", "lib/oauth/client/net_http.rb", "lib/oauth/consumer.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_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/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/server.rb", "lib/oauth/signature.rb", "lib/oauth/signature/base.rb", "lib/oauth/signature/hmac/base.rb", "lib/oauth/signature/hmac/md5.rb", "lib/oauth/signature/hmac/rmd160.rb", "lib/oauth/signature/hmac/sha1.rb", "lib/oauth/signature/hmac/sha2.rb", "lib/oauth/signature/md5.rb", "lib/oauth/signature/plaintext.rb", "lib/oauth/signature/rsa/sha1.rb", "lib/oauth/signature/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", "oauth.gemspec", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "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/keys/rsa.cert", "test/keys/rsa.pem", "test/test_access_token.rb", "test/test_action_controller_request_proxy.rb", "test/test_consumer.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_rsa_sha1.rb", "test/test_server.rb", "test/test_signature.rb", "test/test_signature_base.rb", "test/test_signature_plain_text.rb", "test/test_token.rb", "website/index.html", "website/index.txt", "website/javascripts/rounded_corners_lite.inc.js", "website/stylesheets/screen.css", "website/template.rhtml"]
|
16
16
|
s.has_rdoc = true
|
17
17
|
s.homepage = %q{http://oauth.rubyforge.org}
|
18
18
|
s.rdoc_options = ["--main", "README.rdoc"]
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.rubyforge_project = %q{oauth}
|
21
21
|
s.rubygems_version = %q{1.3.1}
|
22
22
|
s.summary = %q{OAuth Core Ruby implementation}
|
23
|
-
s.test_files = ["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/test_access_token.rb", "test/test_action_controller_request_proxy.rb", "test/test_consumer.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_rack_request_proxy.rb", "test/test_request_token.rb", "test/test_rsa_sha1.rb", "test/test_server.rb", "test/test_signature.rb", "test/test_signature_base.rb", "test/test_signature_plain_text.rb", "test/test_token.rb"]
|
23
|
+
s.test_files = ["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/test_access_token.rb", "test/test_action_controller_request_proxy.rb", "test/test_consumer.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_rsa_sha1.rb", "test/test_server.rb", "test/test_signature.rb", "test/test_signature_base.rb", "test/test_signature_plain_text.rb", "test/test_token.rb"]
|
24
24
|
|
25
25
|
if s.respond_to? :specification_version then
|
26
26
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
@@ -5,34 +5,116 @@ require 'action_controller/test_process'
|
|
5
5
|
|
6
6
|
class ActionControllerRequestProxyTest < Test::Unit::TestCase
|
7
7
|
|
8
|
-
def request_proxy(
|
9
|
-
request = ActionController::TestRequest.new
|
8
|
+
def request_proxy(request_method = :get, uri_params = {}, body_params = {})
|
9
|
+
request = ActionController::TestRequest.new
|
10
|
+
|
11
|
+
case request_method
|
12
|
+
when :post
|
13
|
+
request.env['REQUEST_METHOD'] = 'POST'
|
14
|
+
when :put
|
15
|
+
request.env['REQUEST_METHOD'] = 'PUT'
|
16
|
+
end
|
17
|
+
|
18
|
+
request.env['RAW_POST_DATA'] = body_params.to_query
|
10
19
|
request.env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
|
20
|
+
|
11
21
|
yield request if block_given?
|
12
|
-
OAuth::RequestProxy.proxy(request)
|
22
|
+
OAuth::RequestProxy.proxy(request, :parameters=>uri_params)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_that_proxy_simple_get_request_works_with_query_params
|
26
|
+
request_proxy = request_proxy(:get, {'key'=>'value'})
|
27
|
+
|
28
|
+
expected_parameters = [["key", "value"]]
|
29
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
30
|
+
assert_equal 'GET', request_proxy.method
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_that_proxy_simple_post_request_works_with_query_params
|
34
|
+
request_proxy = request_proxy(:post, {'key'=>'value'})
|
35
|
+
|
36
|
+
expected_parameters = [["key", "value"]]
|
37
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
38
|
+
assert_equal 'POST', request_proxy.method
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_that_proxy_simple_put_request_works_with_query_params
|
42
|
+
request_proxy = request_proxy(:put, {'key'=>'value'})
|
43
|
+
|
44
|
+
expected_parameters = [["key", "value"]]
|
45
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
46
|
+
assert_equal 'PUT', request_proxy.method
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_that_proxy_simple_put_request_works_with_post_params
|
50
|
+
request_proxy = request_proxy(:get, {}, {'key'=>'value'})
|
51
|
+
|
52
|
+
expected_parameters = []
|
53
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
54
|
+
assert_equal 'GET', request_proxy.method
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_that_proxy_simple_post_request_works_with_post_params
|
58
|
+
request_proxy = request_proxy(:post, {}, {'key'=>'value'})
|
59
|
+
|
60
|
+
expected_parameters = [["key", "value"]]
|
61
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
62
|
+
assert_equal 'POST', request_proxy.method
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_that_proxy_simple_put_request_works_with_post_params
|
66
|
+
request_proxy = request_proxy(:put, {}, {'key'=>'value'})
|
67
|
+
|
68
|
+
expected_parameters = []
|
69
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
70
|
+
assert_equal 'PUT', request_proxy.method
|
13
71
|
end
|
14
|
-
|
72
|
+
|
73
|
+
def test_that_proxy_simple_put_request_works_with_mixed_params
|
74
|
+
request_proxy = request_proxy(:get, {'key'=>'value'}, {'key2'=>'value2'})
|
75
|
+
|
76
|
+
expected_parameters = [["key", "value"]]
|
77
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
78
|
+
assert_equal 'GET', request_proxy.method
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_that_proxy_simple_post_request_works_with_mixed_params
|
82
|
+
request_proxy = request_proxy(:post, {'key'=>'value'}, {'key2'=>'value2'})
|
83
|
+
|
84
|
+
expected_parameters = [["key", "value"],["key2", "value2"]]
|
85
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
86
|
+
assert_equal 'POST', request_proxy.method
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_that_proxy_simple_put_request_works_with_mixed_params
|
90
|
+
request_proxy = request_proxy(:put, {'key'=>'value'}, {'key2'=>'value2'})
|
91
|
+
|
92
|
+
expected_parameters = [["key", "value"]]
|
93
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
94
|
+
assert_equal 'PUT', request_proxy.method
|
95
|
+
end
|
96
|
+
|
15
97
|
def test_parameter_keys_should_preserve_brackets_from_hash
|
16
98
|
assert_equal(
|
17
99
|
[["message[body]", "This is a test"]],
|
18
|
-
request_proxy({ :message => { :body => 'This is a test' }}).parameters_for_signature
|
100
|
+
request_proxy(:post, { :message => { :body => 'This is a test' }}).parameters_for_signature
|
19
101
|
)
|
20
102
|
end
|
21
|
-
|
103
|
+
|
22
104
|
def test_parameter_values_with_amps_should_not_break_parameter_parsing
|
23
105
|
assert_equal(
|
24
106
|
[['message[body]', 'http://foo.com/?a=b&c=d']],
|
25
|
-
request_proxy({ :message => { :body => 'http://foo.com/?a=b&c=d'}}).parameters_for_signature
|
107
|
+
request_proxy(:post, { :message => { :body => 'http://foo.com/?a=b&c=d'}}).parameters_for_signature
|
26
108
|
)
|
27
109
|
end
|
28
110
|
|
29
111
|
def test_parameter_keys_should_preserve_brackets_from_array
|
30
112
|
assert_equal(
|
31
113
|
[["foo[]", "123"], ["foo[]", "456"]],
|
32
|
-
request_proxy({ :foo => [123, 456] }).parameters_for_signature.sort
|
114
|
+
request_proxy(:post, { :foo => [123, 456] }).parameters_for_signature.sort
|
33
115
|
)
|
34
116
|
end
|
35
|
-
|
117
|
+
|
36
118
|
def test_query_string_parameter_values_should_be_cgi_unescaped
|
37
119
|
request = request_proxy do |r|
|
38
120
|
r.env['QUERY_STRING'] = 'url=http%3A%2F%2Ffoo.com%2F%3Fa%3Db%26c%3Dd'
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
2
|
require 'oauth/client/net_http'
|
3
|
+
require 'oauth/version'
|
3
4
|
|
4
5
|
class NetHTTPClientTest < Test::Unit::TestCase
|
5
6
|
|
@@ -16,7 +17,7 @@ class NetHTTPClientTest < Test::Unit::TestCase
|
|
16
17
|
def test_that_using_auth_headers_on_get_requests_works
|
17
18
|
request = Net::HTTP::Get.new(@request_uri.path + "?" + request_parameters_to_s)
|
18
19
|
request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp})
|
19
|
-
|
20
|
+
|
20
21
|
assert_equal 'GET', request.method
|
21
22
|
assert_equal '/test?key=value', request.path
|
22
23
|
assert_equal "OAuth 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\"".split(', ').sort, request['authorization'].split(', ').sort
|
@@ -32,16 +33,22 @@ class NetHTTPClientTest < Test::Unit::TestCase
|
|
32
33
|
assert_equal 'key=value', request.body
|
33
34
|
assert_equal "OAuth 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\"".split(', ').sort, request['authorization'].split(', ').sort
|
34
35
|
end
|
35
|
-
|
36
|
-
def
|
36
|
+
|
37
|
+
def test_that_version_is_added_to_existing_user_agent
|
37
38
|
request = Net::HTTP::Post.new(@request_uri.path)
|
39
|
+
request['User-Agent'] = "MyApp"
|
38
40
|
request.set_form_data( @request_parameters )
|
39
|
-
request.oauth!(@http, @consumer, @token, {:
|
41
|
+
request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp})
|
40
42
|
|
41
|
-
assert_equal
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
assert_equal "MyApp (OAuth gem v#{OAuth::VERSION})", request['User-Agent']
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_that_version_is_set_when_no_user_agent
|
47
|
+
request = Net::HTTP::Post.new(@request_uri.path)
|
48
|
+
request.set_form_data( @request_parameters )
|
49
|
+
request.oauth!(@http, @consumer, @token, {:nonce => @nonce, :timestamp => @timestamp})
|
50
|
+
|
51
|
+
assert_equal "OAuth gem v#{OAuth::VERSION}", request['User-Agent']
|
45
52
|
end
|
46
53
|
|
47
54
|
def test_that_using_get_params_works
|
@@ -56,7 +63,18 @@ class NetHTTPClientTest < Test::Unit::TestCase
|
|
56
63
|
assert_equal nil, request['authorization']
|
57
64
|
end
|
58
65
|
|
59
|
-
def
|
66
|
+
def test_that_using_post_params_works
|
67
|
+
request = Net::HTTP::Post.new(@request_uri.path)
|
68
|
+
request.set_form_data( @request_parameters )
|
69
|
+
request.oauth!(@http, @consumer, @token, {:scheme => 'body', :nonce => @nonce, :timestamp => @timestamp})
|
70
|
+
|
71
|
+
assert_equal 'POST', request.method
|
72
|
+
assert_equal '/test', request.path
|
73
|
+
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("&")
|
74
|
+
assert_equal nil, request['authorization']
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_that_using_post_with_uri_params_works
|
60
78
|
request = Net::HTTP::Post.new(@request_uri.path + "?" + request_parameters_to_s)
|
61
79
|
request.oauth!(@http, @consumer, @token, {:scheme => 'query_string', :nonce => @nonce, :timestamp => @timestamp})
|
62
80
|
|
@@ -69,7 +87,7 @@ class NetHTTPClientTest < Test::Unit::TestCase
|
|
69
87
|
assert_equal nil, request['authorization']
|
70
88
|
end
|
71
89
|
|
72
|
-
def
|
90
|
+
def test_that_using_post_with_uri_and_form_params_works
|
73
91
|
request = Net::HTTP::Post.new(@request_uri.path + "?" + request_parameters_to_s)
|
74
92
|
request.set_form_data( { 'key2' => 'value2' } )
|
75
93
|
request.oauth!(@http, @consumer, @token, {:scheme => :query_string, :nonce => @nonce, :timestamp => @timestamp})
|
@@ -82,8 +100,8 @@ class NetHTTPClientTest < Test::Unit::TestCase
|
|
82
100
|
assert_equal "key2=value2", request.body
|
83
101
|
assert_equal nil, request['authorization']
|
84
102
|
end
|
85
|
-
|
86
|
-
|
103
|
+
|
104
|
+
|
87
105
|
def test_example_from_specs
|
88
106
|
consumer=OAuth::Consumer.new("dpf43f3p2l4k3l03","kd94hf93k423kf44")
|
89
107
|
token = OAuth::Token.new('nnch734d00sl2jdk', 'pfkkdhi9sl3r4s00')
|
@@ -101,22 +119,22 @@ class NetHTTPClientTest < Test::Unit::TestCase
|
|
101
119
|
|
102
120
|
assert_equal 'GET', request.method
|
103
121
|
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"'.split(', ').sort, request['authorization'].split(', ').sort
|
104
|
-
|
122
|
+
|
105
123
|
end
|
106
|
-
|
124
|
+
|
107
125
|
def test_step_by_step_token_request
|
108
|
-
consumer=OAuth::Consumer.new(
|
126
|
+
consumer=OAuth::Consumer.new(
|
109
127
|
"key",
|
110
128
|
"secret")
|
111
129
|
request_uri = URI.parse('http://term.ie/oauth/example/request_token.php')
|
112
130
|
nonce = rand(2**128).to_s
|
113
131
|
timestamp = Time.now.to_i.to_s
|
114
132
|
http = Net::HTTP.new(request_uri.host, request_uri.port)
|
115
|
-
|
133
|
+
|
116
134
|
request = Net::HTTP::Get.new(request_uri.path)
|
117
135
|
signature_base_string=request.signature_base_string(http, consumer, nil, {:scheme=>:query_string,:nonce => nonce, :timestamp => timestamp})
|
118
136
|
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_version%3D1.0",signature_base_string
|
119
|
-
|
137
|
+
|
120
138
|
# request = Net::HTTP::Get.new(request_uri.path)
|
121
139
|
request.oauth!(http, consumer, nil, {:scheme=>:query_string,:nonce => nonce, :timestamp => timestamp})
|
122
140
|
assert_equal 'GET', request.method
|
@@ -129,7 +147,7 @@ class NetHTTPClientTest < Test::Unit::TestCase
|
|
129
147
|
# assert_equal request['authorization'],response.body
|
130
148
|
assert_equal "oauth_token=requestkey&oauth_token_secret=requestsecret",response.body
|
131
149
|
end
|
132
|
-
|
150
|
+
|
133
151
|
def test_that_put_bodies_not_signed
|
134
152
|
request = Net::HTTP::Put.new(@request_uri.path)
|
135
153
|
request.body = "<?xml version=\"1.0\"?><foo><bar>baz</bar></foo>"
|
@@ -144,14 +162,14 @@ class NetHTTPClientTest < Test::Unit::TestCase
|
|
144
162
|
signature_base_string=request.signature_base_string(@http, @consumer, nil, { :nonce => @nonce, :timestamp => @timestamp })
|
145
163
|
assert_equal "PUT&http%3A%2F%2Fexample.com%2Ftest&oauth_consumer_key%3Dconsumer_key_86cad9%26oauth_nonce%3D225579211881198842005988698334675835446%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1199645624%26oauth_version%3D1.0", signature_base_string
|
146
164
|
end
|
147
|
-
|
165
|
+
|
148
166
|
def test_that_post_bodies_signed_if_form_urlencoded
|
149
167
|
request = Net::HTTP::Post.new(@request_uri.path)
|
150
168
|
request.set_form_data( { 'key2' => 'value2' } )
|
151
169
|
signature_base_string=request.signature_base_string(@http, @consumer, nil, { :nonce => @nonce, :timestamp => @timestamp })
|
152
170
|
assert_equal "POST&http%3A%2F%2Fexample.com%2Ftest&key2%3Dvalue2%26oauth_consumer_key%3Dconsumer_key_86cad9%26oauth_nonce%3D225579211881198842005988698334675835446%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1199645624%26oauth_version%3D1.0", signature_base_string
|
153
171
|
end
|
154
|
-
|
172
|
+
|
155
173
|
def test_that_post_bodies_not_signed_if_other_content_type
|
156
174
|
request = Net::HTTP::Post.new(@request_uri.path)
|
157
175
|
request.body = "<?xml version=\"1.0\"?><foo><bar>baz</bar></foo>"
|
@@ -8,29 +8,64 @@ class NetHTTPRequestProxyTest < Test::Unit::TestCase
|
|
8
8
|
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value'})
|
9
9
|
|
10
10
|
expected_parameters = {'key' => ['value']}
|
11
|
-
assert_equal expected_parameters, request_proxy.
|
11
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
12
12
|
assert_equal 'http://example.com/test', request_proxy.normalized_uri
|
13
13
|
assert_equal 'GET', request_proxy.method
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def test_that_proxy_simple_post_request_works_with_arguments
|
17
17
|
request = Net::HTTP::Post.new('/test')
|
18
18
|
params = {'key' => 'value'}
|
19
19
|
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params})
|
20
20
|
|
21
21
|
expected_parameters = {'key' => ['value']}
|
22
|
-
assert_equal expected_parameters, request_proxy.
|
22
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
23
23
|
assert_equal 'http://example.com/test', request_proxy.normalized_uri
|
24
24
|
assert_equal 'POST', request_proxy.method
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def test_that_proxy_simple_post_request_works_with_form_data
|
28
|
+
request = Net::HTTP::Post.new('/test')
|
29
|
+
params = {'key' => 'value'}
|
30
|
+
request.set_form_data(params)
|
31
|
+
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'})
|
32
|
+
|
33
|
+
expected_parameters = {'key' => ['value']}
|
34
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
35
|
+
assert_equal 'http://example.com/test', request_proxy.normalized_uri
|
36
|
+
assert_equal 'POST', request_proxy.method
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_that_proxy_simple_put_request_works_with_argugments
|
40
|
+
request = Net::HTTP::Put.new('/test')
|
41
|
+
params = {'key' => 'value'}
|
42
|
+
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params})
|
43
|
+
|
44
|
+
expected_parameters = {'key' => ['value']}
|
45
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
46
|
+
assert_equal 'http://example.com/test', request_proxy.normalized_uri
|
47
|
+
assert_equal 'PUT', request_proxy.method
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_that_proxy_simple_put_request_works_with_form_data
|
51
|
+
request = Net::HTTP::Put.new('/test')
|
52
|
+
params = {'key' => 'value'}
|
53
|
+
request.set_form_data(params)
|
54
|
+
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'})
|
55
|
+
|
56
|
+
expected_parameters = {}
|
57
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
58
|
+
assert_equal 'http://example.com/test', request_proxy.normalized_uri
|
59
|
+
assert_equal 'PUT', request_proxy.method
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_that_proxy_post_request_works_with_mixed_parameter_sources
|
28
63
|
request = Net::HTTP::Post.new('/test?key=value')
|
29
|
-
|
30
|
-
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value', :parameters =>
|
64
|
+
request.set_form_data({'key2' => 'value2'})
|
65
|
+
request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value', :parameters => {'key3' => 'value3'}})
|
31
66
|
|
32
|
-
expected_parameters = {'key' => ['value'], 'key2' => ['value2']}
|
33
|
-
assert_equal expected_parameters, request_proxy.
|
67
|
+
expected_parameters = {'key' => ['value'], 'key2' => ['value2'], 'key3' => ['value3']}
|
68
|
+
assert_equal expected_parameters, request_proxy.parameters_for_signature
|
34
69
|
assert_equal 'http://example.com/test', request_proxy.normalized_uri
|
35
70
|
assert_equal 'POST', request_proxy.method
|
36
71
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require 'oauth/helper'
|
3
|
+
|
4
|
+
class TestOAuthHelper < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_parse_valid_header
|
7
|
+
header = 'OAuth ' \
|
8
|
+
'realm="http://example.com/method", ' \
|
9
|
+
'oauth_consumer_key="vince_clortho", ' \
|
10
|
+
'oauth_token="token_value", ' \
|
11
|
+
'oauth_signature_method="HMAC-SHA1", ' \
|
12
|
+
'oauth_signature="signature_here", ' \
|
13
|
+
'oauth_timestamp="1240004133", oauth_nonce="nonce", ' \
|
14
|
+
'oauth_version="1.0" '
|
15
|
+
|
16
|
+
params = OAuth::Helper.parse_header(header)
|
17
|
+
|
18
|
+
assert_equal "http://example.com/method", params['realm']
|
19
|
+
assert_equal "vince_clortho", params['oauth_consumer_key']
|
20
|
+
assert_equal "token_value", params['oauth_token']
|
21
|
+
assert_equal "HMAC-SHA1", params['oauth_signature_method']
|
22
|
+
assert_equal "signature_here", params['oauth_signature']
|
23
|
+
assert_equal "1240004133", params['oauth_timestamp']
|
24
|
+
assert_equal "nonce", params['oauth_nonce']
|
25
|
+
assert_equal "1.0", params['oauth_version']
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_parse_header_ill_formed
|
29
|
+
header = "OAuth garbage"
|
30
|
+
|
31
|
+
assert_raise OAuth::Problem do
|
32
|
+
OAuth::Helper.parse_header(header)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_parse_header_contains_equals
|
37
|
+
header = 'OAuth ' \
|
38
|
+
'realm="http://example.com/method", ' \
|
39
|
+
'oauth_consumer_key="vince_clortho", ' \
|
40
|
+
'oauth_token="token_value", ' \
|
41
|
+
'oauth_signature_method="HMAC-SHA1", ' \
|
42
|
+
'oauth_signature="signature_here_with_=", ' \
|
43
|
+
'oauth_timestamp="1240004133", oauth_nonce="nonce", ' \
|
44
|
+
'oauth_version="1.0" '
|
45
|
+
|
46
|
+
assert_raise OAuth::Problem do
|
47
|
+
OAuth::Helper.parse_header(header)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/test/test_signature.rb
CHANGED
@@ -1,11 +1,19 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
|
3
|
-
class TestOauth < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestOauth < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_parameter_escaping_kcode_invariant
|
6
|
+
old = $KCODE
|
7
|
+
begin
|
8
|
+
%w(n N e E s S u U).each do |kcode|
|
9
|
+
$KCODE = kcode
|
10
|
+
assert_equal '%E3%81%82', OAuth::Helper.escape('あ'),
|
11
|
+
"Failed to correctly escape Japanese under $KCODE = #{kcode}"
|
12
|
+
assert_equal '%C3%A9', OAuth::Helper.escape('é'),
|
13
|
+
"Failed to correctly escape e+acute under $KCODE = #{kcode}"
|
14
|
+
end
|
15
|
+
ensure
|
16
|
+
$KCODE = old
|
17
|
+
end
|
18
|
+
end
|
19
|
+
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.3.
|
36
|
+
<a href="http://rubyforge.org/projects/oauth" class="numbers">0.3.3</a>
|
37
37
|
</div>
|
38
38
|
<h2>What</h2>
|
39
39
|
<p>This is a RubyGem for implementing both OAuth clients and servers in Ruby applications.</p>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pelle Braendgaard
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2009-
|
17
|
+
date: 2009-05-04 00:00:00 +05:30
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
version: 1.8.0
|
69
69
|
version:
|
70
70
|
description: OAuth Core Ruby implementation
|
71
|
-
email:
|
71
|
+
email: oauth-ruby@googlegroups.com
|
72
72
|
executables:
|
73
73
|
- oauth
|
74
74
|
extensions: []
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- test/test_hmac_sha1.rb
|
151
151
|
- test/test_net_http_client.rb
|
152
152
|
- test/test_net_http_request_proxy.rb
|
153
|
+
- test/test_oauth_helper.rb
|
153
154
|
- test/test_rack_request_proxy.rb
|
154
155
|
- test/test_request_token.rb
|
155
156
|
- test/test_rsa_sha1.rb
|
@@ -165,6 +166,8 @@ files:
|
|
165
166
|
- website/template.rhtml
|
166
167
|
has_rdoc: true
|
167
168
|
homepage: http://oauth.rubyforge.org
|
169
|
+
licenses: []
|
170
|
+
|
168
171
|
post_install_message:
|
169
172
|
rdoc_options:
|
170
173
|
- --main
|
@@ -186,9 +189,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
189
|
requirements: []
|
187
190
|
|
188
191
|
rubyforge_project: oauth
|
189
|
-
rubygems_version: 1.3.
|
192
|
+
rubygems_version: 1.3.2
|
190
193
|
signing_key:
|
191
|
-
specification_version:
|
194
|
+
specification_version: 3
|
192
195
|
summary: OAuth Core Ruby implementation
|
193
196
|
test_files:
|
194
197
|
- test/cases/spec/1_0-final/test_construct_request_url.rb
|
@@ -202,6 +205,7 @@ test_files:
|
|
202
205
|
- test/test_hmac_sha1.rb
|
203
206
|
- test/test_net_http_client.rb
|
204
207
|
- test/test_net_http_request_proxy.rb
|
208
|
+
- test/test_oauth_helper.rb
|
205
209
|
- test/test_rack_request_proxy.rb
|
206
210
|
- test/test_request_token.rb
|
207
211
|
- test/test_rsa_sha1.rb
|