sslcheck 0.9.3 → 0.9.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e95e8af9f709c97fc7821e5b9dedecd95ef01e0c
4
- data.tar.gz: 961224561da2b1bf950543eb879ec4f68dfe19ea
3
+ metadata.gz: d3cef80868e3796537488bac3896a10c52853757
4
+ data.tar.gz: 12dbc2542745a65fbf439798e208290b4a08b744
5
5
  SHA512:
6
- metadata.gz: c91f73a624a7008bb6ac5dccc17142c91584026f6746373f1aa7f686104ecc58d202f6677e4902e1fdf75ef7c99b7c7930ba69d4a5f0f99bc1b69c1a72dea175
7
- data.tar.gz: c0ffd510d900404be65cb5b1ae1451a92ed18cf2c5dbc5364f4c72a9da49e9bac44d3d3aeb8030defc3e10eb87dc102aadae66dc2a45ae70d857b6034901a948
6
+ metadata.gz: b003ebe52cfcea15993e6c2234cb161f81794a924605849b4f6fb55bebea91ba9fbb86a0402050a3caa6b86412129cbfb55705ef6d9cb91ef85cb0fca21134e6
7
+ data.tar.gz: 7ab5cda4f44d57a15ad209a0315c2bce1355da107382cb35843b1844f32eb1a03af6c26263792c5c779298fe01a2fa5b21ee55a12aed5ae052d6f796fc3b0b71
data/lib/sslcheck.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "sslcheck/version"
2
2
  require 'openssl'
3
+ require 'active_support/all'
3
4
 
4
5
  module SSLCheck
5
6
  # Your code goes here...
@@ -108,6 +108,10 @@ module SSLCheck
108
108
  @clock.now > not_after
109
109
  end
110
110
 
111
+ def expires_in?(num_days)
112
+ (@clock.now.beginning_of_day + num_days.days) >= not_after.beginning_of_day
113
+ end
114
+
111
115
  def issued?
112
116
  @clock.now > not_before
113
117
  end
@@ -1,3 +1,3 @@
1
1
  module SSLCheck
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
@@ -130,5 +130,29 @@ module SSLCheck
130
130
  expect(@sut.issued?).to be
131
131
  end
132
132
  end
133
+ describe "days from expiration" do
134
+ it 'should know how many days until the certificate expires' do
135
+ expires_at = Certificate.new(VALID_CERT).not_after
136
+ clock = class_double(DateTime, :now => expires_at - 30.days)
137
+ @sut = Certificate.new(VALID_CERT, clock)
138
+ expect(@sut.expires_in?(30)).to be
139
+ end
140
+ context "when it's less than 1 day from expiring" do
141
+ it 'should still know that it is expiring' do
142
+ expires_at = Certificate.new(VALID_CERT).not_after
143
+ clock = class_double(DateTime, :now => expires_at - 12.hours)
144
+ @sut = Certificate.new(VALID_CERT, clock)
145
+ expect(@sut.expires_in?(1)).to be
146
+ end
147
+ end
148
+ context "when it's not expiring in the given timeframe" do
149
+ it 'should not think its expiring within the given number of days' do
150
+ expires_at = Certificate.new(VALID_CERT).not_after
151
+ clock = class_double(DateTime, :now => expires_at - 60.days)
152
+ @sut = Certificate.new(VALID_CERT, clock)
153
+ expect(@sut.expires_in?(30)).to_not be
154
+ end
155
+ end
156
+ end
133
157
  end
134
158
  end
data/sslcheck.gemspec CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_runtime_dependency "activesupport", "~> 4.2"
22
+
21
23
  spec.add_development_dependency "bundler", "~> 1.7"
22
24
  spec.add_development_dependency "rake", "~> 10.0"
23
25
  spec.add_development_dependency "rspec", "~> 3.1"
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sslcheck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clayton Lengel-Zigich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-25 00:00:00.000000000 Z
11
+ date: 2015-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement