5
5
6
6
require 'riemann/tools/tls_check'
7
7
8
- def gen_certificate ( not_before = Time . now , validity_duration_days = 90 )
8
+ def gen_certificate ( not_before , validity_duration_days )
9
9
certificate = OpenSSL ::X509 ::Certificate . new
10
10
certificate . not_before = not_before
11
11
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)
14
14
15
15
RSpec . describe Riemann ::Tools ::TLSCheck ::TLSCheckResult do
16
16
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 (
37
22
renewal_duration_ratio : 1.0 / 3 ,
38
23
renewal_duration_days : 90 ,
39
24
)
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 )
40
28
res
41
29
end
42
30
43
- let ( :certificate ) do
44
- gen_certificate ( not_before , validity_duration_days )
45
- end
46
-
47
31
let ( :not_before ) { Time . now }
48
32
let ( :validity_duration_days ) { 90 }
49
33
@@ -60,7 +44,7 @@ def gen_certificate(not_before = Time.now, validity_duration_days = 90)
60
44
it { is_expected . to eq ( 30 . days ) }
61
45
end
62
46
63
- context 'with short -lived certificates' do
47
+ context 'with long -lived certificates' do
64
48
let ( :validity_duration_days ) { 730 }
65
49
66
50
it { is_expected . to eq ( 90 . days ) }
0 commit comments