@@ -20,19 +20,13 @@ func init() {
2020
2121func TestVaultRenewDuration (t * testing.T ) {
2222 renewable := Secret {LeaseDuration : 100 , Renewable : true }
23- renewableDur , err := leaseCheckWait (& renewable )
24- if err != nil {
25- t .Fatal (err )
26- }
23+ renewableDur , _ := leaseCheckWait (& renewable )
2724 if renewableDur < 16 * time .Second || renewableDur >= 34 * time .Second {
2825 t .Fatalf ("renewable duration is not within 1/6 to 1/3 of lease duration: %s" , renewableDur )
2926 }
3027
3128 nonRenewable := Secret {LeaseDuration : 100 }
32- nonRenewableDur , err := leaseCheckWait (& nonRenewable )
33- if err != nil {
34- t .Fatal (err )
35- }
29+ nonRenewableDur , _ := leaseCheckWait (& nonRenewable )
3630 if nonRenewableDur < 80 * time .Second || nonRenewableDur > 95 * time .Second {
3731 t .Fatalf ("renewable duration is not within 80%% to 95%% of lease duration: %s" , nonRenewableDur )
3832 }
@@ -43,14 +37,10 @@ func TestVaultRenewDuration(t *testing.T) {
4337 }
4438
4539 nonRenewableRotated := Secret {LeaseDuration : 100 , Data : data }
46- nonRenewableRotatedDur , err := leaseCheckWait (& nonRenewableRotated )
47- if err != nil {
48- t .Fatal (err )
49- }
50-
40+ nonRenewableRotatedDur , _ := leaseCheckWait (& nonRenewableRotated )
5141 // We expect a 1 second cushion
5242 if nonRenewableRotatedDur != 31 * time .Second {
53- t .Fatalf ("renewable duration is not 31: %s " , nonRenewableRotatedDur )
43+ t .Fatalf ("renewable duration is not 31: %f " , nonRenewableRotatedDur . Seconds () )
5444 }
5545
5646 data = map [string ]interface {}{
@@ -59,23 +49,18 @@ func TestVaultRenewDuration(t *testing.T) {
5949 }
6050
6151 nonRenewableRotated = Secret {LeaseDuration : 100 , Data : data }
62- nonRenewableRotatedDur , err = leaseCheckWait (& nonRenewableRotated )
63- if err != nil {
64- t .Fatal (err )
65- }
66-
52+ nonRenewableRotatedDur , _ = leaseCheckWait (& nonRenewableRotated )
6753 // We expect a 1 second cushion
6854 if nonRenewableRotatedDur != 6 * time .Second {
69- t .Fatalf ("renewable duration is not 6: %s " , nonRenewableRotatedDur )
55+ t .Fatalf ("renewable duration is not 6: %f " , nonRenewableRotatedDur . Seconds () )
7056 }
71-
7257 // Test TTL=0 case - should return error
7358 data = map [string ]interface {}{
7459 "rotation_period" : json .Number ("30" ),
7560 "ttl" : json .Number ("0" ),
7661 }
7762 nonRenewableRotatedZero := Secret {LeaseDuration : 100 , Data : data }
78- _ , err = leaseCheckWait (& nonRenewableRotatedZero )
63+ _ , err : = leaseCheckWait (& nonRenewableRotatedZero )
7964 if err == nil {
8065 t .Fatalf ("expected error for ttl=0, got nil" )
8166 }
@@ -92,12 +77,9 @@ func TestVaultRenewDuration(t *testing.T) {
9277 }
9378
9479 nonRenewableCert := Secret {LeaseDuration : 100 , Data : data }
95- nonRenewableCertDur , err := leaseCheckWait (& nonRenewableCert )
96- if err != nil {
97- t .Fatal (err )
98- }
80+ nonRenewableCertDur , _ := leaseCheckWait (& nonRenewableCert )
9981 if nonRenewableCertDur < 80 * time .Second || nonRenewableCertDur > 95 * time .Second {
100- t .Fatalf ("non renewable certificate duration is not within 80%% to 95%%: %s " , nonRenewableCertDur )
82+ t .Fatalf ("non renewable certificate duration is not within 80%% to 95%%: %f " , nonRenewableCertDur . Seconds () )
10183 }
10284
10385 t .Run ("secret ID handling" , func (t * testing.T ) {
@@ -109,13 +91,11 @@ func TestVaultRenewDuration(t *testing.T) {
10991 }
11092
11193 nonRenewableSecretID := Secret {LeaseDuration : 100 , Data : data }
112- nonRenewableSecretIDDur , err := leaseCheckWait (& nonRenewableSecretID )
113- if err != nil {
114- t .Fatal (err )
115- }
94+ nonRenewableSecretIDDur , _ := leaseCheckWait (& nonRenewableSecretID )
95+ secs := nonRenewableSecretIDDur .Seconds ()
11696
117- if nonRenewableSecretIDDur . Seconds () < 0.80 * (60 + 1 ) || nonRenewableSecretIDDur . Seconds () > 0.95 * (60 + 1 ) {
118- t .Fatalf ("renewable duration is not within 80%% to 95%% of lease duration: %s " , nonRenewableSecretIDDur )
97+ if secs < 0.80 * (60 + 1 ) || secs > 0.95 * (60 + 1 ) {
98+ t .Fatalf ("renewable duration is not within 80%% to 95%% of lease duration: %f " , secs )
11999 }
120100 })
121101
@@ -128,13 +108,11 @@ func TestVaultRenewDuration(t *testing.T) {
128108 }
129109
130110 nonRenewableSecretID := Secret {LeaseDuration : leaseDuration , Data : data }
131- nonRenewableSecretIDDur , err := leaseCheckWait (& nonRenewableSecretID )
132- if err != nil {
133- t .Fatal (err )
134- }
111+ nonRenewableSecretIDDur , _ := leaseCheckWait (& nonRenewableSecretID )
112+ secs := nonRenewableSecretIDDur .Seconds ()
135113
136- if nonRenewableSecretIDDur . Seconds () < 0.80 * (leaseDuration + 1 ) || nonRenewableSecretIDDur . Seconds () > 0.95 * (leaseDuration + 1 ) {
137- t .Fatalf ("renewable duration is not within 80%% to 95%% of lease duration: %s " , nonRenewableSecretIDDur )
114+ if secs < 0.80 * (leaseDuration + 1 ) || secs > 0.95 * (leaseDuration + 1 ) {
115+ t .Fatalf ("renewable duration is not within 80%% to 95%% of lease duration: %f " , secs )
138116 }
139117 })
140118
@@ -146,13 +124,11 @@ func TestVaultRenewDuration(t *testing.T) {
146124 }
147125
148126 nonRenewableSecretID := Secret {LeaseDuration : leaseDuration , Data : data }
149- nonRenewableSecretIDDur , err := leaseCheckWait (& nonRenewableSecretID )
150- if err != nil {
151- t .Fatal (err )
152- }
127+ nonRenewableSecretIDDur , _ := leaseCheckWait (& nonRenewableSecretID )
128+ secs := nonRenewableSecretIDDur .Seconds ()
153129
154- if nonRenewableSecretIDDur . Seconds () < 0.80 * (leaseDuration + 1 ) || nonRenewableSecretIDDur . Seconds () > 0.95 * (leaseDuration + 1 ) {
155- t .Fatalf ("renewable duration is not within 80%% to 95%% of lease duration: %s " , nonRenewableSecretIDDur )
130+ if secs < 0.80 * (leaseDuration + 1 ) || secs > 0.95 * (leaseDuration + 1 ) {
131+ t .Fatalf ("renewable duration is not within 80%% to 95%% of lease duration: %f " , secs )
156132 }
157133 })
158134 })
0 commit comments