sigil 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/sigil/base.rb +6 -7
- data/lib/sigil/version.rb +1 -1
- data/spec/sigil/base_spec.rb +9 -5
- metadata +7 -7
data/Gemfile.lock
CHANGED
data/lib/sigil/base.rb
CHANGED
@@ -29,16 +29,15 @@ module Sigil
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def verify(provided_signature)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
signature == provided_signature
|
32
|
+
verify!(provided_signature)
|
33
|
+
rescue Sigil::Error
|
34
|
+
false
|
36
35
|
end
|
37
36
|
|
38
37
|
def verify!(provided_signature)
|
39
|
-
|
40
|
-
|
41
|
-
raise Sigil::Error, "Signature does not match" unless
|
38
|
+
raise Sigil::Error, "Params not set" if params.empty?
|
39
|
+
raise Sigil::Error, "Signature not set" if provided_signature.blank?
|
40
|
+
raise Sigil::Error, "Signature does not match" unless signature == provided_signature
|
42
41
|
|
43
42
|
true
|
44
43
|
end
|
data/lib/sigil/version.rb
CHANGED
data/spec/sigil/base_spec.rb
CHANGED
@@ -59,23 +59,27 @@ describe Sigil::Base do
|
|
59
59
|
describe "input verification convenience methods" do
|
60
60
|
|
61
61
|
it "should verify against a provided signature" do
|
62
|
-
@sigil.verify(@signature).should
|
62
|
+
@sigil.verify(@signature).should be_true
|
63
|
+
@sigil.verify!(@signature).should be_true
|
63
64
|
end
|
64
65
|
|
65
66
|
it "should verify against a wrong signature" do
|
66
|
-
@sigil.verify("abc").should
|
67
|
+
@sigil.verify("abc").should be_false
|
68
|
+
lambda { @sigil.verify!("abc") }.should raise_error(Sigil::Error, /Signature does not match/)
|
67
69
|
end
|
68
70
|
|
69
71
|
it "should raise an error if no params present" do
|
70
72
|
sigil = Sigil::Base.new({}, @key)
|
71
|
-
|
73
|
+
sigil.verify("abc").should be_false
|
74
|
+
lambda { sigil.verify!("abc") }.should raise_error(Sigil::Error, /Params not set/)
|
72
75
|
end
|
73
76
|
|
74
77
|
it "should raise an error if no signature specified" do
|
75
78
|
sigil = Sigil::Base.new(@params, @key)
|
76
|
-
|
79
|
+
sigil.verify("").should be_false
|
80
|
+
lambda { sigil.verify!("") }.should raise_error(Sigil::Error, /Signature not set/)
|
77
81
|
end
|
78
82
|
|
79
83
|
end
|
80
84
|
|
81
|
-
end
|
85
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sigil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-19 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70321865718580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70321865718580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70321865717980 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.1.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70321865717980
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70321865717240 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70321865717240
|
47
47
|
description: Signs and verifies a set of parameters
|
48
48
|
email:
|
49
49
|
- steve@seven.net.nz
|