rainforest_auth 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/LICENSE +1 -1
- data/lib/rainforest_auth.rb +6 -1
- data/rainforest_auth.gemspec +2 -2
- data/spec/rainforest_auth_spec.rb +12 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 980dfd004061d614b9fe029789fd9b9c4684d852
|
4
|
+
data.tar.gz: 5dab043d568f273e6a82e47a861422ef0a821c43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13583387b606552eaf3f16cfab460046dbab0d4bd4f770ed131ac2c6bec5df8fc5e4e9f23df9a18e85cdc594c6b68c23b55e8c95ecde7773df9474f8ae5c6b4b
|
7
|
+
data.tar.gz: 80fd94cb083e0bbfb4d3644194f309b1c8f7bcb87a6f44400b8f8fb6aeac2364c5f29f2f469f8727774f2dca4a57c9567264ef2b5d1bcd6e3183db124352cd3f
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rainforest_auth (0.1.
|
4
|
+
rainforest_auth (0.1.1)
|
5
5
|
json
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
10
|
diff-lcs (1.2.5)
|
11
|
-
json (2.0
|
11
|
+
json (2.1.0)
|
12
12
|
rake (10.1.1)
|
13
13
|
rspec (2.14.1)
|
14
14
|
rspec-core (~> 2.14.0)
|
@@ -30,4 +30,4 @@ DEPENDENCIES
|
|
30
30
|
rspec (>= 2.0)
|
31
31
|
|
32
32
|
BUNDLED WITH
|
33
|
-
1.
|
33
|
+
1.16.0
|
data/LICENSE
CHANGED
data/lib/rainforest_auth.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Rainforest
|
2
|
+
# Rainforest Authentication
|
3
3
|
#
|
4
4
|
#
|
5
5
|
# @author Russell Smith <russ@rainforestqa.com>
|
@@ -9,6 +9,9 @@ require 'openssl'
|
|
9
9
|
require 'json'
|
10
10
|
|
11
11
|
class RainforestAuth
|
12
|
+
class MissingKeyException < StandardError
|
13
|
+
end
|
14
|
+
|
12
15
|
attr_reader :key
|
13
16
|
|
14
17
|
def initialize(key, key_hash=nil)
|
@@ -29,11 +32,13 @@ class RainforestAuth
|
|
29
32
|
|
30
33
|
# Return a signature for a callback_type and specified options
|
31
34
|
def sign(callback_type, options = nil)
|
35
|
+
raise MissingKeyException, 'Missing key hash' if @key_hash.nil?
|
32
36
|
OpenSSL::HMAC.hexdigest(digest, @key_hash, merge_data(callback_type, options))
|
33
37
|
end
|
34
38
|
|
35
39
|
# Return a signature for a callback_type and specified options
|
36
40
|
def sign_old(callback_type, options = nil)
|
41
|
+
raise MissingKeyException, 'Missing key' if @key.nil?
|
37
42
|
OpenSSL::HMAC.hexdigest(digest, @key, merge_data(callback_type, options))
|
38
43
|
end
|
39
44
|
|
data/rainforest_auth.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "rainforest_auth"
|
3
|
-
s.version = "0.1.
|
4
|
-
s.date = "2017-
|
3
|
+
s.version = "0.1.1"
|
4
|
+
s.date = "2017-12-19"
|
5
5
|
s.summary = "Authentication of messages for Rainforest webhooks"
|
6
6
|
s.description = "Signs / Authenticates messages"
|
7
7
|
s.authors = ["Russell Smith"]
|
@@ -53,6 +53,12 @@ describe RainforestAuth do
|
|
53
53
|
it "works with no options parameter" do
|
54
54
|
@auth.sign('test').should == 'd38f897889c808c021a8ed97d2caacdac48b8259'
|
55
55
|
end
|
56
|
+
|
57
|
+
context 'key hash is nil' do
|
58
|
+
it 'raises an exception' do
|
59
|
+
expect { RainforestAuth.new(nil).sign('test') }.to raise_error(RainforestAuth::MissingKeyException)
|
60
|
+
end
|
61
|
+
end
|
56
62
|
end
|
57
63
|
|
58
64
|
#TODO: nuke
|
@@ -72,6 +78,12 @@ describe RainforestAuth do
|
|
72
78
|
it "works with no options parameter" do
|
73
79
|
@auth.sign_old('test').should == '0a41bdf26fac08a89573a7f5efe0a5145f2730df'
|
74
80
|
end
|
81
|
+
|
82
|
+
context 'key is nil' do
|
83
|
+
it 'raises an exception' do
|
84
|
+
expect { RainforestAuth.new(nil, 'I am not nil!').sign_old('test') }.to raise_error(RainforestAuth::MissingKeyException)
|
85
|
+
end
|
86
|
+
end
|
75
87
|
end
|
76
88
|
|
77
89
|
context ".verify" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rainforest_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Russell Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -68,4 +68,6 @@ rubygems_version: 2.2.2
|
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
70
|
summary: Authentication of messages for Rainforest webhooks
|
71
|
-
test_files:
|
71
|
+
test_files:
|
72
|
+
- spec/rainforest_auth_spec.rb
|
73
|
+
- spec/spec_helper.rb
|