Skip to content

Commit 27c7014

Browse files
committed
Pet rubocop
1 parent 4343f4f commit 27c7014

File tree

2 files changed

+14
-30
lines changed

2 files changed

+14
-30
lines changed

lib/riemann/tools/tls_check.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ def renewal_duration
146146
end
147147

148148
def expired_or_expire_soon?
149-
now + renewal_duration / 3 > not_after
149+
now + (renewal_duration / 3) > not_after
150150
end
151151

152152
def expire_soonish?
153-
now + 2 * renewal_duration / 3 > not_after
153+
now + (2 * renewal_duration / 3) > not_after
154154
end
155155

156156
def expired?
@@ -230,6 +230,8 @@ def check_ocsp_status
230230
opt :workers, 'Run this number of worker threads', short: :none, type: :integer, default: 20
231231

232232
def initialize
233+
super
234+
233235
@resolve_queue = Queue.new
234236
@work_queue = Queue.new
235237

@@ -266,8 +268,6 @@ def initialize
266268
end
267269
end
268270
end
269-
270-
super
271271
end
272272

273273
def tick

spec/riemann/tools/tls_check/tls_check_result_spec.rb

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
require 'riemann/tools/tls_check'
77

8-
def gen_certificate(not_before = Time.now, validity_duration_days = 90)
8+
def gen_certificate(not_before, validity_duration_days)
99
certificate = OpenSSL::X509::Certificate.new
1010
certificate.not_before = not_before
1111
certificate.not_after = certificate.not_before + validity_duration_days.days
@@ -14,36 +14,20 @@ def gen_certificate(not_before = Time.now, validity_duration_days = 90)
1414

1515
RSpec.describe Riemann::Tools::TLSCheck::TLSCheckResult do
1616
let(:tls_check_result) do
17-
res = described_class.new(uri, address, tls_socket, checker)
18-
allow(res).to receive(:peer_cert).and_return(certificate)
19-
res
20-
end
21-
22-
let(:uri) do
23-
URI('https://example.com')
24-
end
25-
26-
let(:address) do
27-
IPAddr.new('::1')
28-
end
29-
30-
let(:tls_socket) do
31-
double
32-
end
33-
34-
let(:checker) do
35-
res = double
36-
allow(res).to receive(:opts).and_return(
17+
uri = URI('https://example.com')
18+
address = IPAddr.new('::1')
19+
tls_socket = double
20+
checker = double
21+
allow(checker).to receive(:opts).and_return(
3722
renewal_duration_ratio: 1.0 / 3,
3823
renewal_duration_days: 90,
3924
)
25+
certificate = gen_certificate(not_before, validity_duration_days)
26+
res = described_class.new(uri, address, tls_socket, checker)
27+
allow(res).to receive(:peer_cert).and_return(certificate)
4028
res
4129
end
4230

43-
let(:certificate) do
44-
gen_certificate(not_before, validity_duration_days)
45-
end
46-
4731
let(:not_before) { Time.now }
4832
let(:validity_duration_days) { 90 }
4933

@@ -60,7 +44,7 @@ def gen_certificate(not_before = Time.now, validity_duration_days = 90)
6044
it { is_expected.to eq(30.days) }
6145
end
6246

63-
context 'with short-lived certificates' do
47+
context 'with long-lived certificates' do
6448
let(:validity_duration_days) { 730 }
6549

6650
it { is_expected.to eq(90.days) }

0 commit comments

Comments
 (0)