r509-validity-redis 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,30 +1,30 @@
1
1
  require "r509"
2
2
 
3
3
  module R509::Validity::Redis
4
- class Checker < R509::Validity::Checker
5
- def initialize(redis)
6
- raise ArgumentError.new("Redis must be provided") if redis.nil?
7
- @redis = redis
8
- end
4
+ class Checker < R509::Validity::Checker
5
+ def initialize(redis)
6
+ raise ArgumentError.new("Redis must be provided") if redis.nil?
7
+ @redis = redis
8
+ end
9
9
 
10
- # @return [R509::Validity::Status]
11
- def check(issuer,serial)
12
- raise ArgumentError.new("Serial and issuer must be provided") if serial.to_s.empty? or issuer.to_s.empty?
10
+ # @return [R509::Validity::Status]
11
+ def check(issuer,serial)
12
+ raise ArgumentError.new("Serial and issuer must be provided") if serial.to_s.empty? or issuer.to_s.empty?
13
13
 
14
- hash = @redis.hgetall("cert:#{issuer}:#{serial}")
15
- if not hash.nil? and hash.has_key?("status")
16
- R509::Validity::Status.new(
17
- :status => hash["status"].to_i,
18
- :revocation_time => hash["revocation_time"].to_i || nil,
19
- :revocation_reason => hash["revocation_reason"].to_i || 0
20
- )
21
- else
22
- R509::Validity::Status.new(:status => R509::Validity::UNKNOWN)
23
- end
24
- end
14
+ hash = @redis.hgetall("cert:#{issuer}:#{serial}")
15
+ if not hash.nil? and hash.has_key?("status")
16
+ R509::Validity::Status.new(
17
+ :status => hash["status"].to_i,
18
+ :revocation_time => hash["revocation_time"].to_i || nil,
19
+ :revocation_reason => hash["revocation_reason"].to_i || 0
20
+ )
21
+ else
22
+ R509::Validity::Status.new(:status => R509::Validity::UNKNOWN)
23
+ end
24
+ end
25
25
 
26
- def is_available?
27
- (@redis.ping == "PONG")? true : false
28
- end
26
+ def is_available?
27
+ (@redis.ping == "PONG")? true : false
29
28
  end
29
+ end
30
30
  end
@@ -1,7 +1,7 @@
1
1
  module R509
2
- module Validity
3
- module Redis
4
- VERSION="0.4.1"
5
- end
2
+ module Validity
3
+ module Redis
4
+ VERSION="0.4.2"
6
5
  end
6
+ end
7
7
  end
@@ -1,43 +1,43 @@
1
1
  require "r509"
2
2
 
3
3
  module R509::Validity::Redis
4
- class Writer < R509::Validity::Writer
5
- def initialize(redis)
6
- raise ArgumentError.new("Redis must be provided") if redis.nil?
7
- @redis = redis
8
- end
4
+ class Writer < R509::Validity::Writer
5
+ def initialize(redis)
6
+ raise ArgumentError.new("Redis must be provided") if redis.nil?
7
+ @redis = redis
8
+ end
9
9
 
10
- def issue(issuer, serial)
11
- raise ArgumentError.new("Serial and issuer must be provided") if serial.to_s.empty? or issuer.to_s.empty?
12
- cert = @redis.hgetall("cert:#{issuer}:#{serial}")
13
- if cert.nil? or not cert.has_key?("status")
14
- @redis.hmset("cert:#{issuer}:#{serial}", "status", 0)
15
- else
16
- raise R509::R509Error.new("Serial #{serial} for issuer #{issuer} is already present")
17
- end
18
- end
10
+ def issue(issuer, serial)
11
+ raise ArgumentError.new("Serial and issuer must be provided") if serial.to_s.empty? or issuer.to_s.empty?
12
+ cert = @redis.hgetall("cert:#{issuer}:#{serial}")
13
+ if cert.nil? or not cert.has_key?("status")
14
+ @redis.hmset("cert:#{issuer}:#{serial}", "status", 0)
15
+ else
16
+ raise R509::R509Error.new("Serial #{serial} for issuer #{issuer} is already present")
17
+ end
18
+ end
19
19
 
20
- def revoke(issuer, serial, revocation_time=Time.now.to_i, reason=0)
21
- raise ArgumentError.new("Serial and issuer must be provided") if serial.to_s.empty? or issuer.to_s.empty?
22
- @redis.hmset("cert:#{issuer}:#{serial}",
23
- "status", 1,
24
- "revocation_time", revocation_time || Time.now.to_i,
25
- "revocation_reason", reason || 0
26
- )
27
- end
20
+ def revoke(issuer, serial, revocation_time=Time.now.to_i, reason=0)
21
+ raise ArgumentError.new("Serial and issuer must be provided") if serial.to_s.empty? or issuer.to_s.empty?
22
+ @redis.hmset("cert:#{issuer}:#{serial}",
23
+ "status", 1,
24
+ "revocation_time", revocation_time || Time.now.to_i,
25
+ "revocation_reason", reason || 0
26
+ )
27
+ end
28
28
 
29
- def unrevoke(issuer, serial)
30
- raise ArgumentError.new("Serial and issuer must be provided") if serial.to_s.empty? or issuer.to_s.empty?
31
- cert = @redis.hgetall("cert:#{issuer}:#{serial}")
32
- if cert.nil? or not cert.has_key?("status")
33
- raise R509::R509Error.new("Serial #{serial} for issuer #{issuer} is not present")
34
- else
35
- @redis.hmset("cert:#{issuer}:#{serial}", "status", 0)
36
- end
37
- end
29
+ def unrevoke(issuer, serial)
30
+ raise ArgumentError.new("Serial and issuer must be provided") if serial.to_s.empty? or issuer.to_s.empty?
31
+ cert = @redis.hgetall("cert:#{issuer}:#{serial}")
32
+ if cert.nil? or not cert.has_key?("status")
33
+ raise R509::R509Error.new("Serial #{serial} for issuer #{issuer} is not present")
34
+ else
35
+ @redis.hmset("cert:#{issuer}:#{serial}", "status", 0)
36
+ end
37
+ end
38
38
 
39
- def is_available?
40
- (@redis.ping == "PONG")? true : false
41
- end
39
+ def is_available?
40
+ (@redis.ping == "PONG")? true : false
42
41
  end
42
+ end
43
43
  end
@@ -1,68 +1,68 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe R509::Validity::Redis::Checker do
4
- context "constructor" do
5
- it "when redis is nil" do
6
- expect { R509::Validity::Redis::Checker.new(nil) }.to raise_error(ArgumentError, "Redis must be provided")
7
- end
4
+ context "constructor" do
5
+ it "when redis is nil" do
6
+ expect { R509::Validity::Redis::Checker.new(nil) }.to raise_error(ArgumentError, "Redis must be provided")
8
7
  end
