From e76bd24dcb33ab71440633303124ea99d59b7783 Mon Sep 17 00:00:00 2001 From: Enis Inan Date: Thu, 13 Dec 2018 02:10:54 -0800 Subject: (maint) Add more crontab provider tests This commit adds the following tests to the cron resource: * A test to ensure that the crontab provider writes the crontab file of a new user * A test to ensure that the crontab provider fails to write the crontab file of a nonexistent user * A test to ensure that the crontab provider writes an originally unauthorized user's crontab file _if_ Puppet authorizes them in the middle of the run These tests are part of the crontab provider's specifications and should have been added before. --- ...fail_to_write_a_nonexistent_users_crontab_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 spec/acceptance/tests/resource/cron/should_fail_to_write_a_nonexistent_users_crontab_spec.rb (limited to 'spec/acceptance/tests/resource/cron/should_fail_to_write_a_nonexistent_users_crontab_spec.rb') diff --git a/spec/acceptance/tests/resource/cron/should_fail_to_write_a_nonexistent_users_crontab_spec.rb b/spec/acceptance/tests/resource/cron/should_fail_to_write_a_nonexistent_users_crontab_spec.rb new file mode 100644 index 0000000..40fbbd9 --- /dev/null +++ b/spec/acceptance/tests/resource/cron/should_fail_to_write_a_nonexistent_users_crontab_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper_acceptance' + +RSpec.context 'when Puppet attempts to write the crontab of a nonexistent user' do + let(:nonexistent_username) { "pl#{rand(999_999).to_i}" } + + before(:each) do + step 'Ensure that the nonexistent user does not exist' do + compatible_agents.each do |agent| + user_absent(agent, nonexistent_username) + end + end + end + + compatible_agents.each do |agent| + it "should fail on #{agent}" do + manifest = cron_manifest('second_entry', command: 'ls', user: nonexistent_username) + apply_manifest_on(agent, manifest, expect_failures: true) + end + end +end -- cgit v1.2.3