oauth 0.3.0 → 0.3.1

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.

@@ -1,4 +1,6 @@
1
- Fix in plain text signatures to bug found by Andrew Arrow. Who contributed new new unit tests for plain text sigs.
1
+ == 0.3.1
2
+
3
+ * Michael Wood identified a problem with relative and absolute token request paths. This should now be fixed and is tested for both cases.
2
4
 
3
5
  == 0.3.0
4
6
 
@@ -13,6 +15,7 @@ Fix in plain text signatures to bug found by Andrew Arrow. Who contributed new n
13
15
  * Improved test-cases and compatibility for encoding issues. (Pelle)
14
16
 
15
17
  == 0.2.7 2008-9-10 The lets fix the last release release
18
+ Fix in plain text signatures to bug found by Andrew Arrow. Who contributed new new unit tests for plain text sigs.
16
19
 
17
20
  There was an error in the RSA requests using oauth tokens. Thanks to Philip Lipu Tsai for noticing this.
18
21
 
@@ -91,7 +91,7 @@ module OAuth
91
91
  # @request_token=@consumer.get_request_token
92
92
  #
93
93
  def get_request_token(request_options={}, *arguments)
94
- response=token_request(http_method,request_token_url, nil, request_options, *arguments)
94
+ response=token_request(http_method,(request_token_url? ? request_token_url : request_token_path), nil, request_options, *arguments)
95
95
  OAuth::RequestToken.new(self,response[:oauth_token],response[:oauth_token_secret])
96
96
  end
97
97
 
@@ -103,7 +103,14 @@ module OAuth
103
103
  # @consumer.request(:post,'/people',@token,{},@person.to_xml,{ 'Content-Type' => 'application/xml' })
104
104
  #
105
105
  def request(http_method,path, token=nil,request_options={},*arguments)
106
- http.request(create_signed_request(http_method,path,token,request_options,*arguments))
106
+ if path=~/^\//
107
+ _http=http
108
+ else
109
+ _http=create_http(path)
110
+ _uri=URI.parse(path)
111
+ path="#{_uri.path}#{_uri.query ? "?#{_uri.query}" : ""}"
112
+ end
113
+ _http.request(create_signed_request(http_method,path,token,request_options,*arguments))
107
114
  end
108
115
 
109
116
  # Creates and signs an http request.
@@ -159,20 +166,37 @@ module OAuth
159
166
  @options[:request_token_url]||site+request_token_path
160
167
  end
161
168
 
169
+ def request_token_url?
170
+ @options[:request_token_url]!=nil
171
+ end
172
+
162
173
  def authorize_url
163
174
  @options[:authorize_url]||site+authorize_path
164
175
  end
176
+
177
+ def authorize_url?
178
+ @options[:authorize_url]!=nil
179
+ end
165
180
 
166
181
  def access_token_url
167
182
  @options[:access_token_url]||site+access_token_path
168
183
  end
169
184
 
185
+ def access_token_url?
186
+ @options[:access_token_url]!=nil
187
+ end
188
+
170
189
  protected
171
190
 
172
191
  #Instantiates the http object
173
- def create_http
174
- http_object=Net::HTTP.new(uri.host, uri.port)
175
- http_object.use_ssl = true if uri.scheme=="https"
192
+ def create_http(_url=nil)
193
+ if _url.nil?||_url[0]=~/^\//
194
+ our_uri=URI.parse(site)
195
+ else
196
+ our_uri=URI.parse(_url)
197
+ end
198
+ http_object=Net::HTTP.new(our_uri.host, our_uri.port)
199
+ http_object.use_ssl = true if our_uri.scheme=="https"
176
200
  http_object
177
201
  end
178
202
 
@@ -62,7 +62,7 @@ module OAuth
62
62
 
63
63
  # exchange for AccessToken on server
64
64
  def get_access_token(options={})
65
- response=consumer.token_request(consumer.http_method,consumer.access_token_url,self,options)
65
+ response=consumer.token_request(consumer.http_method,(consumer.access_token_url? ? consumer.access_token_url : consumer.access_token_path),self,options)
66
66
  OAuth::AccessToken.new(consumer,response[:oauth_token],response[:oauth_token_secret])
67
67
  end
68
68
  end
@@ -1,3 +1,3 @@
1
1
  module OAuth #:nodoc:
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{oauth}
5
- s.version = "0.3.0"
5
+ s.version = "0.3.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons"]
9
- s.date = %q{2009-01-25}
9
+ s.date = %q{2009-01-26}
10
10
  s.default_executable = %q{oauth}
11
11
  s.description = %q{OAuth Core Ruby implementation}
12
12
  s.email = %q{pelleb@gmail.com}
@@ -208,6 +208,51 @@ class ConsumerTest < Test::Unit::TestCase
208
208
  :access_token_path=>"/oauth/example/access_token.php",
209
209
  :authorize_path=>"/oauth/example/authorize.php"
210
210
  })
211
+ assert_equal "http://term.ie/oauth/example/request_token.php",@consumer.request_token_url
212
+ assert_equal "http://term.ie/oauth/example/access_token.php",@consumer.access_token_url
213
+
214
+ assert !@consumer.request_token_url?, "Should not use fully qualified request token url"
215
+ assert !@consumer.access_token_url?, "Should not use fully qualified access token url"
216
+ assert !@consumer.authorize_url?, "Should not use fully qualified url"
217
+
218
+ @request_token=@consumer.get_request_token
219
+ assert_not_nil @request_token
220
+ assert_equal "requestkey",@request_token.token
221
+ assert_equal "requestsecret",@request_token.secret
222
+ assert_equal "http://term.ie/oauth/example/authorize.php?oauth_token=requestkey",@request_token.authorize_url
223
+
224
+ @access_token=@request_token.get_access_token
225
+ assert_not_nil @access_token
226
+ assert_equal "accesskey",@access_token.token
227
+ assert_equal "accesssecret",@access_token.secret
228
+
229
+ @response=@access_token.get("/oauth/example/echo_api.php?ok=hello&test=this")
230
+ assert_not_nil @response
231
+ assert_equal "200",@response.code
232
+ assert_equal( "ok=hello&test=this",@response.body)
233
+
234
+ @response=@access_token.post("/oauth/example/echo_api.php",{'ok'=>'hello','test'=>'this'})
235
+ assert_not_nil @response
236
+ assert_equal "200",@response.code
237
+ assert_equal( "ok=hello&test=this",@response.body)
238
+ end
239
+
240
+ def test_get_token_sequence_using_fqdn
241
+ @consumer=OAuth::Consumer.new(
242
+ "key",
243
+ "secret",
244
+ {
245
+ :site=>"http://term.ie",
246
+ :request_token_url=>"http://term.ie/oauth/example/request_token.php",
247
+ :access_token_url=>"http://term.ie/oauth/example/access_token.php",
248
+ :authorize_url=>"http://term.ie/oauth/example/authorize.php"
249
+ })
250
+ assert_equal "http://term.ie/oauth/example/request_token.php",@consumer.request_token_url
251
+ assert_equal "http://term.ie/oauth/example/access_token.php",@consumer.access_token_url
252
+
253
+ assert @consumer.request_token_url?, "Should use fully qualified request token url"
254
+ assert @consumer.access_token_url?, "Should use fully qualified access token url"
255
+ assert @consumer.authorize_url?, "Should use fully qualified url"
211
256
 
212
257
  @request_token=@consumer.get_request_token
213
258
  assert_not_nil @request_token
@@ -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.2.7</a>
36
+ <a href="http://rubyforge.org/projects/oauth" class="numbers">0.3.0</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.0
4
+ version: 0.3.1
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-01-25 00:00:00 -08:00
17
+ date: 2009-01-26 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency