oauth_weshays 0.4.8.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +15 -0
  2. data/.gemtest +0 -0
  3. data/Gemfile +16 -0
  4. data/Gemfile.lock +47 -0
  5. data/HISTORY +173 -0
  6. data/LICENSE +20 -0
  7. data/README.rdoc +75 -0
  8. data/Rakefile +37 -0
  9. data/TODO +32 -0
  10. data/bin/oauth +5 -0
  11. data/examples/yql.rb +44 -0
  12. data/lib/digest/hmac.rb +104 -0
  13. data/lib/oauth/cli.rb +378 -0
  14. data/lib/oauth/client/action_controller_request.rb +65 -0
  15. data/lib/oauth/client/em_http.rb +120 -0
  16. data/lib/oauth/client/helper.rb +91 -0
  17. data/lib/oauth/client/net_http.rb +120 -0
  18. data/lib/oauth/client.rb +4 -0
  19. data/lib/oauth/consumer.rb +389 -0
  20. data/lib/oauth/core_ext.rb +31 -0
  21. data/lib/oauth/errors/error.rb +4 -0
  22. data/lib/oauth/errors/problem.rb +14 -0
  23. data/lib/oauth/errors/unauthorized.rb +12 -0
  24. data/lib/oauth/errors.rb +3 -0
  25. data/lib/oauth/helper.rb +109 -0
  26. data/lib/oauth/oauth.rb +13 -0
  27. data/lib/oauth/oauth_test_helper.rb +25 -0
  28. data/lib/oauth/request_proxy/action_controller_request.rb +62 -0
  29. data/lib/oauth/request_proxy/base.rb +174 -0
  30. data/lib/oauth/request_proxy/curb_request.rb +55 -0
  31. data/lib/oauth/request_proxy/em_http_request.rb +66 -0
  32. data/lib/oauth/request_proxy/jabber_request.rb +41 -0
  33. data/lib/oauth/request_proxy/mock_request.rb +44 -0
  34. data/lib/oauth/request_proxy/net_http.rb +73 -0
  35. data/lib/oauth/request_proxy/rack_request.rb +44 -0
  36. data/lib/oauth/request_proxy/typhoeus_request.rb +53 -0
  37. data/lib/oauth/request_proxy.rb +24 -0
  38. data/lib/oauth/server.rb +66 -0
  39. data/lib/oauth/signature/base.rb +110 -0
  40. data/lib/oauth/signature/hmac/base.rb +15 -0
  41. data/lib/oauth/signature/hmac/md5.rb +8 -0
  42. data/lib/oauth/signature/hmac/rmd160.rb +8 -0
  43. data/lib/oauth/signature/hmac/sha1.rb +9 -0
  44. data/lib/oauth/signature/hmac/sha2.rb +8 -0
  45. data/lib/oauth/signature/md5.rb +13 -0
  46. data/lib/oauth/signature/plaintext.rb +23 -0
  47. data/lib/oauth/signature/rsa/sha1.rb +46 -0
  48. data/lib/oauth/signature/sha1.rb +13 -0
  49. data/lib/oauth/signature.rb +45 -0
  50. data/lib/oauth/token.rb +7 -0
  51. data/lib/oauth/tokens/access_token.rb +71 -0
  52. data/lib/oauth/tokens/consumer_token.rb +33 -0
  53. data/lib/oauth/tokens/request_token.rb +32 -0
  54. data/lib/oauth/tokens/server_token.rb +9 -0
  55. data/lib/oauth/tokens/token.rb +17 -0
  56. data/lib/oauth.rb +13 -0
  57. data/oauth.gemspec +148 -0
  58. data/tasks/deployment.rake +34 -0
  59. data/tasks/environment.rake +7 -0
  60. data/tasks/website.rake +17 -0
  61. data/test/cases/oauth_case.rb +19 -0
  62. data/test/cases/spec/1_0-final/test_construct_request_url.rb +62 -0
  63. data/test/cases/spec/1_0-final/test_normalize_request_parameters.rb +88 -0
  64. data/test/cases/spec/1_0-final/test_parameter_encodings.rb +86 -0
  65. data/test/cases/spec/1_0-final/test_signature_base_strings.rb +77 -0
  66. data/test/integration/consumer_test.rb +307 -0
  67. data/test/keys/rsa.cert +11 -0
  68. data/test/keys/rsa.pem +16 -0
  69. data/test/test_access_token.rb +26 -0
  70. data/test/test_action_controller_request_proxy.rb +133 -0
  71. data/test/test_consumer.rb +220 -0
  72. data/test/test_curb_request_proxy.rb +77 -0
  73. data/test/test_em_http_client.rb +80 -0
  74. data/test/test_em_http_request_proxy.rb +115 -0
  75. data/test/test_helper.rb +28 -0
  76. data/test/test_hmac_sha1.rb +20 -0
  77. data/test/test_net_http_client.rb +292 -0
  78. data/test/test_net_http_request_proxy.rb +72 -0
  79. data/test/test_oauth_helper.rb +94 -0
  80. data/test/test_rack_request_proxy.rb +40 -0
  81. data/test/test_request_token.rb +51 -0
  82. data/test/test_rsa_sha1.rb +59 -0
  83. data/test/test_server.rb +40 -0
  84. data/test/test_signature.rb +22 -0
  85. data/test/test_signature_base.rb +32 -0
  86. data/test/test_signature_plain_text.rb +31 -0
  87. data/test/test_token.rb +14 -0
  88. data/test/test_typhoeus_request_proxy.rb +80 -0
  89. metadata +252 -0
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path('../test_helper', __FILE__)
4
+
5
+ class TestOauth < Test::Unit::TestCase
6
+
7
+ def test_parameter_escaping_kcode_invariant
8
+ ruby19 = RUBY_VERSION =~ /^1\.9/
9
+ old = $KCODE if !ruby19
10
+ begin
11
+ %w(n N e E s S u U).each do |kcode|
12
+ $KCODE = kcode if !ruby19
13
+ assert_equal '%E3%81%82', OAuth::Helper.escape('あ'),
14
+ "Failed to correctly escape Japanese under $KCODE = #{kcode}"
15
+ assert_equal '%C3%A9', OAuth::Helper.escape('é'),
16
+ "Failed to correctly escape e+acute under $KCODE = #{kcode}"
17
+ end
18
+ ensure
19
+ $KCODE = old if !ruby19
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,32 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+ require 'oauth/signature/base'
3
+ require 'net/http'
4
+ class SignatureBaseTest < Test::Unit::TestCase
5
+
6
+ def test_that_initialize_requires_one_request_argument
7
+ assert_raises ArgumentError do
8
+ OAuth::Signature::Base.new()
9
+ end
10
+ end
11
+
12
+ def test_that_initialize_requires_a_valid_request_argument
13
+ request = nil
14
+ assert_raises TypeError do
15
+ OAuth::Signature::Base.new(request) { |token|
16
+ # just a stub
17
+ }
18
+ end
19
+ end
20
+
21
+ def test_that_initialize_succeeds_when_the_request_proxy_is_valid
22
+ # this isn't quite valid, but it will do.
23
+ raw_request = Net::HTTP::Get.new('/test')
24
+ request = OAuth::RequestProxy.proxy(raw_request)
25
+ assert_nothing_raised do
26
+ OAuth::Signature::Base.new(request) { |token|
27
+ # just a stub
28
+ }
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,31 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+ require 'oauth/signature/plaintext'
3
+
4
+ class TestSignaturePlaintext < Test::Unit::TestCase
5
+ def test_that_plaintext_implements_plaintext
6
+ assert OAuth::Signature.available_methods.include?('plaintext')
7
+ end
8
+
9
+ def test_that_get_request_from_oauth_test_cases_produces_matching_signature
10
+ request = Net::HTTP::Get.new('/photos?file=vacation.jpg&size=original&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_token=nnch734d00sl2jdk&oauth_signature=kd94hf93k423kf44%26&oauth_timestamp=1191242096&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=PLAINTEXT')
11
+
12
+ consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03','kd94hf93k423kf44')
13
+ token = OAuth::Token.new('nnch734d00sl2jdk', nil)
14
+
15
+ assert OAuth::Signature.verify(request, { :consumer => consumer,
16
+ :token => token,
17
+ :uri => 'http://photos.example.net/photos' } )
18
+ end
19
+
20
+ def test_that_get_request_from_oauth_test_cases_produces_matching_signature_part_two
21
+ request = Net::HTTP::Get.new('/photos?file=vacation.jpg&size=original&oauth_version=1.0&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_token=nnch734d00sl2jdk&oauth_signature=kd94hf93k423kf44%26pfkkdhi9sl3r4s00&oauth_timestamp=1191242096&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=PLAINTEXT')
22
+
23
+ consumer = OAuth::Consumer.new('dpf43f3p2l4k3l03','kd94hf93k423kf44')
24
+ token = OAuth::Token.new('nnch734d00sl2jdk', 'pfkkdhi9sl3r4s00')
25
+
26
+ assert OAuth::Signature.verify(request, { :consumer => consumer,
27
+ :token => token,
28
+ :uri => 'http://photos.example.net/photos' } )
29
+ end
30
+
31
+ end
@@ -0,0 +1,14 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+ require 'oauth/token'
3
+
4
+ class TestToken < Test::Unit::TestCase
5
+
6
+ def setup
7
+ end
8
+
9
+ def test_token_constructor_produces_valid_token
10
+ token = OAuth::Token.new('xyz', '123')
11
+ assert_equal 'xyz', token.token
12
+ assert_equal '123', token.secret
13
+ end
14
+ end
@@ -0,0 +1,80 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+
3
+ begin
4
+
5
+ require 'oauth/request_proxy/typhoeus_request'
6
+ require 'typhoeus'
7
+
8
+ class TyphoeusRequestProxyTest < Test::Unit::TestCase
9
+
10
+ def test_that_proxy_simple_get_request_works
11
+ request = ::Typhoeus::Request.new('/test?key=value')
12
+ request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value'})
13
+
14
+ expected_parameters = {'key' => ['value']}
15
+ assert_equal expected_parameters, request_proxy.parameters_for_signature
16
+ assert_equal 'http://example.com/test', request_proxy.normalized_uri
17
+ assert_equal 'GET', request_proxy.method
18
+ end
19
+
20
+ def test_that_proxy_simple_post_request_works_with_arguments
21
+ request = Typhoeus::Request.new('/test', :method => :post)
22
+ params = {'key' => 'value'}
23
+ request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params})
24
+
25
+ expected_parameters = {'key' => 'value'}
26
+ assert_equal expected_parameters, request_proxy.parameters_for_signature
27
+ assert_equal 'http://example.com/test', request_proxy.normalized_uri
28
+ assert_equal 'POST', request_proxy.method
29
+ end
30
+
31
+ def test_that_proxy_simple_post_request_works_with_form_data
32
+ request = Typhoeus::Request.new('/test', :method => :post,
33
+ :params => {'key' => 'value'},
34
+ :headers => {'Content-Type' => 'application/x-www-form-urlencoded'})
35
+ request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'})
36
+
37
+ expected_parameters = {'key' => 'value'}
38
+ assert_equal expected_parameters, request_proxy.parameters_for_signature
39
+ assert_equal 'http://example.com/test', request_proxy.normalized_uri
40
+ assert_equal 'POST', request_proxy.method
41
+ end
42
+
43
+ def test_that_proxy_simple_put_request_works_with_arguments
44
+ request = Typhoeus::Request.new('/test', :method => :put)
45
+ params = {'key' => 'value'}
46
+ request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test', :parameters => params})
47
+
48
+ expected_parameters = {'key' => 'value'}
49
+ assert_equal expected_parameters, request_proxy.parameters_for_signature
50
+ assert_equal 'http://example.com/test', request_proxy.normalized_uri
51
+ assert_equal 'PUT', request_proxy.method
52
+ end
53
+
54
+ def test_that_proxy_simple_put_request_works_with_form_data
55
+ request = Typhoeus::Request.new('/test', :method => :put, :params => {'key' => 'value'})
56
+ request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test'})
57
+
58
+ expected_parameters = {'key' => ['value']}
59
+ assert_equal expected_parameters, request_proxy.parameters_for_signature
60
+ assert_equal 'http://example.com/test', request_proxy.normalized_uri
61
+ assert_equal 'PUT', request_proxy.method
62
+ end
63
+
64
+ def test_that_proxy_post_request_works_with_mixed_parameter_sources
65
+ request = Typhoeus::Request.new('/test?key=value',
66
+ :method => :post,
67
+ :params => {'key2' => 'value2'},
68
+ :headers => {'Content-Type' => 'application/x-www-form-urlencoded'})
69
+ request_proxy = OAuth::RequestProxy.proxy(request, {:uri => 'http://example.com/test?key=value', :parameters => {'key3' => 'value3'}})
70
+
71
+ expected_parameters = {'key' => ['value'], 'key2' => 'value2', 'key3' => 'value3'}
72
+ assert_equal expected_parameters, request_proxy.parameters_for_signature
73
+ assert_equal 'http://example.com/test', request_proxy.normalized_uri
74
+ assert_equal 'POST', request_proxy.method
75
+ end
76
+ end
77
+
78
+ rescue LoadError => e
79
+ warn "! problem loading typhoeus, skipping these tests: #{e}"
80
+ end
metadata ADDED
@@ -0,0 +1,252 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: oauth_weshays
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.8.pre
5
+ platform: ruby
6
+ authors:
7
+ - Pelle Braendgaard
8
+ - Blaine Cook
9
+ - Larry Halff
10
+ - Jesse Clark
11
+ - Jon Crosby
12
+ - Seth Fitzsimmons
13
+ - Matt Sanford
14
+ - Aaron Quint
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+ date: 2013-08-01 00:00:00.000000000 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rake
22
+ requirement: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ type: :development
28
+ prerelease: false
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ - !ruby/object:Gem::Dependency
35
+ name: jeweler
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ type: :development
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ - !ruby/object:Gem::Dependency
49
+ name: actionpack
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.3.5
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.3.5
62
+ - !ruby/object:Gem::Dependency
63
+ name: rack
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.0
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: 1.0.0
76
+ - !ruby/object:Gem::Dependency
77
+ name: mocha
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.9.8
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.9.8
90
+ - !ruby/object:Gem::Dependency
91
+ name: typhoeus
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.1.13
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.1.13
104
+ - !ruby/object:Gem::Dependency
105
+ name: em-http-request
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.2.10
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: 0.2.10
118
+ - !ruby/object:Gem::Dependency
119
+ name: curb
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: 0.6.6.0
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: 0.6.6.0
132
+ description: OAuth Core Ruby implementation
133
+ email: oauth-ruby@googlegroups.com
134
+ executables:
135
+ - oauth
136
+ extensions: []
137
+ extra_rdoc_files:
138
+ - LICENSE
139
+ - README.rdoc
140
+ - TODO
141
+ files:
142
+ - .gemtest
143
+ - Gemfile
144
+ - Gemfile.lock
145
+ - HISTORY
146
+ - LICENSE
147
+ - README.rdoc
148
+ - Rakefile
149
+ - TODO
150
+ - bin/oauth
151
+ - examples/yql.rb
152
+ - lib/digest/hmac.rb
153
+ - lib/oauth.rb
154
+ - lib/oauth/cli.rb
155
+ - lib/oauth/client.rb
156
+ - lib/oauth/client/action_controller_request.rb
157
+ - lib/oauth/client/em_http.rb
158
+ - lib/oauth/client/helper.rb
159
+ - lib/oauth/client/net_http.rb
160
+ - lib/oauth/consumer.rb
161
+ - lib/oauth/core_ext.rb
162
+ - lib/oauth/errors.rb
163
+ - lib/oauth/errors/error.rb
164
+ - lib/oauth/errors/problem.rb
165
+ - lib/oauth/errors/unauthorized.rb
166
+ - lib/oauth/helper.rb
167
+ - lib/oauth/oauth.rb
168
+ - lib/oauth/oauth_test_helper.rb
169
+ - lib/oauth/request_proxy.rb
170
+ - lib/oauth/request_proxy/action_controller_request.rb
171
+ - lib/oauth/request_proxy/base.rb
172
+ - lib/oauth/request_proxy/curb_request.rb
173
+ - lib/oauth/request_proxy/em_http_request.rb
174
+ - lib/oauth/request_proxy/jabber_request.rb
175
+ - lib/oauth/request_proxy/mock_request.rb
176
+ - lib/oauth/request_proxy/net_http.rb
177
+ - lib/oauth/request_proxy/rack_request.rb
178
+ - lib/oauth/request_proxy/typhoeus_request.rb
179
+ - lib/oauth/server.rb
180
+ - lib/oauth/signature.rb
181
+ - lib/oauth/signature/base.rb
182
+ - lib/oauth/signature/hmac/base.rb
183
+ - lib/oauth/signature/hmac/md5.rb
184
+ - lib/oauth/signature/hmac/rmd160.rb
185
+ - lib/oauth/signature/hmac/sha1.rb
186
+ - lib/oauth/signature/hmac/sha2.rb
187
+ - lib/oauth/signature/md5.rb
188
+ - lib/oauth/signature/plaintext.rb
189
+ - lib/oauth/signature/rsa/sha1.rb
190
+ - lib/oauth/signature/sha1.rb
191
+ - lib/oauth/token.rb
192
+ - lib/oauth/tokens/access_token.rb
193
+ - lib/oauth/tokens/consumer_token.rb
194
+ - lib/oauth/tokens/request_token.rb
195
+ - lib/oauth/tokens/server_token.rb
196
+ - lib/oauth/tokens/token.rb
197
+ - oauth.gemspec
198
+ - tasks/deployment.rake
199
+ - tasks/environment.rake
200
+ - tasks/website.rake
201
+ - test/cases/oauth_case.rb
202
+ - test/cases/spec/1_0-final/test_construct_request_url.rb
203
+ - test/cases/spec/1_0-final/test_normalize_request_parameters.rb
204
+ - test/cases/spec/1_0-final/test_parameter_encodings.rb
205
+ - test/cases/spec/1_0-final/test_signature_base_strings.rb
206
+ - test/integration/consumer_test.rb
207
+ - test/keys/rsa.cert
208
+ - test/keys/rsa.pem
209
+ - test/test_access_token.rb
210
+ - test/test_action_controller_request_proxy.rb
211
+ - test/test_consumer.rb
212
+ - test/test_curb_request_proxy.rb
213
+ - test/test_em_http_client.rb
214
+ - test/test_em_http_request_proxy.rb
215
+ - test/test_helper.rb
216
+ - test/test_hmac_sha1.rb
217
+ - test/test_net_http_client.rb
218
+ - test/test_net_http_request_proxy.rb
219
+ - test/test_oauth_helper.rb
220
+ - test/test_rack_request_proxy.rb
221
+ - test/test_request_token.rb
222
+ - test/test_rsa_sha1.rb
223
+ - test/test_server.rb
224
+ - test/test_signature.rb
225
+ - test/test_signature_base.rb
226
+ - test/test_signature_plain_text.rb
227
+ - test/test_token.rb
228
+ - test/test_typhoeus_request_proxy.rb
229
+ homepage:
230
+ licenses: []
231
+ metadata: {}
232
+ post_install_message:
233
+ rdoc_options: []
234
+ require_paths:
235
+ - lib
236
+ required_ruby_version: !ruby/object:Gem::Requirement
237
+ requirements:
238
+ - - ! '>='
239
+ - !ruby/object:Gem::Version
240
+ version: '0'
241
+ required_rubygems_version: !ruby/object:Gem::Requirement
242
+ requirements:
243
+ - - ! '>='
244
+ - !ruby/object:Gem::Version
245
+ version: '0'
246
+ requirements: []
247
+ rubyforge_project: oauth
248
+ rubygems_version: 2.0.5
249
+ signing_key:
250
+ specification_version: 3
251
+ summary: OAuth Core Ruby implementation
252
+ test_files: []