ey_api_hmac 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,7 +19,7 @@ module EY
19
19
  @lookup.call(env, auth_id)
20
20
  end
21
21
  rescue HmacAuthFail => e
22
- return [401, {}, ["Authentication failure: #{e.message}"]]
22
+ return [401, {"Content-Type" => "text/plain"}, ["Authentication failure: #{e.message}"]]
23
23
  end
24
24
  @app.call(env)
25
25
  end
@@ -57,13 +57,13 @@ module EY
57
57
  class AuthFailure < RuntimeError
58
58
  end
59
59
 
60
- def initialize(app, auth_id, auth_key)
61
- @app, @auth_id, @auth_key = app, auth_id, auth_key
60
+ def initialize(app, auth_id, auth_key, quiet=false)
61
+ @app, @auth_id, @auth_key, @quiet = app, auth_id, auth_key, quiet
62
62
  end
63
63
  def call(env)
64
64
  ApiHMAC.sign!(env, @auth_id, @auth_key)
65
65
  tuple = @app.call(env)
66
- if tuple.first.to_i == 401
66
+ if !@quiet && tuple.first.to_i == 401
67
67
  response_body = ""
68
68
  tuple.last.each{ |v| response_body << v }
69
69
  raise AuthFailure, "HMAC Authentication Failed: #{response_body}"
@@ -1,5 +1,5 @@
1
1
  module EY
2
2
  module ApiHMAC
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -213,6 +213,19 @@ describe EY::ApiHMAC::ApiAuth do
213
213
 
214
214
  lambda { client.get('/') }.should raise_error(EY::ApiHMAC::ApiAuth::Client::AuthFailure)
215
215
  end
216
+
217
+ it "fails but does not raise when quiet is enabled" do
218
+ client = Rack::Client.new('http://localhost') do
219
+ use Rack::Config do |env|
220
+ env['HTTP_DATE'] = Time.now.httpdate
221
+ end
222
+ use EY::ApiHMAC::ApiAuth::Client, 1, 'diffkey', true
223
+ run MockApp.call(true, 'key')
224
+ end
225
+
226
+ client.get("/").status.should == 401
227
+
228
+ end
216
229
  end
217
230
  end
218
231
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ey_api_hmac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-14 00:00:00.000000000 Z
12
+ date: 2011-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack-client
16
- requirement: &2158291480 !ruby/object:Gem::Requirement
16
+ requirement: &2158803980 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2158291480
24
+ version_requirements: *2158803980
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &2158290940 !ruby/object:Gem::Requirement
27
+ requirement: &2158803140 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2158290940
35
+ version_requirements: *2158803140
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2158290360 !ruby/object:Gem::Requirement
38
+ requirement: &2158802700 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2158290360
46
+ version_requirements: *2158802700
47
47
  description: basic wrapper for rack-client + middlewares for HMAC auth + helpers for
48
48
  SSO auth
49
49
  email: