File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,28 @@ def crl_last_update=(time)
147
147
Puppet ::FileSystem . touch ( @crlpath , mtime : time )
148
148
end
149
149
150
+ # Return the time when the CA bundle was last updated.
151
+ #
152
+ # @return [Time, nil] Time when the CA bundle was last updated, or nil if we don't
153
+ # have a CA bundle
154
+ #
155
+ # @api private
156
+ def ca_last_update
157
+ stat = Puppet ::FileSystem . stat ( @capath )
158
+ Time . at ( stat . mtime )
159
+ rescue Errno ::ENOENT
160
+ nil
161
+ end
162
+
163
+ # Set the CA bundle last updated time.
164
+ #
165
+ # @param time [Time] The last updated time
166
+ #
167
+ # @api private
168
+ def ca_last_update = ( time )
169
+ Puppet ::FileSystem . touch ( @capath , mtime : time )
170
+ end
171
+
150
172
# Save named private key in the configured `privatekeydir`. For
151
173
# historical reasons, names are case insensitive.
152
174
#
Original file line number Diff line number Diff line change @@ -586,6 +586,32 @@ def expects_private_file(path)
586
586
end
587
587
end
588
588
589
+ context 'CA last update time' do
590
+ let ( :ca_path ) { tmpfile ( 'pem_ca' ) }
591
+
592
+ it 'returns nil if the CA does not exist' do
593
+ provider = create_provider ( capath : '/does/not/exist' )
594
+
595
+ expect ( provider . ca_last_update ) . to be_nil
596
+ end
597
+
598
+ it 'returns the last update time' do
599
+ time = Time . now - 30
600
+ Puppet ::FileSystem . touch ( ca_path , mtime : time )
601
+ provider = create_provider ( capath : ca_path )
602
+
603
+ expect ( provider . ca_last_update ) . to be_within ( 1 ) . of ( time )
604
+ end
605
+
606
+ it 'sets the last update time' do
607
+ time = Time . now - 30
608
+ provider = create_provider ( capath : ca_path )
609
+ provider . ca_last_update = time
610
+
611
+ expect ( Puppet ::FileSystem . stat ( ca_path ) . mtime ) . to be_within ( 1 ) . of ( time )
612
+ end
613
+ end
614
+
589
615
context 'CRL last update time' do
590
616
let ( :crl_path ) { tmpfile ( 'pem_crls' ) }
591
617
You can’t perform that action at this time.
0 commit comments