crashlog-auth-hmac 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- crashlog-auth-hmac (1.1.3)
4
+ crashlog-auth-hmac (1.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -9,6 +9,9 @@ GEM
9
9
  activesupport (3.2.7)
10
10
  i18n (~> 0.6)
11
11
  multi_json (~> 1.0)
12
+ chronic (0.6.7)
13
+ delorean (2.0.0)
14
+ chronic
12
15
  diff-lcs (1.1.3)
13
16
  i18n (0.6.0)
14
17
  multi_json (1.3.6)
@@ -31,6 +34,7 @@ PLATFORMS
31
34
  DEPENDENCIES
32
35
  activesupport (~> 3.2.0)
33
36
  crashlog-auth-hmac!
37
+ delorean
34
38
  rack-test
35
39
  rake
36
40
  rspec (>= 2.7.0)
@@ -79,10 +79,12 @@ module CrashLog
79
79
  request.env['REQUEST_METHOD']
80
80
  elsif request.is_a?(Hash) && request.has_key?('REQUEST_METHOD')
81
81
  request['REQUEST_METHOD']
82
- elsif request.respond_to?(:method) && request.method.is_a?(String)
83
- request.method
84
82
  else
85
- raise ArgumentError, "Don't know how to get the request method from #{request.inspect}"
83
+ begin
84
+ request.method
85
+ rescue ArgumentError
86
+ raise ArgumentError, "Don't know how to get the request method from #{request.inspect}"
87
+ end
86
88
  end
87
89
  end
88
90
 
@@ -1,5 +1,5 @@
1
1
  module CrashLog
2
2
  class AuthHMAC
3
- VERSION = "1.1.4"
3
+ VERSION = "1.1.5"
4
4
  end
5
5
  end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+ require "net/http"
3
+ require 'time'
4
+ require 'active_support'
5
+ require 'rack/test'
6
+ require "delorean"
7
+
8
+ describe CrashLog::AuthHMAC do
9
+ include Rack::Test::Methods
10
+
11
+ def app
12
+ lambda do |env|
13
+ [200, {"Content-Type" => "text/html", "Content-Length" => 13}, "Hello, World!"]
14
+ end
15
+ end
16
+
17
+ it 'says hello world' do
18
+ get '/'
19
+ last_response.status.should == 200
20
+ last_response.body.should == 'Hello, World!'
21
+ end
22
+
23
+ it 'can process rack test requests' do
24
+ # HMAC uses date to validate request signature, we need to fix the date so
25
+ # that it matches.
26
+ Delorean.time_travel_to(Date.parse("Thu, 10 Jul 2008 03:29:56 GMT"))
27
+
28
+ env = current_session.__send__(:env_for, '/notify', {}.merge(:method => "POST", :params => {token: 'my-key-id'}))
29
+ signature = CrashLog::AuthHMAC.sign!(env, "my-key-id", "secret")
30
+ signature.should == "AuthHMAC my-key-id:nt0VFUekBB3Ci5cCyaqy9fQnaK0="
31
+ end
32
+
33
+ it 'can handle hash requests' do
34
+ Delorean.time_travel_to(Date.parse("Thu, 10 Jul 2008 03:29:56 GMT"))
35
+
36
+ request_hash = {
37
+ 'REQUEST_METHOD' => 'POST',
38
+ 'content-type' => 'text/plain',
39
+ 'content-md5' => 'blahblah',
40
+ 'date' => "Thu, 10 Jul 2008 03:29:56 GMT",
41
+ 'PATH_INFO' => '/notify'
42
+ }
43
+
44
+ sig = CrashLog::AuthHMAC.signature(request_hash, 'secret')
45
+ sig.should == 'ODgXzfflvf+Sbr6wxGbWURucYgo='
46
+ end
47
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crashlog-auth-hmac
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
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: 2012-08-08 00:00:00.000000000 Z
12
+ date: 2012-09-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A Ruby Gem for authenticating HTTP requests using a HMAC
15
15
  email:
@@ -32,6 +32,7 @@ files:
32
32
  - lib/crash_log/auth_hmac/version.rb
33
33
  - lib/crashlog-auth-hmac.rb
34
34
  - spec/crash_log/auth_hmac_spec.rb
35
+ - spec/crash_log/rack_test_request_spec.rb
35
36
  - spec/spec_helper.rb
36
37
  homepage: http://crashlog.io
37
38
  licenses: []
@@ -59,4 +60,5 @@ specification_version: 3
59
60
  summary: A Ruby Gem for authenticating HTTP requests using a HMAC
60
61
  test_files:
61
62
  - spec/crash_log/auth_hmac_spec.rb
63
+ - spec/crash_log/rack_test_request_spec.rb
62
64
  - spec/spec_helper.rb