Skip to content

Commit 944cac4

Browse files
committed
(PUP-10639) Add integration tests
1 parent 55e66ad commit 944cac4

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

spec/integration/application/agent_spec.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,55 @@ def copy_fixtures(sources, dest)
896896
.and output(%r{Certificate 'CN=revoked' is revoked}).to_stderr
897897
end
898898
end
899+
900+
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+
now = Time.now
907+
yesterday = now - (60 * 60 * 24)
908+
Puppet::FileSystem.touch(ca, mtime: yesterday)
909+
Puppet::FileSystem.touch(crl, mtime: yesterday)
910+
911+
server.start_server do |port|
912+
Puppet[:serverport] = port
913+
Puppet[:ca_refresh_interval] = 1
914+
915+
expect {
916+
agent.command_line.args << '--test'
917+
agent.run
918+
}.to exit_with(0)
919+
.and output(/Info: Refreshed CA certificate: /).to_stdout
920+
end
921+
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
925+
end
926+
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+
now = Time.now
932+
yesterday = now - (60 * 60 * 24)
933+
Puppet::FileSystem.touch(crl, mtime: yesterday)
934+
935+
server.start_server do |port|
936+
Puppet[:serverport] = port
937+
Puppet[:crl_refresh_interval] = 1
938+
939+
expect {
940+
agent.command_line.args << '--test'
941+
agent.run
942+
}.to exit_with(0)
943+
.and output(/Info: Refreshed CRL: /).to_stdout
944+
end
945+
946+
expect(Puppet::FileSystem.stat(crl).mtime).to be >= now
947+
end
899948
end
900949

901950
context "legacy facts" do

0 commit comments

Comments
 (0)