oauth 0.4.4 → 0.4.5

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.

File without changes
data/Gemfile CHANGED
@@ -1,13 +1,16 @@
1
- source :gemcutter
1
+ source :rubygems
2
+
2
3
 
3
4
  group :development do
5
+ gem 'rake'
4
6
  gem 'jeweler'
5
7
  end
6
8
 
7
9
  group :test do
8
- gem 'actionpack', '2.3.8'
10
+ gem 'actionpack', '~>2.3.8'
9
11
  gem 'mocha', '>=0.9.8'
10
12
  gem 'typhoeus', '>=0.1.13'
11
13
  gem 'em-http-request', "0.2.11"
12
14
  gem 'curb', ">= 0.6.6.0"
15
+ gem 'webmock'
13
16
  end
@@ -6,6 +6,7 @@ GEM
6
6
  rack (~> 1.1.0)
7
7
  activesupport (2.3.8)
8
8
  addressable (2.2.0)
9
+ crack (0.1.8)
9
10
  curb (0.7.7.1)
10
11
  em-http-request (0.2.11)
11
12
  addressable (>= 2.0.0)
@@ -27,14 +28,19 @@ GEM
27
28
  json_pure (>= 1.1.7)
28
29
  typhoeus (0.1.31)
29
30
  rack
31
+ webmock (1.3.5)
32
+ addressable (>= 2.1.1)
33
+ crack (>= 0.1.7)
30
34
 
31
35
  PLATFORMS
32
36
  ruby
33
37
 
34
38
  DEPENDENCIES
35
- actionpack (= 2.3.8)
39
+ actionpack (~> 2.3.8)
36
40
  curb (>= 0.6.6.0)
37
41
  em-http-request (= 0.2.11)
38
42
  jeweler
39
43
  mocha (>= 0.9.8)
44
+ rake
40
45
  typhoeus (>= 0.1.13)
46
+ webmock
data/HISTORY CHANGED
@@ -1,3 +1,13 @@
1
+ === 0.4.5 2011-06-25
2
+
3
+ * Add explicit require for rsa/sha1 (Juris Galang)
4
+ * Use webmock to mock all http-requests in tests (Adrian Feldman)
5
+ * Add gemtest support (Adrian Feldman)
6
+ * Fix POST Requests with Typhoeus proxy (niedhui)
7
+ * Mention Typhoeus require in the README (Kim Ahlström)
8
+ * Fix incorrect hardcoded port (Ian Taylor)
9
+ * Use Net::HTTPGenericRequest (Jakub Kuźma)
10
+
1
11
  === 0.4.4 2010-10-31
2
12
 
3
13
  * Fix LoadError rescue in tests: return can't be used in this context (Hans de Graaff)
@@ -20,15 +20,19 @@ As a matter of fact it has been pulled out from an OAuth Rails Plugin http://cod
20
20
 
21
21
  == Demonstration of usage
22
22
 
23
+ We need to specify the oauth_callback url explicitly, otherwise it defaults to "oob" (Out of Band)
24
+
25
+ @callback_url = "http://127.0.0.1:3000/oauth/callback"
26
+
23
27
  Create a new consumer instance by passing it a configuration hash:
24
28
 
25
29
  @consumer = OAuth::Consumer.new("key","secret", :site => "https://agree2")
26
30
 
27
31
  Start the process by requesting a token
28
32
 
29
- @request_token = @consumer.get_request_token
33
+ @request_token = @consumer.get_request_token(:oauth_callback => @callback_url)
30
34
  session[:request_token] = @request_token
31
- redirect_to @request_token.authorize_url
35
+ redirect_to @request_token.authorize_url(:oauth_callback => @callback_url)
32
36
 
33
37
  When user returns create an access_token
34
38
 
@@ -37,6 +41,7 @@ When user returns create an access_token
37
41
 
38
42
  Now that you have an access token, you can use Typhoeus to interact with the OAuth provider if you choose.
39
43
 
44
+ require 'oauth/request_proxy/typhoeus_request'
40
45
  oauth_params = {:consumer => oauth_consumer, :token => access_token}
41
46
  hydra = Typhoeus::Hydra.new
42
47
  req = Typhoeus::Request.new(uri, options)
data/Rakefile CHANGED
@@ -18,6 +18,8 @@ begin
18
18
  s.add_development_dependency(%q<typhoeus>, [">= 0.1.13"])
19
19
  s.add_development_dependency(%q<em-http-request>, [">= 0.2.10"])
20
20
  s.add_development_dependency(%q<curb>, [">= 0.6.6.0"])
21
+
22
+ s.files.include '.gemtest'
21
23
  end
22
24
  Jeweler::GemcutterTasks.new
23
25
  rescue LoadError
@@ -26,7 +28,7 @@ end
26
28
 
27
29
  Rake::TestTask.new do |t|
28
30
  t.libs << "test"
29
- t.test_files = FileList['test/*test*.rb']
31
+ t.test_files = FileList['test/**/*test*.rb']
30
32
  t.verbose = true
31
33
  end
32
34
 
@@ -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.4"
4
+ VERSION = "0.4.5"
5
5
  end
6
6
 
