ey_api_hmac 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/ey_api_hmac/version.rb +1 -1
- data/lib/ey_api_hmac.rb +1 -0
- data/spec/api_auth_spec.rb +31 -0
- metadata +5 -5
data/Gemfile.lock
CHANGED
data/lib/ey_api_hmac/version.rb
CHANGED
data/lib/ey_api_hmac.rb
CHANGED
data/spec/api_auth_spec.rb
CHANGED
@@ -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:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
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-
|
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.
|
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
|