oauth 0.4.3 → 0.4.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.

data/HISTORY CHANGED
@@ -1,3 +1,11 @@
1
+ === 0.4.4 2010-10-31
2
+
3
+ * Fix LoadError rescue in tests: return can't be used in this context (Hans de Graaff)
4
+ * HTTP headers should be strings. (seancribbs)
5
+ * ensure consumer uri gets set back to original config even if an error occurs (Brian Finney)
6
+ * Yahoo uses & to split records in OAuth headers (Brian Finney)
7
+ * Added support for Rails 3 in client/action_controller_request (Pelle)
8
+
1
9
  == 0.4.3 2010-09-01
2
10
 
3
11
  * Fix for em-http proxy (ichverstehe)
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ begin
12
12
  s.description = "OAuth Core Ruby implementation"
13
13
  s.summary = s.description
14
14
  s.rubyforge_project = %q{oauth}
15
- s.add_development_dependency(%q<actionpack>, ["2.3.8"])
15
+ s.add_development_dependency(%q<actionpack>, [">=2.3.5"])
16
16
  s.add_development_dependency(%q<rack>, [">= 1.0.0"])
17
17
  s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
18
18
  s.add_development_dependency(%q<typhoeus>, [">= 0.1.13"])
@@ -1,7 +1,7 @@
1
1
  $LOAD_PATH << File.dirname(__FILE__) unless $LOAD_PATH.include?(File.dirname(__FILE__))
2
2
 
3
3
  module OAuth
4
- VERSION = "0.4.3"
4
+ VERSION = "0.4.4"
5
5
  end
6
6
 
7
7
  require 'oauth/oauth'
@@ -1,15 +1,26 @@
1
1
  require 'oauth/client/helper'
2
- require 'oauth/request_proxy/action_controller_request'
3
- require 'action_controller/test_process'
2
+ if defined? ActionDispatch
3
+ require 'oauth/request_proxy/rack_request'
4
+ require 'action_dispatch/testing/test_process'
5
+ else
6
+ require 'oauth/request_proxy/action_controller_request'
7
+ require 'action_controller/test_process'
8
+ end
4
9
 
5
10
  module ActionController
6
11
  class Base
7
- def process_with_oauth(request, response=nil)
8
- request.apply_oauth! if request.respond_to?(:apply_oauth!)
9
- process_without_oauth(request, response)
12
+ if defined? ActionDispatch
13
+ def process_with_new_base_test(request, response=nil)
14
+ request.apply_oauth! if request.respond_to?(:apply_oauth!)
15
+ super(request, response)
16
+ end
17
+ else
18
+ def process_with_oauth(request, response=nil)
19
+ request.apply_oauth! if request.respond_to?(:apply_oauth!)
20
+ process_without_oauth(request, response)
21
+ end
22
+ alias_method_chain :process, :oauth
10
23
  end
11
-
12
- alias_method_chain :process, :oauth
13
24
  end
14
25
 
15
26
  class TestRequest
@@ -33,7 +44,7 @@ module ActionController
33
44
  def apply_oauth!
34
45
  return unless ActionController::TestRequest.use_oauth? && @oauth_options
35
46
 
36
- @oauth_helper = OAuth::Client::Helper.new(self, @oauth_options.merge(:request_uri => request_uri))
47
+ @oauth_helper = OAuth::Client::Helper.new(self, @oauth_options.merge(:request_uri => (respond_to?(:fullpath) ? fullpath : request_uri)))
37
48
  @oauth_helper.amend_user_agent_header(env)
38
49
 
39
50
  self.send("set_oauth_#{@oauth_options[:scheme]}")
@@ -334,10 +334,10 @@ module OAuth
334
334
  case http_method
335
335
  when :post
336
336
  request = Net::HTTP::Post.new(path,headers)
337
- request["Content-Length"] = 0 # Default to 0
337
+ request["Content-Length"] = '0' # Default to 0
338
338
  when :put
339
339
  request = Net::HTTP::Put.new(path,headers)
340
- request["Content-Length"] = 0 # Default to 0
340
+ request["Content-Length"] = '0' # Default to 0
341
341
  when :get
342
342
  request = Net::HTTP::Get.new(path,headers)
343
343
  when :delete
@@ -356,15 +356,15 @@ module OAuth
356
356
  if data.respond_to?(:read)
357
357
  request.body_stream = data
358
358
  if data.respond_to?(:length)
359
- request["Content-Length"] = data.length
359
+ request["Content-Length"] = data.length.to_s
360
360
  elsif data.respond_to?(:stat) && data.stat.respond_to?(:size)
361
- request["Content-Length"] = data.stat.size
361
+ request["Content-Length"] = data.stat.size.to_s
362
362
  else
363
363
  raise ArgumentError, "Don't know how to send a body_stream that doesn't respond to .length or .stat.size"
364
364
  end
365
365
  else
366
366
  request.body = data.to_s
367
- request["Content-Length"] = request.body.length
367
+ request["Content-Length"] = request.body.length.to_s
368
368
  end
369
369
  end
370
370
 
@@ -57,7 +57,7 @@ module OAuth
57
57
  #
58
58
  def parse_header(header)
59
59
  # decompose
60
- params = header[6,header.length].split(/[,=]/)
60
+ params = header[6,header.length].split(/[,=&]/)
61
61
 
62
62
  # odd number of arguments - must be a malformed header.
63
63
  raise OAuth::Problem.new("Invalid authorization header") if params.size % 2 != 0
@@ -7,11 +7,14 @@ module OAuth
7
7
  request_uri = URI.parse(path)
8
8
  site_uri = consumer.uri
9
9
  is_service_uri_different = (request_uri.absolute? && request_uri != site_uri)
10
- consumer.uri(request_uri) if is_service_uri_different
11
- @response = super(http_method, path, *arguments)
12
- # NOTE: reset for wholesomeness? meaning that we admit only AccessToken service calls may use different URIs?
13
- # so reset in case consumer is still used for other token-management tasks subsequently?
14
- consumer.uri(site_uri) if is_service_uri_different
10
+ begin
11
+ consumer.uri(request_uri) if is_service_uri_different
12
+ @response = super(http_method, path, *arguments)
13
+ ensure
14
+ # NOTE: reset for wholesomeness? meaning that we admit only AccessToken service calls may use different URIs?
15
+ # so reset in case consumer is still used for other token-management tasks subsequently?
16
+ consumer.uri(site_uri) if is_service_uri_different
17
+ end
15
18
  @response
16
19
  end
17
20
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{oauth}
8
- s.version = "0.4.3"
8
+ s.version = "0.4.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons", "Matt Sanford", "Aaron Quint"]
12
- s.date = %q{2010-09-01}
12
+ s.date = %q{2010-10-31}
13
13
  s.default_executable = %q{oauth}
14
14
  s.description = %q{OAuth Core Ruby implementation}
15
15
  s.email = %q{oauth-ruby@googlegroups.com}
@@ -148,14 +148,14 @@ Gem::Specification.new do |s|
148
148
  s.specification_version = 3
149
149
 
150
150
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
151
- s.add_development_dependency(%q<actionpack>, ["= 2.3.8"])
151
+ s.add_development_dependency(%q<actionpack>, [">= 2.3.5"])
152
152
  s.add_development_dependency(%q<rack>, [">= 1.0.0"])
153
153
  s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
154
154
  s.add_development_dependency(%q<typhoeus>, [">= 0.1.13"])
155
155
  s.add_development_dependency(%q<em-http-request>, [">= 0.2.10"])
156
156
  s.add_development_dependency(%q<curb>, [">= 0.6.6.0"])
157
157
  else
158
- s.add_dependency(%q<actionpack>, ["= 2.3.8"])
158
+ s.add_dependency(%q<actionpack>, [">= 2.3.5"])
159
159
  s.add_dependency(%q<rack>, [">= 1.0.0"])
160
160
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
161
161
  s.add_dependency(%q<typhoeus>, [">= 0.1.13"])
@@ -163,7 +163,7 @@ Gem::Specification.new do |s|
163
163
  s.add_dependency(%q<curb>, [">= 0.6.6.0"])
164
164
  end
165
165
  else
166
- s.add_dependency(%q<actionpack>, ["= 2.3.8"])
166
+ s.add_dependency(%q<actionpack>, [">= 2.3.5"])
167
167
  s.add_dependency(%q<rack>, [">= 1.0.0"])
168
168
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
169
169
  s.add_dependency(%q<typhoeus>, [">= 0.1.13"])
@@ -1,12 +1,9 @@
1
1
  require File.expand_path('../test_helper', __FILE__)
2
2
 
3
3
  begin
4
- require 'oauth/request_proxy/curb_request'
5
- require 'curb'
6
- rescue LoadError => e
7
- warn "! problems loading curb, skipping these tests: #{e}"
8
- return
9
- end
4
+
5
+ require 'oauth/request_proxy/curb_request'
6
+ require 'curb'
10
7
 
11
8
 
12
9
  class CurbRequestProxyTest < Test::Unit::TestCase
@@ -74,3 +71,7 @@ class CurbRequestProxyTest < Test::Unit::TestCase
74
71
  assert_equal 'http://example.com/test', request_proxy.normalized_uri
75
72
  end
76
73
  end
74
+
75
+ rescue LoadError => e
76
+ warn "! problems loading curb, skipping these tests: #{e}"
77
+ end
@@ -1,10 +1,7 @@
1
1
  require File.expand_path('../test_helper', __FILE__)
2
2
  begin
