15
15
let ( :node ) { Puppet ::Node . new ( Puppet [ :certname ] , environment : 'production' ) }
16
16
let ( :formatter ) { Puppet ::Network ::FormatHandler . format ( :rich_data_json ) }
17
17
18
+ # Create temp fixtures since the agent will attempt to refresh the CA/CRL
19
+ before do
20
+ Puppet [ :localcacert ] = ca = tmpfile ( 'ca' )
21
+ Puppet [ :hostcrl ] = crl = tmpfile ( 'crl' )
22
+
23
+ copy_fixtures ( %w[ ca.pem intermediate.pem ] , ca )
24
+ copy_fixtures ( %w[ crl.pem intermediate-crl.pem ] , crl )
25
+ end
26
+
27
+ def copy_fixtures ( sources , dest )
28
+ ssldir = File . join ( PuppetSpec ::FIXTURE_DIR , 'ssl' )
29
+ File . open ( dest , 'w' ) do |f |
30
+ sources . each do |s |
31
+ f . write ( File . read ( File . join ( ssldir , s ) ) )
32
+ end
33
+ end
34
+ end
35
+
18
36
context 'server_list' do
19
37
it "uses the first server in the list" do
20
38
Puppet [ :server_list ] = '127.0.0.1'
@@ -835,23 +853,10 @@ def with_another_agent_running(&block)
835
853
end
836
854
end
837
855
838
- def copy_fixtures ( sources , dest )
839
- ssldir = File . join ( PuppetSpec ::FIXTURE_DIR , 'ssl' )
840
- File . open ( dest , 'w' ) do |f |
841
- sources . each do |s |
842
- f . write ( File . read ( File . join ( ssldir , s ) ) )
843
- end
844
- end
845
- end
846
-
847
856
it "reloads the CRL between runs" do
848
- Puppet [ :localcacert ] = ca = tmpfile ( 'ca' )
849
- Puppet [ :hostcrl ] = crl = tmpfile ( 'crl' )
850
857
Puppet [ :hostcert ] = cert = tmpfile ( 'cert' )
851
858
Puppet [ :hostprivkey ] = key = tmpfile ( 'key' )
852
859
853
- copy_fixtures ( %w[ ca.pem intermediate.pem ] , ca )
854
- copy_fixtures ( %w[ crl.pem intermediate-crl.pem ] , crl )
855
860
copy_fixtures ( %w[ 127.0.0.1.pem ] , cert )
856
861
copy_fixtures ( %w[ 127.0.0.1-key.pem ] , key )
857
862
@@ -898,15 +903,10 @@ def copy_fixtures(sources, dest)
898
903
end
899
904
900
905
it "refreshes the CA and CRL" do
901
- Puppet [ :localcacert ] = ca = tmpfile ( 'ca' )
902
- Puppet [ :hostcrl ] = crl = tmpfile ( 'crl' )
903
- copy_fixtures ( %w[ ca.pem intermediate.pem ] , ca )
904
- copy_fixtures ( %w[ crl.pem intermediate-crl.pem ] , crl )
905
-
906
906
now = Time . now
907
907
yesterday = now - ( 60 * 60 * 24 )
908
- Puppet ::FileSystem . touch ( ca , mtime : yesterday )
909
- Puppet ::FileSystem . touch ( crl , mtime : yesterday )
908
+ Puppet ::FileSystem . touch ( Puppet [ :localcacert ] , mtime : yesterday )
909
+ Puppet ::FileSystem . touch ( Puppet [ :hostcrl ] , mtime : yesterday )
910
910
911
911
server . start_server do |port |
912
912
Puppet [ :serverport ] = port
@@ -920,17 +920,17 @@ def copy_fixtures(sources, dest)
920
920
end
921
921
922
922
# If the CA is updated, then the CRL must be updated too
923
- expect ( Puppet ::FileSystem . stat ( ca ) . mtime ) . to be >= now
924
- expect ( Puppet ::FileSystem . stat ( crl ) . mtime ) . to be >= now
923
+ expect ( Puppet ::FileSystem . stat ( Puppet [ :localcacert ] ) . mtime ) . to be >= now
924
+ expect ( Puppet ::FileSystem . stat ( Puppet [ :hostcrl ] ) . mtime ) . to be >= now
925
925
end
926
926
927
927
it "refreshes only the CRL" do
928
- Puppet [ :hostcrl ] = crl = tmpfile ( 'crl' )
929
- copy_fixtures ( %w[ crl.pem intermediate-crl.pem ] , crl )
930
-
931
928
now = Time . now
929
+ tomorrow = now + ( 60 * 60 * 24 )
930
+ Puppet ::FileSystem . touch ( Puppet [ :localcacert ] , mtime : tomorrow )
931
+
932
932
yesterday = now - ( 60 * 60 * 24 )
933
- Puppet ::FileSystem . touch ( crl , mtime : yesterday )
933
+ Puppet ::FileSystem . touch ( Puppet [ :hostcrl ] , mtime : yesterday )
934
934
935
935
server . start_server do |port |
936
936
Puppet [ :serverport ] = port
@@ -943,7 +943,7 @@ def copy_fixtures(sources, dest)
943
943
. and output ( /Info: Refreshed CRL: / ) . to_stdout
944
944
end
945
945
946
- expect ( Puppet ::FileSystem . stat ( crl ) . mtime ) . to be >= now
946
+ expect ( Puppet ::FileSystem . stat ( Puppet [ :hostcrl ] ) . mtime ) . to be >= now
947
947
end
948
948
end
949
949
0 commit comments