api-auth 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,19 @@
1
+ # 1.2.4 (2014-08-27)
2
+ - Fix a bug in the Net::HTTP request driver where the md5 isn't calculated
3
+ correctly when the content of the request is set with the `.body_stream`
4
+ method. (#49 adamcrown)
5
+
6
+ # 1.2.3 (2014-08-01)
7
+ - Update action controller request driver to fix a bug with OLD versions of
8
+ Rails using CGI
9
+
1
10
  # 1.2.2 (2014-07-08)
2
11
  - Fix Rest Client driver to account for the generated date when signing (cjeeky)
3
12
 
4
13
  # 1.2.1 (2014-07-03)
5
14
 
6
- - Fix Rest Client driver to account for the generated md5 when signing (#45 cjeeky)
15
+ - Fix Rest Client driver to account for the generated md5 when signing
16
+ (#45 cjeeky)
7
17
  - Support for testing against Rails 4.1 (#42 awendt)
8
18
  - Support all requests inheriting from Rack::Request (#43 mcls)
9
19
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- api-auth (1.2.3)
4
+ api-auth (1.2.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -40,6 +40,7 @@ GEM
40
40
  rubyntlm (~> 0.3.2)
41
41
  i18n (0.5.3)
42
42
  mime-types (1.17.2)
43
+ multipart-post (2.0.0)
43
44
  rack (1.2.8)
44
45
  rack-mount (0.6.14)
45
46
  rack (>= 1.0.0)
@@ -72,6 +73,7 @@ DEPENDENCIES
72
73
  appraisal
73
74
  curb (~> 0.8.1)
74
75
  httpi
76
+ multipart-post (~> 2.0)
75
77
  rake
76
78
  rest-client (~> 1.6.0)
77
79
  rspec (~> 2.4.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.3
1
+ 1.2.4
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.add_development_dependency "rest-client", "~> 1.6.0"
21
21
  s.add_development_dependency "curb", "~> 0.8.1"
22
22
  s.add_development_dependency "httpi"
23
+ s.add_development_dependency "multipart-post", "~> 2.0"
23
24
 
24
25
  s.files = `git ls-files`.split("\n")
25
26
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.2.3)
4
+ api-auth (1.2.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -24,6 +24,7 @@ GEM
24
24
  rack
25
25
  rubyntlm (~> 0.3.2)
26
26
  mime-types (1.25.1)
27
+ multipart-post (2.0.0)
27
28
  rack (1.1.6)
28
29
  rake (10.3.1)
29
30
  rest-client (1.6.7)
@@ -52,6 +53,7 @@ DEPENDENCIES
52
53
  appraisal
53
54
  curb (~> 0.8.1)
54
55
  httpi
56
+ multipart-post (~> 2.0)
55
57
  rake
56
58
  rest-client (~> 1.6.0)
57
59
  rspec (~> 2.4.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.2.3)
4
+ api-auth (1.2.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -41,6 +41,7 @@ GEM
41
41
  rubyntlm (~> 0.3.2)
42
42
  i18n (0.5.3)
43
43
  mime-types (1.25.1)
44
+ multipart-post (2.0.0)
44
45
  rack (1.2.8)
45
46
  rack-mount (0.6.14)
46
47
  rack (>= 1.0.0)
@@ -74,6 +75,7 @@ DEPENDENCIES
74
75
  appraisal
75
76
  curb (~> 0.8.1)
76
77
  httpi
78
+ multipart-post (~> 2.0)
77
79
  rake
78
80
  rest-client (~> 1.6.0)
79
81
  rspec (~> 2.4.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.2.3)
4
+ api-auth (1.2.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -42,6 +42,7 @@ GEM
42
42
  i18n (0.6.9)
43
43
  mime-types (1.25.1)
44
44
  multi_json (1.9.2)
45
+ multipart-post (2.0.0)
45
46
  rack (1.3.10)
46
47
  rack-cache (1.2)
47
48
  rack (>= 0.4)
@@ -80,6 +81,7 @@ DEPENDENCIES
80
81
  appraisal
81
82
  curb (~> 0.8.1)
82
83
  httpi
84
+ multipart-post (~> 2.0)
83
85
  rake
84
86
  rest-client (~> 1.6.0)
85
87
  rspec (~> 2.4.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.2.3)
4
+ api-auth (1.2.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -42,6 +42,7 @@ GEM
42
42
  journey (1.0.4)
43
43
  mime-types (1.25.1)
44
44
  multi_json (1.9.2)
45
+ multipart-post (2.0.0)
45
46
  rack (1.4.5)
46
47
  rack-cache (1.2)
47
48
  rack (>= 0.4)
@@ -79,6 +80,7 @@ DEPENDENCIES
79
80
  appraisal
80
81
  curb (~> 0.8.1)
81
82
  httpi
83
+ multipart-post (~> 2.0)
82
84
  rake
83
85
  rest-client (~> 1.6.0)
84
86
  rspec (~> 2.4.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.2.3)
4
+ api-auth (1.2.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -42,6 +42,7 @@ GEM
42
42
  mime-types (2.2)
43
43
  minitest (4.7.5)
44
44
  multi_json (1.9.2)
45
+ multipart-post (2.0.0)
45
46
  rack (1.5.2)
46
47
  rack-test (0.6.2)
47
48
  rack (>= 1.0)
@@ -76,6 +77,7 @@ DEPENDENCIES
76
77
  appraisal
77
78
  curb (~> 0.8.1)
78
79
  httpi
80
+ multipart-post (~> 2.0)
79
81
  rake
80
82
  rest-client (~> 1.6.0)
81
83
  rspec (~> 2.4.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- api-auth (1.2.3)
4
+ api-auth (1.2.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -45,6 +45,7 @@ GEM
45
45
  json (1.8.1)
46
46
  mime-types (2.2)
47
47
  minitest (5.3.4)
48
+ multipart-post (2.0.0)
48
49
  rack (1.5.2)
49
50
  rack-test (0.6.2)
50
51
  rack (>= 1.0)
@@ -80,6 +81,7 @@ DEPENDENCIES
80
81
  appraisal
81
82
  curb (~> 0.8.1)
82
83
  httpi
84
+ multipart-post (~> 2.0)
83
85
  rake
84
86
  rest-client (~> 1.6.0)
85
87
  rspec (~> 2.4.0)
@@ -19,7 +19,14 @@ module ApiAuth
19
19
  end
20
20
 
21
21
  def calculated_md5
22
- md5_base64digest(@request.body || '')
22
+ if @request.respond_to?(:body_stream) && @request.body_stream
23
+ body = @request.body_stream.read
24
+ @request.body_stream.rewind
25
+ else
26
+ body = @request.body
27
+ end
28
+
29
+ md5_base64digest(body || '')
23
30
  end
24
31
 
25
32
  def populate_content_md5
@@ -65,6 +65,15 @@ describe "ApiAuth" do
65
65
  signed_request = ApiAuth.sign!(request, @access_id, @secret_key)
66
66
  signed_request['Content-MD5'].should == "kZXQvrKoieG+Be1rsZVINw=="
67
67
  end
68
+
69
+ it "should calculate for real multipart content" do
70
+ request = Net::HTTP::Put.new("/resource.xml?foo=bar&bar=foo",
71
+ 'content-type' => 'text/plain',
72
+ 'date' => "Mon, 23 Jan 1984 03:29:56 GMT")
73
+ request.body_stream = File.new('spec/fixtures/upload.png')
74
+ signed_request = ApiAuth.sign!(request, @access_id, @secret_key)
75
+ signed_request['Content-MD5'].should == "k4U8MTA3RHDcewBzymVNEQ=="
76
+ end
68
77
  end
69
78
 
70
79
  it "should leave the content-md5 alone if provided" do
Binary file
@@ -4,6 +4,25 @@ describe "ApiAuth::Headers" do
4
4
 
5
5
  CANONICAL_STRING = "text/plain,e59ff97941044f85df5297e1c302d260,/resource.xml?foo=bar&bar=foo,Mon, 23 Jan 1984 03:29:56 GMT"
6
6
 
7
+ describe "with Net::HTTP::Put::Multipart" do
8
+
9
+ before(:each) do
10
+ request = Net::HTTP::Put::Multipart.new("/resource.xml?foo=bar&bar=foo",
11
+ 'file' => UploadIO.new(File.new('spec/fixtures/upload.png'), 'image/png', 'upload.png'))
12
+ ApiAuth.sign!(request, "some access id", "some secret key")
13
+ @headers = ApiAuth::Headers.new(request)
14
+ end
15
+
16
+ it "should set the content-type" do
17
+ @headers.canonical_string.split(',')[0].should match 'multipart/form-data; boundary='
18
+ end
19
+
20
+ it "should generate the proper content-md5" do
21
+ @headers.canonical_string.split(',')[1].should match 'zap0d6zuh6wRBSrsvO2bcw=='
22
+ end
23
+
24
+ end
25
+
7
26
  describe "with Net::HTTP" do
8
27
 
9
28
  before(:each) do
@@ -6,6 +6,7 @@ require 'amatch'
6
6
  require 'rest_client'
7
7
  require 'curb'
8
8
  require 'httpi'
9
+ require 'net/http/post/multipart'
9
10
 
10
11
  require 'active_support'
11
12
  require 'active_support/test_case'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-01 00:00:00.000000000 Z
12
+ date: 2014-08-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: appraisal
@@ -171,6 +171,22 @@ dependencies:
171
171
  - - ! '>='
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: multipart-post
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ~>
180
+ - !ruby/object:Gem::Version
181
+ version: '2.0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ~>
188
+ - !ruby/object:Gem::Version
189
+ version: '2.0'
174
190
  description: Full HMAC auth implementation for use in your gems and Rails apps.
175
191
  email: mauricio@edge14.com
176
192
  executables: []
@@ -218,6 +234,7 @@ files:
218
234
  - lib/api_auth/request_drivers/rest_client.rb
219
235
  - spec/api_auth_spec.rb
220
236
  - spec/application_helper.rb
237
+ - spec/fixtures/upload.png
221
238
  - spec/headers_spec.rb
222
239
  - spec/helpers_spec.rb
223
240
  - spec/railtie_spec.rb
@@ -235,12 +252,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
235
252
  - - ! '>='
236
253
  - !ruby/object:Gem::Version
237
254
  version: '0'
255
+ segments:
256
+ - 0
257
+ hash: -2860665435517215427
238
258
  required_rubygems_version: !ruby/object:Gem::Requirement
239
259
  none: false
240
260
  requirements:
241
261
  - - ! '>='
242
262
  - !ruby/object:Gem::Version
243
263
  version: '0'
264
+ segments:
265
+ - 0
266
+ hash: -2860665435517215427
244
267
  requirements: []
245
268
  rubyforge_project:
246
269
  rubygems_version: 1.8.23.2
@@ -250,6 +273,7 @@ summary: Simple HMAC authentication for your APIs
250
273
  test_files:
251
274
  - spec/api_auth_spec.rb
252
275
  - spec/application_helper.rb
276
+ - spec/fixtures/upload.png
253
277
  - spec/headers_spec.rb
254
278
  - spec/helpers_spec.rb
255
279
  - spec/railtie_spec.rb