ey_api_hmac 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ey_api_hmac (0.0.11.pre)
4
+ ey_api_hmac (0.0.12.pre)
5
5
  json
6
6
  rack-client
7
7
 
@@ -1,5 +1,5 @@
1
1
  module EY
2
2
  module ApiHMAC
3
- VERSION = "0.0.11"
3
+ VERSION = "0.0.12"
4
4
  end
5
5
  end
data/lib/ey_api_hmac.rb CHANGED
@@ -74,6 +74,7 @@ module EY
74
74
  private
75
75
 
76
76
  def self.generated_md5(env)
77
+ env["rack.input"].rewind
77
78
  request_body = env["rack.input"].read
78
79
  env["rack.input"].rewind
79
80
  OpenSSL::Digest::MD5.hexdigest(request_body)
@@ -11,6 +11,37 @@ describe EY::ApiHMAC::ApiAuth do
11
11
 
12
12
  describe "AuthHMAC working" do
13
13
 
14
+ it "works for documented/realistic example" do
15
+ env = {'PATH_INFO' => "/api/1/service_accounts/1324/messages",
16
+ 'CONTENT_TYPE' => 'application/json',
17
+ 'HTTP_ACCEPT' => 'application/json',
18
+ 'REQUEST_METHOD' => "POST",
19
+ 'HTTP_DATE' => Time.now.httpdate,
20
+ "rack.input" => StringIO.new(
21
+ %q{{"message":{"message_type":"status","subject":"Everything looks good.","body":null}}})}
22
+
23
+ puts "before signed: \n#{env.inspect}\n\n"
24
+
25
+ auth_id = "123bc211233eabc"
26
+ auth_key = "abc474e3fc9bddf6d41236b70cc5a952f3681166e1239214740d13eecd12318f7b8d27123b61eabc"
27
+
28
+ puts "auth_id: #{auth_id}"
29
+ puts "auth_key: #{auth_key}\n\n"
30
+
31
+ canonical_string = EY::ApiHMAC.canonical_string(env)
32
+ puts "canonical_string: \n#{canonical_string.inspect}\n\n"
33
+
34
+ signature = EY::ApiHMAC.signature(env, auth_key)
35
+ puts "signature: \n#{signature}\n\n"
36
+
37
+ EY::ApiHMAC.sign!(env, auth_id, auth_key)
38
+ puts "now signed: \n#{env.inspect}\n\n"
39
+
40
+ lookup = Proc.new{ |key| auth_key if key == auth_id }
41
+
42
+ EY::ApiHMAC.authenticated?(env, &lookup).should be_true
43
+ end
44
+
14
45
  before(:each) do
15
46
  @env = {'PATH_INFO' => "/path/to/put",
16
47
  'QUERY_STRING' => 'foo=bar&bar=foo',
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ey_api_hmac
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 11
10
- version: 0.0.11
9
+ - 12
10
+ version: 0.0.12
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Jacob Burkhart & Thorben Schr\xC3\xB6der & David Calavera & others"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-08 00:00:00 Z
18
+ date: 2011-09-14 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rack-client
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  requirements: []
115
115
 
116
116
  rubyforge_project: ey_api_hmac
117
- rubygems_version: 1.8.6
117
+ rubygems_version: 1.8.10
118
118
  signing_key:
119
119
  specification_version: 3
120
120
  summary: HMAC Rack basic implementation for Engine Yard services