3
- require 'oauth/client/em_http'
4
- rescue LoadError => e
5
- warn "! problem loading em-http, skipping these tests: #{e}"
6
- return
7
- end
3
+
4
+ require 'oauth/client/em_http'
8
5
 
9
6
  class EmHttpClientTest < Test::Unit::TestCase
10
7
 
@@ -77,3 +74,7 @@ class EmHttpClientTest < Test::Unit::TestCase
77
74
  end
78
75
 
79
76
  end
77
+
78
+ rescue LoadError => e
79
+ warn "! problem loading em-http, skipping these tests: #{e}"
80
+ end
@@ -1,12 +1,9 @@
1
1
  require File.expand_path('../test_helper', __FILE__)
2
2
 
3
3
  begin
4
- require 'em-http'
5
- require 'oauth/request_proxy/em_http_request'
6
- rescue LoadError => e
7
- warn "! problem loading em-http, skipping these tests: #{e}"
8
- return
9
- end
4
+
5
+ require 'em-http'
6
+ require 'oauth/request_proxy/em_http_request'
10
7
 
11
8
 
12
9
  class EmHttpRequestProxyTest < Test::Unit::TestCase
@@ -110,5 +107,9 @@ class EmHttpRequestProxyTest < Test::Unit::TestCase
110
107
  arguments = opts.delete(:proxy_options) || {}
111
108
  OAuth::RequestProxy.proxy(create_client(opts), arguments)
112
109
  end
110
+
111
+ end
113
112
 
113
+ rescue LoadError => e
114
+ warn "! problem loading em-http, skipping these tests: #{e}"
114
115
  end
@@ -46,4 +46,26 @@ class TestOAuthHelper < Test::Unit::TestCase
46
46
  OAuth::Helper.parse_header(header)
47
47
  end
48
48
  end
49
+
50
+ def test_parse_valid_header_with_and_signs
51
+ header = 'OAuth ' \
52
+ 'realm="http://example.com/method"&' \
53
+ 'oauth_consumer_key="vince_clortho"&' \
54
+ 'oauth_token="token_value"&' \
55
+ 'oauth_signature_method="HMAC-SHA1"&' \
56
+ 'oauth_signature="signature_here"&' \
57
+ 'oauth_timestamp="1240004133"&oauth_nonce="nonce"&' \
58
+ 'oauth_version="1.0"'
59
+
60
+ params = OAuth::Helper.parse_header(header)
61
+
62
+ assert_equal "http://example.com/method", params['realm']
63
+ assert_equal "vince_clortho", params['oauth_consumer_key']
64
+ assert_equal "token_value", params['oauth_token']
65
+ assert_equal "HMAC-SHA1", params['oauth_signature_method']
66
+ assert_equal "signature_here", params['oauth_signature']
67
+ assert_equal "1240004133", params['oauth_timestamp']
68
+ assert_equal "nonce", params['oauth_nonce']
69
+ assert_equal "1.0", params['oauth_version']
70
+ end
49
71
  end
@@ -1,13 +1,9 @@
1
1
  require File.expand_path('../test_helper', __FILE__)
2
2
 
3
3
  begin
4
- require 'oauth/request_proxy/typhoeus_request'
5
- require 'typhoeus'
6
- rescue LoadError => e
7
- warn "! problem loading typhoeus, skipping these tests: #{e}"
8
- return
9
- end
10
4
 
5
+ require 'oauth/request_proxy/typhoeus_request'
6
+ require 'typhoeus'
11
7
 
12
8
  class TyphoeusRequestProxyTest < Test::Unit::TestCase
13
9
 
@@ -78,3 +74,8 @@ class TyphoeusRequestProxyTest < Test::Unit::TestCase
78
74
  assert_equal 'POST', request_proxy.method
79
75
  end
80
76
  end
77
+
78
+ rescue LoadError => e
79
+ warn "! problem loading typhoeus, skipping these tests: #{e}"
80
+ end
81
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oauth
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 3
10
- version: 0.4.3
9
+ - 4
10
+ version: 0.4.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pelle Braendgaard
@@ -22,7 +22,7 @@ autorequire:
22
22
  bindir: bin
23
23
  cert_chain: []
24
24
 
25
- date: 2010-09-01 00:00:00 -07:00
25
+ date: 2010-10-31 00:00:00 -07:00
26
26
  default_executable: oauth
27
27
  dependencies:
28
28
  - !ruby/object:Gem::Dependency
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirement: &id001 !ruby/object:Gem::Requirement
32
32
  none: false
33
33
  requirements:
34
- - - "="
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
- hash: 19
36
+ hash: 9
37
37
  segments:
38
38
  - 2
39
39
  - 3
40
- - 8
41
- version: 2.3.8
40
+ - 5
41
+ version: 2.3.5
42
42
  type: :development
43
43
  version_requirements: *id001
44
44
  - !ruby/object:Gem::Dependency