9
- context "check" do
10
- it "throws an exception when issuer is nil/empty string" do
11
- redis = double("redis")
12
- checker = R509::Validity::Redis::Checker.new(redis)
13
- expect { checker.check(nil,123) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
14
- end
15
- it "throws an exception when serial is nil/empty string" do
16
- redis = double("redis")
17
- checker = R509::Validity::Redis::Checker.new(redis)
18
- expect { checker.check("abcdef",nil) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
19
- end
20
- it "gets unknown when serial is not found (returns {})" do
21
- redis = double("redis")
22
- checker = R509::Validity::Redis::Checker.new(redis)
23
- redis.should_receive(:hgetall).with("cert:abcdef:123").and_return({})
24
- status = checker.check("abcdef",123)
25
- status.status.should == R509::Validity::UNKNOWN
26
- end
27
- it "gets unknown when serial is not found (returns nil)" do
28
- redis = double("redis")
29
- checker = R509::Validity::Redis::Checker.new(redis)
30
- redis.should_receive(:hgetall).with("cert:abcdef:123").and_return(nil)
31
- status = checker.check("abcdef",123)
32
- status.status.should == R509::Validity::UNKNOWN
33
- end
34
- it "gets valid" do
35
- redis = double("redis")
36
- checker = R509::Validity::Redis::Checker.new(redis)
37
- redis.should_receive(:hgetall).with("cert:abcdef:123").and_return({"status" => "0" })
38
- status = checker.check("abcdef",123)
39
- status.status.should == R509::Validity::VALID
40
- status.revocation_time.should == 0
41
- status.revocation_reason.should == 0
42
- end
43
- it "gets revoked with revocation time and reason" do
44
- redis = double("redis")
45
- checker = R509::Validity::Redis::Checker.new(redis)
46
- redis.should_receive(:hgetall).with("cert:abcdef:123").and_return({"status" => "1", "revocation_time" => "789", "revocation_reason" => "5" })
47
- status = checker.check("abcdef",123)
48
- status.status.should == R509::Validity::REVOKED
49
- status.revocation_time.should == 789
50
- status.revocation_reason.should == 5
51
- end
8
+ end
9
+ context "check" do
10
+ it "throws an exception when issuer is nil/empty string" do
11
+ redis = double("redis")
12
+ checker = R509::Validity::Redis::Checker.new(redis)
13
+ expect { checker.check(nil,123) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
14
+ end
15
+ it "throws an exception when serial is nil/empty string" do
16
+ redis = double("redis")
17
+ checker = R509::Validity::Redis::Checker.new(redis)
18
+ expect { checker.check("abcdef",nil) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
19
+ end
20
+ it "gets unknown when serial is not found (returns {})" do
21
+ redis = double("redis")
22
+ checker = R509::Validity::Redis::Checker.new(redis)
23
+ redis.should_receive(:hgetall).with("cert:abcdef:123").and_return({})
24
+ status = checker.check("abcdef",123)
25
+ status.status.should == R509::Validity::UNKNOWN
26
+ end
27
+ it "gets unknown when serial is not found (returns nil)" do
28
+ redis = double("redis")
29
+ checker = R509::Validity::Redis::Checker.new(redis)
30
+ redis.should_receive(:hgetall).with("cert:abcdef:123").and_return(nil)
31
+ status = checker.check("abcdef",123)
32
+ status.status.should == R509::Validity::UNKNOWN
33
+ end
34
+ it "gets valid" do
35
+ redis = double("redis")
36
+ checker = R509::Validity::Redis::Checker.new(redis)
37
+ redis.should_receive(:hgetall).with("cert:abcdef:123").and_return({"status" => "0" })
38
+ status = checker.check("abcdef",123)
39
+ status.status.should == R509::Validity::VALID
40
+ status.revocation_time.should == 0
41
+ status.revocation_reason.should == 0
42
+ end
43
+ it "gets revoked with revocation time and reason" do
44
+ redis = double("redis")
45
+ checker = R509::Validity::Redis::Checker.new(redis)
46
+ redis.should_receive(:hgetall).with("cert:abcdef:123").and_return({"status" => "1", "revocation_time" => "789", "revocation_reason" => "5" })
47
+ status = checker.check("abcdef",123)
48
+ status.status.should == R509::Validity::REVOKED
49
+ status.revocation_time.should == 789
50
+ status.revocation_reason.should == 5
51
+ end
52
+ end
53
+ context "is available" do
54
+ it "returns true if redis is available" do
55
+ redis = double("redis")
56
+ redis.should_receive(:ping).and_return("PONG")
57
+ checker = R509::Validity::Redis::Checker.new(redis)
58
+ checker.is_available?.should == true
52
59
  end
53
- context "is available" do
54
- it "returns true if redis is available" do
55
- redis = double("redis")
56
- redis.should_receive(:ping).and_return("PONG")
57
- checker = R509::Validity::Redis::Checker.new(redis)
58
- checker.is_available?.should == true
59
- end
60
60
 
61
- it "raises error if redis is unavailable" do
62
- redis = double("redis")
63
- redis.should_receive(:ping).and_return(StandardError)
64
- checker = R509::Validity::Redis::Checker.new(redis)
65
- checker.is_available?.should == false
66
- end
61
+ it "raises error if redis is unavailable" do
62
+ redis = double("redis")
63
+ redis.should_receive(:ping).and_return(StandardError)
64
+ checker = R509::Validity::Redis::Checker.new(redis)
65
+ checker.is_available?.should == false
67
66
  end
67
+ end
68
68
  end
@@ -1,7 +1,5 @@
1
- if (RUBY_VERSION.split('.')[1].to_i > 8)
2
- require 'simplecov'
3
- SimpleCov.start
4
- end
1
+ require 'simplecov'
2
+ SimpleCov.start
5
3
 
6
4
  $:.unshift File.expand_path("../../lib", __FILE__)
7
5
  $:.unshift File.expand_path("../", __FILE__)
@@ -1,127 +1,127 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe R509::Validity::Redis::Writer do
4
- context "constructor" do
5
- it "when redis is nil" do
6
- expect { R509::Validity::Redis::Writer.new(nil) }.to raise_error(ArgumentError, "Redis must be provided")
7
- end
4
+ context "constructor" do
5
+ it "when redis is nil" do
6
+ expect { R509::Validity::Redis::Writer.new(nil) }.to raise_error(ArgumentError, "Redis must be provided")
8
7
  end
8
+ end
9
9
 
10
- context "issue" do
11
- it "when issuer is nil/empty string" do
12
- redis = double("redis")
13
- writer = R509::Validity::Redis::Writer.new(redis)
14
- expect { writer.issue(nil,123) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
15
- end
16
- it "when serial is nil/empty string" do
17
- redis = double("redis")
18
- writer = R509::Validity::Redis::Writer.new(redis)
19
- expect { writer.issue("abcdef",nil) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
20
- end
21
- it "when serial/issuer is provided (check returns nil)" do
22
- redis = double("redis")
23
- writer = R509::Validity::Redis::Writer.new(redis)
24
- redis.should_receive(:hgetall).with("cert:abcdef:123").and_return(nil)
25
- redis.should_receive(:hmset).with("cert:abcdef:123", "status", 0)
26
- writer.issue("abcdef",123)
27
- end
28
- it "when serial/issuer is provided (check returns {})" do
29
- redis = double("redis")
30
- writer = R509::Validity::Redis::Writer.new(redis)
31
- redis.should_receive(:hgetall).with("cert:abcdef:123").and_return({})
32
- redis.should_receive(:hmset).with("cert:abcdef:123", "status", 0)
33
- writer.issue("abcdef",123)
34
- end
35
- it "when serial/issuer is already present" do
36
- redis = double("redis")
37
- writer = R509::Validity::Redis::Writer.new(redis)
38
- redis.should_receive(:hgetall).with("cert:abcdef:123").and_return({"status"=>0})
39
- expect { writer.issue("abcdef",123) }.to raise_error(R509::R509Error, "Serial 123 for issuer abcdef is already present")
40
- end
10
+ context "issue" do
11
+ it "when issuer is nil/empty string" do
12
+ redis = double("redis")
13
+ writer = R509::Validity::Redis::Writer.new(redis)
14
+ expect { writer.issue(nil,123) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
41
15
  end
16
+ it "when serial is nil/empty string" do
17
+ redis = double("redis")
18
+ writer = R509::Validity::Redis::Writer.new(redis)
19
+ expect { writer.issue("abcdef",nil) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
20
+ end
21
+ it "when serial/issuer is provided (check returns nil)" do
22
+ redis = double("redis")
23
+ writer = R509::Validity::Redis::Writer.new(redis)
24
+ redis.should_receive(:hgetall).with("cert:abcdef:123").and_return(nil)
25
+ redis.should_receive(:hmset).with("cert:abcdef:123", "status", 0)
26
+ writer.issue("abcdef",123)
27
+ end
28
+ it "when serial/issuer is provided (check returns {})" do
29
+ redis = double("redis")
30
+ writer = R509::Validity::Redis::Writer.new(redis)
31
+ redis.should_receive(:hgetall).with("cert:abcdef:123").and_return({})
32
+ redis.should_receive(:hmset).with("cert:abcdef:123", "status", 0)
33
+ writer.issue("abcdef",123)
34
+ end
35
+ it "when serial/issuer is already present" do
36
+ redis = double("redis")
37
+ writer = R509::Validity::Redis::Writer.new(redis)
38
+ redis.should_receive(:hgetall).with("cert:abcdef:123").and_return({"status"=>0})
39
+ expect { writer.issue("abcdef",123) }.to raise_error(R509::R509Error, "Serial 123 for issuer abcdef is already present")
40
+ end
41
+ end
42
42
 
43
- context "revoke" do
44
- it "when issuer is nil/empty string" do
45
- redis = double("redis")
46
- writer = R509::Validity::Redis::Writer.new(redis)
47
- expect { writer.revoke(nil,123) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
48
- end
49
- it "when serial is nil/empty string" do
50
- redis = double("redis")
51
- writer = R509::Validity::Redis::Writer.new(redis)
52
- expect { writer.revoke("abcdef",nil) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
53
- end
54
- it "when time and reason aren't provided" do
55
- redis = double("redis")
56
- writer = R509::Validity::Redis::Writer.new(redis)
57
- redis.should_receive(:hmset).with("cert:abcdef:123", "status", 1, "revocation_time", Time.now.to_i, "revocation_reason", 0)
58
- writer.revoke("abcdef",123)
59
- end
60
- it "when time and reason are nil" do
61
- redis = double("redis")
62
- writer = R509::Validity::Redis::Writer.new(redis)
63
- redis.should_receive(:hmset).with("cert:abcdef:123", "status", 1, "revocation_time", Time.now.to_i, "revocation_reason", 0)
64
- writer.revoke("abcdef",123, nil, nil)
65
- end
66
- it "when time is provided, but not reason" do
67
- redis = double("redis")
68
- writer = R509::Validity::Redis::Writer.new(redis)
69
- redis.should_receive(:hmset).with("cert:abcdef:123", "status", 1, "revocation_time", 100, "revocation_reason", 0)
70
- writer.revoke("abcdef",123, 100)
71
- end
72
- it "when time and reason are provided" do
73
- redis = double("redis")
74
- writer = R509::Validity::Redis::Writer.new(redis)
75
- redis.should_receive(:hmset).with("cert:abcdef:123", "status", 1, "revocation_time", 100, "revocation_reason", 2)
76
- writer.revoke("abcdef",123, 100, 2)
77
- end
43
+ context "revoke" do
44
+ it "when issuer is nil/empty string" do
45
+ redis = double("redis")
46
+ writer = R509::Validity::Redis::Writer.new(redis)
47
+ expect { writer.revoke(nil,123) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
48
+ end
49
+ it "when serial is nil/empty string" do
50
+ redis = double("redis")
51
+ writer = R509::Validity::Redis::Writer.new(redis)
52
+ expect { writer.revoke("abcdef",nil) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
53
+ end
54
+ it "when time and reason aren't provided" do
55
+ redis = double("redis")
56
+ writer = R509::Validity::Redis::Writer.new(redis)
57
+ redis.should_receive(:hmset).with("cert:abcdef:123", "status", 1, "revocation_time", Time.now.to_i, "revocation_reason", 0)
58
+ writer.revoke("abcdef",123)
59
+ end
60
+ it "when time and reason are nil" do
61
+ redis = double("redis")
62
+ writer = R509::Validity::Redis::Writer.new(redis)
63
+ redis.should_receive(:hmset).with("cert:abcdef:123", "status", 1, "revocation_time", Time.now.to_i, "revocation_reason", 0)
64
+ writer.revoke("abcdef",123, nil, nil)
78
65
  end
66
+ it "when time is provided, but not reason" do
67
+ redis = double("redis")
68
+ writer = R509::Validity::Redis::Writer.new(redis)
69
+ redis.should_receive(:hmset).with("cert:abcdef:123", "status", 1, "revocation_time", 100, "revocation_reason", 0)
70
+ writer.revoke("abcdef",123, 100)
71
+ end
72
+ it "when time and reason are provided" do
73
+ redis = double("redis")
74
+ writer = R509::Validity::Redis::Writer.new(redis)
75
+ redis.should_receive(:hmset).with("cert:abcdef:123", "status", 1, "revocation_time", 100, "revocation_reason", 2)
76
+ writer.revoke("abcdef",123, 100, 2)
77
+ end
78
+ end
79
79
 
80
- context "unrevoke" do
81
- it "when issuer is nil/empty string" do
82
- redis = double("redis")
83
- writer = R509::Validity::Redis::Writer.new(redis)
84
- expect { writer.unrevoke(nil,123) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
85
- end
86
- it "when serial is nil/empty string" do
87
- redis = double("redis")
88
- writer = R509::Validity::Redis::Writer.new(redis)
89
- expect { writer.unrevoke("abcdef",nil) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
90
- end
91
- it "when serial/issuer is provided" do
92
- redis = double("redis")
93
- writer = R509::Validity::Redis::Writer.new(redis)
94
- redis.should_receive(:hgetall).with("cert:abcdef:123").and_return({"status" => 1})
95
- redis.should_receive(:hmset).with("cert:abcdef:123", "status", 0)
96
- writer.unrevoke("abcdef",123)
97
- end
98
- it "when cert record doesn't exist (nil)" do
99
- redis = double("redis")
100
- writer = R509::Validity::Redis::Writer.new(redis)
101
- redis.should_receive(:hgetall).with("cert:abcdef:123").and_return(nil)
102
- expect { writer.unrevoke("abcdef",123) }.to raise_error(R509::R509Error, "Serial 123 for issuer abcdef is not present")
103
- end
104
- it "when cert record doesn't exist ({})" do
105
- redis = double("redis")
106
- writer = R509::Validity::Redis::Writer.new(redis)
107
- redis.should_receive(:hgetall).with("cert:abcdef:123").and_return({})
108
- expect { writer.unrevoke("abcdef",123) }.to raise_error(R509::R509Error, "Serial 123 for issuer abcdef is not present")
109
- end
80
+ context "unrevoke" do
81
+ it "when issuer is nil/empty string" do
82
+ redis = double("redis")
83
+ writer = R509::Validity::Redis::Writer.new(redis)
84
+ expect { writer.unrevoke(nil,123) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
85
+ end
86
+ it "when serial is nil/empty string" do
87
+ redis = double("redis")
88
+ writer = R509::Validity::Redis::Writer.new(redis)
89
+ expect { writer.unrevoke("abcdef",nil) }.to raise_error(ArgumentError, "Serial and issuer must be provided")
90
+ end
91
+ it "when serial/issuer is provided" do
92
+ redis = double("redis")
93
+ writer = R509::Validity::Redis::Writer.new(redis)
94
+ redis.should_receive(:hgetall).with("cert:abcdef:123").and_return({"status" => 1})
95
+ redis.should_receive(:hmset).with("cert:abcdef:123", "status", 0)
96
+ writer.unrevoke("abcdef",123)
110
97
  end
98
+ it "when cert record doesn't exist (nil)" do
99
+ redis = double("redis")
100
+ writer = R509::Validity::Redis::Writer.new(redis)
101
+ redis.should_receive(:hgetall).with("cert:abcdef:123").and_return(nil)
102
+ expect { writer.unrevoke("abcdef",123) }.to raise_error(R509::R509Error, "Serial 123 for issuer abcdef is not present")
103
+ end
104
+ it "when cert record doesn't exist ({})" do
105
+ redis = double("redis")
106
+ writer = R509::Validity::Redis::Writer.new(redis)
107
+ redis.should_receive(:hgetall).with("cert:abcdef:123").and_return({})
108
+ expect { writer.unrevoke("abcdef",123) }.to raise_error(R509::R509Error, "Serial 123 for issuer abcdef is not present")
109
+ end
110
+ end
111
111
 
112
- context "is available" do
113
- it "returns true if redis is available" do
114
- redis = double("redis")
115
- redis.should_receive(:ping).and_return("PONG")
116
- writer = R509::Validity::Redis::Writer.new(redis)
117
- writer.is_available?.should == true
118
- end
112
+ context "is available" do
113
+ it "returns true if redis is available" do
114
+ redis = double("redis")
115
+ redis.should_receive(:ping).and_return("PONG")
116
+ writer = R509::Validity::Redis::Writer.new(redis)
117
+ writer.is_available?.should == true
118
+ end
119
119
 
120
- it "raises error if redis is unavailable" do
121
- redis = double("redis")
122
- redis.should_receive(:ping).and_return(StandardError)
123
- writer = R509::Validity::Redis::Writer.new(redis)
124
- writer.is_available?.should == false
125
- end
120
+ it "raises error if redis is unavailable" do
121
+ redis = double("redis")
122
+ redis.should_receive(:ping).and_return(StandardError)
123
+ writer = R509::Validity::Redis::Writer.new(redis)
124
+ writer.is_available?.should == false
126
125
  end
126
+ end
127
127
  end