Skip to content

Commit

Permalink
Pet rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
smortex committed May 31, 2024
1 parent 8c2a86f commit 4c06573
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
4 changes: 2 additions & 2 deletions lib/riemann/tools/tls_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ def check_ocsp_status
opt :workers, 'Run this number of worker threads', short: :none, type: :integer, default: 20

def initialize
super

@resolve_queue = Queue.new
@work_queue = Queue.new

Expand Down Expand Up @@ -266,8 +268,6 @@ def initialize
end
end
end

super
end

def tick
Expand Down
36 changes: 10 additions & 26 deletions spec/riemann/tools/tls_check/tls_check_result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

require 'riemann/tools/tls_check'

def gen_certificate(not_before = Time.now, validity_duration_days = 90)
def gen_certificate(not_before, validity_duration_days)
certificate = OpenSSL::X509::Certificate.new
certificate.not_before = not_before
certificate.not_after = certificate.not_before + validity_duration_days.days
Expand All @@ -14,36 +14,20 @@ def gen_certificate(not_before = Time.now, validity_duration_days = 90)

RSpec.describe Riemann::Tools::TLSCheck::TLSCheckResult do
let(:tls_check_result) do
res = described_class.new(uri, address, tls_socket, checker)
allow(res).to receive(:peer_cert).and_return(certificate)
res
end

let(:uri) do
URI('https://example.com')
end

let(:address) do
IPAddr.new('::1')
end

let(:tls_socket) do
double
end

let(:checker) do
res = double
allow(res).to receive(:opts).and_return(
uri = URI('https://example.com')
address = IPAddr.new('::1')
tls_socket = double
checker = double
allow(checker).to receive(:opts).and_return(
renewal_duration_ratio: 1.0 / 3,
renewal_duration_days: 90,
)
certificate = gen_certificate(not_before, validity_duration_days)
res = described_class.new(uri, address, tls_socket, checker)
allow(res).to receive(:peer_cert).and_return(certificate)
res
end

let(:certificate) do
gen_certificate(not_before, validity_duration_days)
end

let(:not_before) { Time.now }
let(:validity_duration_days) { 90 }

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

context 'with short-lived certificates' do
context 'with long-lived certificates' do
let(:validity_duration_days) { 730 }

it { is_expected.to eq(90.days) }
Expand Down

0 comments on commit 4c06573

Please sign in to comment.