7
7
  require 'oauth/oauth'
@@ -9,4 +9,5 @@ require 'oauth/core_ext'
9
9
 
10
10
  require 'oauth/client/helper'
11
11
  require 'oauth/signature/hmac/sha1'
12
+ require 'oauth/signature/rsa/sha1'
12
13
  require 'oauth/request_proxy/mock_request'
@@ -12,7 +12,7 @@ module ActionController
12
12
  if defined? ActionDispatch
13
13
  def process_with_new_base_test(request, response=nil)
14
14
  request.apply_oauth! if request.respond_to?(:apply_oauth!)
15
- super(request, response)
15
+ super(request, response)
16
16
  end
17
17
  else
18
18
  def process_with_oauth(request, response=nil)
@@ -2,7 +2,7 @@ require 'oauth/helper'
2
2
  require 'oauth/client/helper'
3
3
  require 'oauth/request_proxy/net_http'
4
4
 
5
- class Net::HTTPRequest
5
+ class Net::HTTPGenericRequest
6
6
  include OAuth::Helper
7
7
 
8
8
  attr_reader :oauth_helper
@@ -69,8 +69,9 @@ private
69
69
  uri.port = http.port
70
70
 
71
71
  if options[:request_endpoint] && options[:site]
72
+ is_https = options[:site].match(%r(^https://))
72
73
  uri.host = options[:site].gsub(%r(^https?://), '')
73
- uri.port = 80
74
+ uri.port ||= is_https ? 443 : 80
74
75
  end
75
76
 
76
77
  if http.respond_to?(:use_ssl?) && http.use_ssl?
@@ -83,7 +84,7 @@ private
83
84
  end
84
85
 
85
86
  def oauth_body_hash_required?
86
- request_body_permitted? && content_type != "application/x-www-form-urlencoded"
87
+ request_body_permitted? && !content_type.to_s.downcase.start_with?("application/x-www-form-urlencoded")
87
88
  end
88
89
 
89
90
  def set_oauth_header
@@ -212,7 +212,9 @@ module OAuth
212
212
  end
213
213
  when (300..399)
214
214
  # this is a redirect
215
- response.error!
215
+ uri = URI.parse(response.header['location'])
216
+ response.error! if uri.path == path # careful of those infinite redirects
217
+ self.token_request(http_method, uri.path, token, request_options, arguments)
216
218
  when (400..499)
217
219
  raise OAuth::Unauthorized, response
218
220
  else
@@ -36,7 +36,7 @@ module OAuth::RequestProxy
36
36
  params << header_params.to_query
37
37
  params << request.query_string unless query_string_blank?
38
38
 
39
- if request.post? && request.content_type == Mime::Type.lookup("application/x-www-form-urlencoded")
39
+ if request.post? && request.content_type.to_s.downcase.start_with?("application/x-www-form-urlencoded")
40
40
  params << request.raw_post
41
41
  end
42
42
  end
@@ -42,7 +42,7 @@ module OAuth::RequestProxy::Curl
42
42
  post_body = {}
43
43
 
44
44
  # Post params are only used if posting form data
45
- if (request.headers['Content-Type'] && request.headers['Content-Type'].downcase == 'application/x-www-form-urlencoded')
45
+ if (request.headers['Content-Type'] && request.headers['Content-Type'].to_s.downcase.start_with?("application/x-www-form-urlencoded"))
46
46
 
47
47
  request.post_body.split("&").each do |str|
48
48
  param = str.split("=")
@@ -41,7 +41,7 @@ module OAuth::RequestProxy::EventMachine
41
41
 
42
42
  def post_parameters
43
43
  headers = request.options[:head] || {}
44
- form_encoded = headers['Content-Type'].to_s.downcase == 'application/x-www-form-urlencoded'
44
+ form_encoded = headers['Content-Type'].to_s.downcase.start_with?("application/x-www-form-urlencoded")
45
45
  if ['POST', 'PUT'].include?(method) && form_encoded
46
46
  CGI.parse(request.normalize_body.to_s)
47
47
  else
@@ -6,7 +6,7 @@ require 'cgi'
6
6
  module OAuth::RequestProxy::Net
7
7
  module HTTP
8
8
  class HTTPRequest < OAuth::RequestProxy::Base
9
- proxies ::Net::HTTPRequest
9
+ proxies ::Net::HTTPGenericRequest
10
10
 
11
11
  def method
12
12
  request.method
@@ -52,7 +52,7 @@ module OAuth::RequestProxy::Net
52
52
  end
53
53
 
54
54
  def form_url_encoded?
55
- request['Content-Type'] != nil && request['Content-Type'].downcase == 'application/x-www-form-urlencoded'
55
+ request['Content-Type'] != nil && request['Content-Type'].to_s.downcase.start_with?('application/x-www-form-urlencoded')
56
56
  end
57
57
 
58
58
  def query_params
@@ -34,7 +34,11 @@ module OAuth::RequestProxy
34
34
  end
35
35
 
36
36
  def request_params
37
- request.POST
37
+ if request.content_type and request.content_type.to_s.downcase.start_with?("application/x-www-form-urlencoded")
38
+ request.POST
39
+ else
40
+ {}
41
+ end
38
42
  end
39
43
  end
40
44
  end
@@ -38,13 +38,13 @@ module OAuth::RequestProxy::Typhoeus
38
38
 
39
39
  def query_parameters
40
40
  query = URI.parse(request.url).query
41
- return(query ? CGI.parse(query) : {})
41
+ query ? CGI.parse(query) : {}
42
42
  end
43
43
 
44
44
  def post_parameters
45
45
  # Post params are only used if posting form data
46
- if(method == 'POST' && request.headers['Content-Type'] && request.headers['Content-Type'].downcase == 'application/x-www-form-urlencoded')
47
- request.body || {}
46
+ if method == 'POST'
47
+ OAuth::Helper.stringify_keys(request.params || {})
48
48
  else
49
49
  {}
50
50
  end
@@ -1,153 +1,125 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{oauth}
8
- s.version = "0.4.4"
8
+ s.version = "0.4.5"
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-10-31}
12
+ s.date = %q{2011-06-25}
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}
16
16
  s.executables = ["oauth"]
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE",
19
- "README.rdoc",
20
- "TODO"
19
+ "README.rdoc",
20
+ "TODO"
21
21
  ]
22
22
  s.files = [
23
- ".gitignore",
24
- "Gemfile",
25
- "Gemfile.lock",
26
- "HISTORY",
27
- "LICENSE",
28
- "README.rdoc",
29
- "Rakefile",
30
- "TODO",
31
- "bin/oauth",
32
- "examples/yql.rb",
33
- "lib/digest/hmac.rb",
34
- "lib/oauth.rb",
35
- "lib/oauth/cli.rb",
36
- "lib/oauth/client.rb",
37
- "lib/oauth/client/action_controller_request.rb",
38
- "lib/oauth/client/em_http.rb",
39
- "lib/oauth/client/helper.rb",
40
- "lib/oauth/client/net_http.rb",
41
- "lib/oauth/consumer.rb",
42
- "lib/oauth/core_ext.rb",
43
- "lib/oauth/errors.rb",
44
- "lib/oauth/errors/error.rb",
45
- "lib/oauth/errors/problem.rb",
46
- "lib/oauth/errors/unauthorized.rb",
47
- "lib/oauth/helper.rb",
48
- "lib/oauth/oauth.rb",
49
- "lib/oauth/oauth_test_helper.rb",
50
- "lib/oauth/request_proxy.rb",
51
- "lib/oauth/request_proxy/action_controller_request.rb",
52
- "lib/oauth/request_proxy/base.rb",
53
- "lib/oauth/request_proxy/curb_request.rb",
54
- "lib/oauth/request_proxy/em_http_request.rb",
55
- "lib/oauth/request_proxy/jabber_request.rb",
56
- "lib/oauth/request_proxy/mock_request.rb",
57
- "lib/oauth/request_proxy/net_http.rb",
58
- "lib/oauth/request_proxy/rack_request.rb",
59
- "lib/oauth/request_proxy/typhoeus_request.rb",
60
- "lib/oauth/server.rb",
61
- "lib/oauth/signature.rb",
62
- "lib/oauth/signature/base.rb",
63
- "lib/oauth/signature/hmac/base.rb",
64
- "lib/oauth/signature/hmac/md5.rb",
65
- "lib/oauth/signature/hmac/rmd160.rb",
66
- "lib/oauth/signature/hmac/sha1.rb",
67
- "lib/oauth/signature/hmac/sha2.rb",
68
- "lib/oauth/signature/md5.rb",
69
- "lib/oauth/signature/plaintext.rb",
70
- "lib/oauth/signature/rsa/sha1.rb",
71
- "lib/oauth/signature/sha1.rb",
72
- "lib/oauth/token.rb",
73
- "lib/oauth/tokens/access_token.rb",
74
- "lib/oauth/tokens/consumer_token.rb",
75
- "lib/oauth/tokens/request_token.rb",
76
- "lib/oauth/tokens/server_token.rb",
77
- "lib/oauth/tokens/token.rb",
78
- "oauth.gemspec",
79
- "tasks/deployment.rake",
80
- "tasks/environment.rake",
81
- "tasks/website.rake",
82
- "test/cases/oauth_case.rb",
83
- "test/cases/spec/1_0-final/test_construct_request_url.rb",
84
- "test/cases/spec/1_0-final/test_normalize_request_parameters.rb",
85
- "test/cases/spec/1_0-final/test_parameter_encodings.rb",
86
- "test/cases/spec/1_0-final/test_signature_base_strings.rb",
87
- "test/integration/consumer_test.rb",
88
- "test/keys/rsa.cert",
89
- "test/keys/rsa.pem",
90
- "test/test_access_token.rb",
91
- "test/test_action_controller_request_proxy.rb",
92
- "test/test_consumer.rb",
93
- "test/test_curb_request_proxy.rb",
94
- "test/test_em_http_client.rb",
95
- "test/test_em_http_request_proxy.rb",
96
- "test/test_helper.rb",
97
- "test/test_hmac_sha1.rb",
98
- "test/test_net_http_client.rb",
99
- "test/test_net_http_request_proxy.rb",
100
- "test/test_oauth_helper.rb",
101
- "test/test_rack_request_proxy.rb",
102
- "test/test_request_token.rb",
103
- "test/test_rsa_sha1.rb",
104
- "test/test_server.rb",
105
- "test/test_signature.rb",
106
- "test/test_signature_base.rb",
107
- "test/test_signature_plain_text.rb",
108
- "test/test_token.rb",
109
- "test/test_typhoeus_request_proxy.rb"
23
+ ".gemtest",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "HISTORY",
27
+ "LICENSE",
28
+ "README.rdoc",
29
+ "Rakefile",
30
+ "TODO",
31
+ "bin/oauth",
32
+ "examples/yql.rb",
33
+ "lib/digest/hmac.rb",
34
+ "lib/oauth.rb",
35
+ "lib/oauth/cli.rb",
36
+ "lib/oauth/client.rb",
37
+ "lib/oauth/client/action_controller_request.rb",
38
+ "lib/oauth/client/em_http.rb",
39
+ "lib/oauth/client/helper.rb",
40
+ "lib/oauth/client/net_http.rb",
41
+ "lib/oauth/consumer.rb",
42
+ "lib/oauth/core_ext.rb",
43
+ "lib/oauth/errors.rb",
44
+ "lib/oauth/errors/error.rb",
45
+ "lib/oauth/errors/problem.rb",
46
+ "lib/oauth/errors/unauthorized.rb",
47
+ "lib/oauth/helper.rb",
48
+ "lib/oauth/oauth.rb",
49
+ "lib/oauth/oauth_test_helper.rb",
50
+ "lib/oauth/request_proxy.rb",
51
+ "lib/oauth/request_proxy/action_controller_request.rb",
52
+ "lib/oauth/request_proxy/base.rb",
53
+ "lib/oauth/request_proxy/curb_request.rb",
54
+ "lib/oauth/request_proxy/em_http_request.rb",
55
+ "lib/oauth/request_proxy/jabber_request.rb",
56
+ "lib/oauth/request_proxy/mock_request.rb",
57
+ "lib/oauth/request_proxy/net_http.rb",
58
+ "lib/oauth/request_proxy/rack_request.rb",
59
+ "lib/oauth/request_proxy/typhoeus_request.rb",
60
+ "lib/oauth/server.rb",
61
+ "lib/oauth/signature.rb",
62
+ "lib/oauth/signature/base.rb",
63
+ "lib/oauth/signature/hmac/base.rb",
64
+ "lib/oauth/signature/hmac/md5.rb",
65
+ "lib/oauth/signature/hmac/rmd160.rb",
66
+ "lib/oauth/signature/hmac/sha1.rb",
67
+ "lib/oauth/signature/hmac/sha2.rb",
68
+ "lib/oauth/signature/md5.rb",
69
+ "lib/oauth/signature/plaintext.rb",
70
+ "lib/oauth/signature/rsa/sha1.rb",
71
+ "lib/oauth/signature/sha1.rb",
72
+ "lib/oauth/token.rb",
73
+ "lib/oauth/tokens/access_token.rb",
74
+ "lib/oauth/tokens/consumer_token.rb",
75
+ "lib/oauth/tokens/request_token.rb",
76
+ "lib/oauth/tokens/server_token.rb",
77
+ "lib/oauth/tokens/token.rb",
78
+ "oauth.gemspec",
79
+ "tasks/deployment.rake",
80
+ "tasks/environment.rake",
81
+ "tasks/website.rake",
82
+ "test/cases/oauth_case.rb",
83
+ "test/cases/spec/1_0-final/test_construct_request_url.rb",
84
+ "test/cases/spec/1_0-final/test_normalize_request_parameters.rb",
85
+ "test/cases/spec/1_0-final/test_parameter_encodings.rb",
86
+ "test/cases/spec/1_0-final/test_signature_base_strings.rb",
87
+ "test/integration/consumer_test.rb",
88
+ "test/keys/rsa.cert",
89
+ "test/keys/rsa.pem",
90
+ "test/test_access_token.rb",
91
+ "test/test_action_controller_request_proxy.rb",
92
+ "test/test_consumer.rb",
93
+ "test/test_curb_request_proxy.rb",
94
+ "test/test_em_http_client.rb",
95
+ "test/test_em_http_request_proxy.rb",
96
+ "test/test_helper.rb",
97
+ "test/test_hmac_sha1.rb",
98
+ "test/test_net_http_client.rb",
99
+ "test/test_net_http_request_proxy.rb",
100
+ "test/test_oauth_helper.rb",
101
+ "test/test_rack_request_proxy.rb",
102
+ "test/test_request_token.rb",
103
+ "test/test_rsa_sha1.rb",
104
+ "test/test_server.rb",
105
+ "test/test_signature.rb",
106
+ "test/test_signature_base.rb",
107
+ "test/test_signature_plain_text.rb",
108
+ "test/test_token.rb",
109
+ "test/test_typhoeus_request_proxy.rb"
110
110
  ]
111
- s.rdoc_options = ["--charset=UTF-8"]
112
111
  s.require_paths = ["lib"]
113
112
  s.rubyforge_project = %q{oauth}
114
113
  s.rubygems_version = %q{1.3.7}
115
114
  s.summary = %q{OAuth Core Ruby implementation}
116
- s.test_files = [
117
- "test/cases/oauth_case.rb",
118
- "test/cases/spec/1_0-final/test_construct_request_url.rb",
119
- "test/cases/spec/1_0-final/test_normalize_request_parameters.rb",
120
- "test/cases/spec/1_0-final/test_parameter_encodings.rb",
121
- "test/cases/spec/1_0-final/test_signature_base_strings.rb",
122
- "test/integration/consumer_test.rb",
123
- "test/test_access_token.rb",
124
- "test/test_action_controller_request_proxy.rb",
125
- "test/test_consumer.rb",
126
- "test/test_curb_request_proxy.rb",
127
- "test/test_em_http_client.rb",
128
- "test/test_em_http_request_proxy.rb",
129
- "test/test_helper.rb",
130
- "test/test_hmac_sha1.rb",
131
- "test/test_net_http_client.rb",
132
- "test/test_net_http_request_proxy.rb",
133
- "test/test_oauth_helper.rb",
134
- "test/test_rack_request_proxy.rb",
135
- "test/test_request_token.rb",
136
- "test/test_rsa_sha1.rb",
137
- "test/test_server.rb",
138
- "test/test_signature.rb",
139
- "test/test_signature_base.rb",
140
- "test/test_signature_plain_text.rb",
141
- "test/test_token.rb",
142
- "test/test_typhoeus_request_proxy.rb",
143
- "examples/yql.rb"
144
- ]
145
115
 
146
116
  if s.respond_to? :specification_version then
147
117
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
148
118
  s.specification_version = 3
149
119
 
150
120
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
121
+ s.add_development_dependency(%q<rake>, [">= 0"])
122
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
151
123
  s.add_development_dependency(%q<actionpack>, [">= 2.3.5"])
152
124
  s.add_development_dependency(%q<rack>, [">= 1.0.0"])
153
125
  s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
@@ -155,6 +127,8 @@ Gem::Specification.new do |s|
155
127
  s.add_development_dependency(%q<em-http-request>, [">= 0.2.10"])
156
128
  s.add_development_dependency(%q<curb>, [">= 0.6.6.0"])
157
129
  else
130
+ s.add_dependency(%q<rake>, [">= 0"])
131
+ s.add_dependency(%q<jeweler>, [">= 0"])
158
132
  s.add_dependency(%q<actionpack>, [">= 2.3.5"])
159
133
  s.add_dependency(%q<rack>, [">= 1.0.0"])
160
134
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
@@ -163,6 +137,8 @@ Gem::Specification.new do |s|
163
137
  s.add_dependency(%q<curb>, [">= 0.6.6.0"])
164
138
  end
165
139
  else
140
+ s.add_dependency(%q<rake>, [">= 0"])
141
+ s.add_dependency(%q<jeweler>, [">= 0"])
166
142
  s.add_dependency(%q<actionpack>, [">= 2.3.5"])
167
143
  s.add_dependency(%q<rack>, [">= 1.0.0"])
168
144
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
@@ -28,7 +28,7 @@ module Integration
28
28
 
29
29
  assert_equal 'GET', request.method
30
30
  assert_equal '/test?key=value', request.path
31
- 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
31
+ 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\"".delete(',').split.sort, request['authorization'].delete(',').split.sort
32
32
  end
33
33
 
34
34
  def test_that_setting_signature_method_on_consumer_effects_signing
@@ -76,7 +76,7 @@ module Integration
76
76
  assert_equal 'POST', request.method
77
77
  assert_equal '/test', request.path
78
78
  assert_equal 'key=value', request.body
79
- 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
79
+ 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\"".delete(',').split.sort, request['authorization'].delete(',').split.sort
80
80
  end
81
81
 
82
82
  def test_that_signing_post_params_works
@@ -95,7 +95,7 @@ module Integration
95
95
 
96
96
  assert_equal 'GET', request.method
97
97
  assert_equal '/test?key=value', request.path
98
- 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
98
+ 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\"".delete(',').split.sort, request['authorization'].delete(',').split.sort
99
99
  end
100
100
 
101
101
  def test_that_using_auth_headers_on_post_on_create_signed_requests_works
@@ -103,7 +103,7 @@ module Integration
103
103
  assert_equal 'POST', request.method
104
104
  assert_equal '/test', request.path
105
105
  assert_equal 'key=value', request.body
106
- 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
106
+ 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\"".delete(',').split.sort, request['authorization'].delete(',').split.sort
107
107
  end
108
108
 
109
109
  def test_that_signing_post_params_works_2
@@ -116,6 +116,8 @@ module Integration
116
116
  end
117
117
 
118
118
  def test_step_by_step_token_request
119
+ stub_test_ie
120
+
119
121
  @consumer=OAuth::Consumer.new(
120
122
  "key",
121
123
  "secret",
@@ -141,6 +143,8 @@ module Integration
141
143
  end
142
144
 
143
145
  def test_get_token_sequence
146
+ stub_test_ie
147
+
144
148
  @consumer=OAuth::Consumer.new(
145
149
  "key",
146
150
  "secret",
@@ -180,6 +184,8 @@ module Integration
180
184
  end
181
185
 
182
186
  def test_get_token_sequence_using_fqdn
187
+ stub_test_ie
188
+
183
189
  @consumer=OAuth::Consumer.new(
184
190
  "key",
185
191
  "secret",
@@ -238,6 +244,8 @@ module Integration
238
244
  # end
239
245
  #
240
246
  def test_get_request_token_with_custom_arguments
247
+ stub_test_ie
248
+
241
249
  @consumer=OAuth::Consumer.new(
242
250
  "key",
243
251
  "secret",
@@ -248,20 +256,15 @@ module Integration
248
256
  :authorize_path=>"/oauth/example/authorize.php"
249
257
  })
250
258
 
251
-
252
- debug = ""
253
- @consumer.http.set_debug_output(debug)
254
-
255
- # get_request_token should receive our custom request_options and *arguments parameters from get_request_token.
256
259
  @consumer.get_request_token({}, {:scope => "http://www.google.com/calendar/feeds http://picasaweb.google.com/data"})
257
260
 
258
261
  # Because this is a POST request, create_http_request should take the first element of *arguments
259
262
  # and turn it into URL-encoded data in the body of the POST.
260
- assert_match( /^<- "scope=http%3a%2f%2fwww.google.com%2fcalendar%2ffeeds%20http%3a%2f%2fpicasaweb.google.com%2fdata"/,
261
- debug)
262
263
  end
263
264
 
264
265
  def test_post_with_body_stream
266
+ stub_test_ie
267
+
265
268
  @consumer=OAuth::Consumer.new(
266
269
  "key",
267
270
  "secret",
@@ -1,4 +1,4 @@
1
- gem 'actionpack', '2.3.8'
1
+ gem 'actionpack', '~> 2.3.8'
2
2
  require File.expand_path('../test_helper', __FILE__)
3
3
 
4
4
  require 'oauth/request_proxy/action_controller_request'
@@ -101,6 +101,18 @@ class ConsumerTest < Test::Unit::TestCase
101
101
  assert_equal 'secret', hash[:oauth_token_secret]
102
102
  end
103
103
 
104
+ def test_token_request_follows_redirect
105
+ redirect_url = @request_uri.clone
106
+ redirect_url.path = "/oauth/example/request_token_redirect.php"
107
+ stub_request(:get, /.*#{@request_uri.path}/).to_return(:status => 301, :headers => {'Location' => redirect_url.to_s})
108
+ stub_request(:get, /.*#{redirect_url.path}/).to_return(:body => "oauth_token=token&oauth_token_secret=secret")
109
+
110
+ hash = @consumer.token_request(:get, @request_uri.path) {{ :oauth_token => 'token', :oauth_token_secret => 'secret' }}
111
+
112
+ assert_equal 'token', hash[:oauth_token]
113
+ assert_equal 'secret', hash[:oauth_token_secret]
114
+ end
115
+
104
116
  def test_that_can_provide_a_block_to_interpret_a_request_token_response
105
117
  @consumer.expects(:request).returns(create_stub_http_response)
106
118
 
@@ -107,7 +107,7 @@ class EmHttpRequestProxyTest < Test::Unit::TestCase
107
107
  arguments = opts.delete(:proxy_options) || {}
108
108
  OAuth::RequestProxy.proxy(create_client(opts), arguments)
109
109
  end
110
-
110
+
111
111
  end
112
112
 
113
113
  rescue LoadError => e
@@ -5,9 +5,9 @@ $LOAD_PATH << File.dirname(__FILE__) + '/../lib/'
5
5
  require 'oauth'
6
6
  require 'mocha'
7
7
  require 'stringio'
8
+ require 'webmock/test_unit'
8
9
 
9
10
  class Test::Unit::TestCase
10
-
11
11
  def assert_matching_headers(expected, actual)
12
12
  # transform into sorted arrays
13
13
  auth_intro, auth_params = actual.split(' ', 2)
@@ -17,4 +17,10 @@ class Test::Unit::TestCase
17
17
  assert_equal expected, auth_params
18
18
  end
19
19
 
20
+ def stub_test_ie
21
+ stub_request(:any, "http://term.ie/oauth/example/request_token.php").to_return(:body => "oauth_token=requestkey&oauth_token_secret=requestsecret")
22
+ stub_request(:post, "http://term.ie/oauth/example/access_token.php").to_return(:body => "oauth_token=accesskey&oauth_token_secret=accesssecret")
23
+ stub_request(:get, %r{http://term\.ie/oauth/example/echo_api\.php\?.+}).to_return(lambda {|request| {:body => request.uri.query}})
24
+ stub_request(:post, "http://term.ie/oauth/example/echo_api.php").to_return(lambda {|request| {:body => request.body}})
25
+ end
20
26
  end
@@ -205,6 +205,9 @@ class NetHTTPClientTest < Test::Unit::TestCase
205
205
  end
206
206
 
207
207
  def test_step_by_step_token_request
208
+ token_response = "oauth_token=requestkey&oauth_token_secret=requestsecret"
209
+ stub_request(:get, %r{http://term\.ie/oauth/example/request_token\.php(\?.*)?}).to_return(:body => token_response)
210
+
208
211
  consumer=OAuth::Consumer.new(
209
212
  "key",
210
213
  "secret")
@@ -227,7 +230,7 @@ class NetHTTPClientTest < Test::Unit::TestCase
227
230
  response=http.request(request)
228
231
  assert_equal "200",response.code
229
232
  # assert_equal request['authorization'],response.body
230
- assert_equal "oauth_token=requestkey&oauth_token_secret=requestsecret",response.body
233
+ assert_equal token_response, response.body
231
234
  end
232
235
 
233
236
  def test_that_put_bodies_signed
@@ -30,7 +30,7 @@ class TyphoeusRequestProxyTest < Test::Unit::TestCase
30
30
 
31
31
  def test_that_proxy_simple_post_request_works_with_form_data
32
32
  request = Typhoeus::Request.new('/test', :method => :post,
33
- :body => {'key' => 'value'},
33
+ :params => {'key' => 'value'},
34
34
  :headers => {'Content-Type' => 'application/x-www-form-urlencoded'})
35
35
  request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'})
36
36
 
@@ -52,10 +52,10 @@ class TyphoeusRequestProxyTest < Test::Unit::TestCase
52
52
  end
53
53
 
54
54
  def test_that_proxy_simple_put_request_works_with_form_data
55
- request = Typhoeus::Request.new('/test', :method => :put, :body => {'key' => 'value'})
55
+ request = Typhoeus::Request.new('/test', :method => :put, :params => {'key' => 'value'})
56
56
  request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'})
57
57
 
58
- expected_parameters = {}
58
+ expected_parameters = {'key' => ['value']}
59
59
  assert_equal expected_parameters, request_proxy.parameters_for_signature
60
60
  assert_equal 'http://example.com/test', request_proxy.normalized_uri
61
61
  assert_equal 'PUT', request_proxy.method
@@ -64,7 +64,7 @@ class TyphoeusRequestProxyTest < Test::Unit::TestCase
64
64
  def test_that_proxy_post_request_works_with_mixed_parameter_sources
65
65
  request = Typhoeus::Request.new('/test?key=value',
66
66
  :method => :post,
67
- :body => {'key2' => 'value2'},
67
+ :params => {'key2' => 'value2'},
68
68
  :headers => {'Content-Type' => 'application/x-www-form-urlencoded'})
69
69
  request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value', :parameters => {'key3' => 'value3'}})
70
70
 
@@ -78,4 +78,3 @@ end
78
78
  rescue LoadError => e
79
79
  warn "! problem loading typhoeus, skipping these tests: #{e}"
80
80
  end
81
-
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oauth
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 4
9
- - 4
10
- version: 0.4.4
8
+ - 5
9
+ version: 0.4.5
11
10
  platform: ruby
12
11
  authors:
13
12
  - Pelle Braendgaard
@@ -22,98 +21,117 @@ autorequire:
22
21
  bindir: bin
23
22
  cert_chain: []
24
23
 
25
- date: 2010-10-31 00:00:00 -07:00
24
+ date: 2011-06-25 00:00:00 -07:00
26
25
  default_executable: oauth
27
26
  dependencies:
28
27
  - !ruby/object:Gem::Dependency
29
- name: actionpack
30
- prerelease: false
28
+ name: rake
31
29
  requirement: &id001 !ruby/object:Gem::Requirement
32
30
  none: false
33
31
  requirements:
34
32
  - - ">="
35
33
  - !ruby/object:Gem::Version
36
- hash: 9
34
+ segments:
35
+ - 0
36
+ version: "0"
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: *id001
40
+ - !ruby/object:Gem::Dependency
41
+ name: jeweler
42
+ requirement: &id002 !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ segments:
48
+ - 0
49
+ version: "0"
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: actionpack
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
37
60
  segments:
38
61
  - 2
39
62
  - 3
40
63
  - 5
41
64
  version: 2.3.5
42
65
  type: :development
43
- version_requirements: *id001
66
+ prerelease: false
67
+ version_requirements: *id003
44
68
  - !ruby/object:Gem::Dependency
45
69
  name: rack
46
- prerelease: false
47
- requirement: &id002 !ruby/object:Gem::Requirement
70
+ requirement: &id004 !ruby/object:Gem::Requirement
48
71
  none: false
49
72
  requirements:
50
73
  - - ">="
51
74
  - !ruby/object:Gem::Version
52
- hash: 23
53
75
  segments:
54
76
  - 1
55
77
  - 0
56
78
  - 0
57
79
  version: 1.0.0
58
80
  type: :development
59
- version_requirements: *id002
81
+ prerelease: false
82
+ version_requirements: *id004
60
83
  - !ruby/object:Gem::Dependency
61
84
  name: mocha
62
- prerelease: false
63
- requirement: &id003 !ruby/object:Gem::Requirement
85
+ requirement: &id005 !ruby/object:Gem::Requirement
64
86
  none: false
65
87
  requirements:
66
88
  - - ">="
67
89
  - !ruby/object:Gem::Version
68
- hash: 43
69
90
  segments:
70
91
  - 0
71
92
  - 9
72
93
  - 8
73
94
  version: 0.9.8
74
95
  type: :development
75
- version_requirements: *id003
96
+ prerelease: false
97
+ version_requirements: *id005
76
98
  - !ruby/object:Gem::Dependency
77
99
  name: typhoeus
78
- prerelease: false
79
- requirement: &id004 !ruby/object:Gem::Requirement
100
+ requirement: &id006 !ruby/object:Gem::Requirement
80
101
  none: false
81
102
  requirements:
82
103
  - - ">="
83
104
  - !ruby/object:Gem::Version
84
- hash: 1
85
105
  segments:
86
106
  - 0
87
107
  - 1
88
108
  - 13
89
109
  version: 0.1.13
90
110
  type: :development
91
- version_requirements: *id004
111
+ prerelease: false
112
+ version_requirements: *id006
92
113
  - !ruby/object:Gem::Dependency
93
114
  name: em-http-request
94
- prerelease: false
95
- requirement: &id005 !ruby/object:Gem::Requirement
115
+ requirement: &id007 !ruby/object:Gem::Requirement
96
116
  none: false
97
117
  requirements:
98
118
  - - ">="
99
119
  - !ruby/object:Gem::Version
100
- hash: 3
101
120
  segments:
102
121
  - 0
103
122
  - 2
104
123
  - 10
105
124
  version: 0.2.10
106
125
  type: :development
107
- version_requirements: *id005
126
+ prerelease: false
127
+ version_requirements: *id007
108
128
  - !ruby/object:Gem::Dependency
109
129
  name: curb
110
- prerelease: false
111
- requirement: &id006 !ruby/object:Gem::Requirement
130
+ requirement: &id008 !ruby/object:Gem::Requirement
112
131
  none: false
113
132
  requirements:
114
133
  - - ">="
115
134
  - !ruby/object:Gem::Version
116
- hash: 103
117
135
  segments:
118
136
  - 0
119
137
  - 6
@@ -121,7 +139,8 @@ dependencies:
121
139
  - 0
122
140
  version: 0.6.6.0
123
141
  type: :development
124
- version_requirements: *id006
142
+ prerelease: false
143
+ version_requirements: *id008
125
144
  description: OAuth Core Ruby implementation
126
145
  email: oauth-ruby@googlegroups.com
127
146
  executables:
@@ -133,7 +152,7 @@ extra_rdoc_files:
133
152
  - README.rdoc
134
153
  - TODO
135
154
  files:
136
- - .gitignore
155
+ - .gemtest
137
156
  - Gemfile
138
157
  - Gemfile.lock
139
158
  - HISTORY
@@ -225,8 +244,8 @@ homepage:
225
244
  licenses: []
226
245
 
227
246
  post_install_message:
228
- rdoc_options:
229
- - --charset=UTF-8
247
+ rdoc_options: []
248
+
230
249
  require_paths:
231
250
  - lib
232
251
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -234,7 +253,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
234
253
  requirements:
235
254
  - - ">="
236
255
  - !ruby/object:Gem::Version
237
- hash: 3
238
256
  segments:
239
257
  - 0
240
258
  version: "0"
@@ -243,7 +261,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
261
  requirements:
244
262
  - - ">="
245
263
  - !ruby/object:Gem::Version
246
- hash: 3
247
264
  segments:
248
265
  - 0
249
266
  version: "0"
@@ -254,31 +271,5 @@ rubygems_version: 1.3.7
254
271
  signing_key:
255
272
  specification_version: 3
256
273
  summary: OAuth Core Ruby implementation
257
- test_files:
258
- - test/cases/oauth_case.rb
259
- - test/cases/spec/1_0-final/test_construct_request_url.rb
260
- - test/cases/spec/1_0-final/test_normalize_request_parameters.rb
261
- - test/cases/spec/1_0-final/test_parameter_encodings.rb
262
- - test/cases/spec/1_0-final/test_signature_base_strings.rb
263
- - test/integration/consumer_test.rb
264
- - test/test_access_token.rb
265
- - test/test_action_controller_request_proxy.rb
266
- - test/test_consumer.rb
267
- - test/test_curb_request_proxy.rb
268
- - test/test_em_http_client.rb
269
- - test/test_em_http_request_proxy.rb
270
- - test/test_helper.rb
271
- - test/test_hmac_sha1.rb
272
- - test/test_net_http_client.rb
273
- - test/test_net_http_request_proxy.rb
274
- - test/test_oauth_helper.rb
275
- - test/test_rack_request_proxy.rb
276
- - test/test_request_token.rb
277
- - test/test_rsa_sha1.rb
278
- - test/test_server.rb
279
- - test/test_signature.rb
280
- - test/test_signature_base.rb
281
- - test/test_signature_plain_text.rb
282
- - test/test_token.rb
283
- - test/test_typhoeus_request_proxy.rb
284
- - examples/yql.rb
274
+ test_files: []
275
+
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- pkg/*
2
- _site
3
- .bundle