From 90216d84f8a2da1f77107dc5f0e3d76a3d72aacc Mon Sep 17 00:00:00 2001 From: Jorie Tappa Date: Tue, 31 Jul 2018 17:01:34 -0500 Subject: Apply automatic pdk validate fixes --- .../cron/should_allow_changing_parameters.rb | 64 +++++++++++----------- .../tests/resource/cron/should_be_idempotent.rb | 25 ++++----- .../tests/resource/cron/should_create_cron.rb | 23 ++++---- .../tests/resource/cron/should_match_existing.rb | 28 +++++----- .../tests/resource/cron/should_remove_cron.rb | 27 +++++---- ...hould_remove_leading_and_trailing_whitespace.rb | 36 ++++++------ .../tests/resource/cron/should_remove_matching.rb | 31 +++++------ .../tests/resource/cron/should_update_existing.rb | 30 +++++----- 8 files changed, 129 insertions(+), 135 deletions(-) (limited to 'spec/acceptance') diff --git a/spec/acceptance/tests/resource/cron/should_allow_changing_parameters.rb b/spec/acceptance/tests/resource/cron/should_allow_changing_parameters.rb index 4a14371..0e0821d 100644 --- a/spec/acceptance/tests/resource/cron/should_allow_changing_parameters.rb +++ b/spec/acceptance/tests/resource/cron/should_allow_changing_parameters.rb @@ -1,7 +1,7 @@ -test_name "Cron: should allow changing parameters after creation" -confine :except, :platform => 'windows' -confine :except, :platform => /^eos-/ # See PUP-5500 -confine :except, :platform => /^fedora-28/ +test_name 'Cron: should allow changing parameters after creation' +confine :except, platform: 'windows' +confine :except, platform: %r{^eos-} # See PUP-5500 +confine :except, platform: %r{^fedora-28} tag 'audit:medium', 'audit:refactor', # Use block style `test_name` 'audit:acceptance' # Could be done at the integration (or unit) layer though @@ -12,63 +12,61 @@ require 'puppet/acceptance/common_utils' extend Puppet::Acceptance::CronUtils teardown do - step "Cron: cleanup" + step 'Cron: cleanup' agents.each do |agent| clean agent end end - agents.each do |agent| - step "ensure the user exist via puppet" + step 'ensure the user exist via puppet' setup agent - step "Cron: basic - verify that it can be created" + step 'Cron: basic - verify that it can be created' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/false", user => "tstuser", hour => "*", minute => [1], ensure => present,}') do - assert_match( /ensure: created/, result.stdout, "err: #{agent}") + assert_match(%r{ensure: created}, result.stdout, "err: #{agent}") end - run_cron_on(agent,:list,'tstuser') do - assert_match(/.bin.false/, result.stdout, "err: #{agent}") + run_cron_on(agent, :list, 'tstuser') do + assert_match(%r{.bin.false}, result.stdout, "err: #{agent}") end - step "Cron: allow changing command" + step 'Cron: allow changing command' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present,}') do - assert_match(/command changed '.bin.false'.* to '.bin.true'/, result.stdout, "err: #{agent}") + assert_match(%r{command changed '.bin.false'.* to '.bin.true'}, result.stdout, "err: #{agent}") end - run_cron_on(agent,:list,'tstuser') do - assert_match(/1 . . . . .bin.true/, result.stdout, "err: #{agent}") + run_cron_on(agent, :list, 'tstuser') do + assert_match(%r{1 . . . . .bin.true}, result.stdout, "err: #{agent}") end - step "Cron: allow changing time" + step 'Cron: allow changing time' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "1", minute => [1], ensure => present,}') do - assert_match(/hour: defined 'hour' as \['1'\]/, result.stdout, "err: #{agent}") + assert_match(%r{hour: defined 'hour' as \['1'\]}, result.stdout, "err: #{agent}") end - run_cron_on(agent,:list,'tstuser') do - assert_match(/1 1 . . . .bin.true/, result.stdout, "err: #{agent}") + run_cron_on(agent, :list, 'tstuser') do + assert_match(%r{1 1 . . . .bin.true}, result.stdout, "err: #{agent}") end - step "Cron: allow changing time(array)" + step 'Cron: allow changing time(array)' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => ["1","2"], minute => [1], ensure => present,}') do - assert_match(/hour: hour changed \['1'\].* to \['1', '2'\]/, result.stdout, "err: #{agent}") + assert_match(%r{hour: hour changed \['1'\].* to \['1', '2'\]}, result.stdout, "err: #{agent}") end - run_cron_on(agent,:list,'tstuser') do - assert_match(/1 1,2 . . . .bin.true/, result.stdout, "err: #{agent}") + run_cron_on(agent, :list, 'tstuser') do + assert_match(%r{1 1,2 . . . .bin.true}, result.stdout, "err: #{agent}") end - step "Cron: allow changing time(array modification)" + step 'Cron: allow changing time(array modification)' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => ["3","2"], minute => [1], ensure => present,}') do - assert_match(/hour: hour changed \['1', '2'\].* to \['3', '2'\]/, result.stdout, "err: #{agent}") + assert_match(%r{hour: hour changed \['1', '2'\].* to \['3', '2'\]}, result.stdout, "err: #{agent}") end - run_cron_on(agent,:list,'tstuser') do - assert_match(/1 3,2 . . . .bin.true/, result.stdout, "err: #{agent}") + run_cron_on(agent, :list, 'tstuser') do + assert_match(%r{1 3,2 . . . .bin.true}, result.stdout, "err: #{agent}") end - step "Cron: allow changing time(array modification to *)" + step 'Cron: allow changing time(array modification to *)' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => "*", ensure => present,}') do - assert_match(/minute: undefined 'minute' from \['1'\]/,result.stdout, "err: #{agent}") - assert_match(/hour: undefined 'hour' from \['3', '2'\]/,result.stdout, "err: #{agent}") + assert_match(%r{minute: undefined 'minute' from \['1'\]}, result.stdout, "err: #{agent}") + assert_match(%r{hour: undefined 'hour' from \['3', '2'\]}, result.stdout, "err: #{agent}") end - run_cron_on(agent,:list,'tstuser') do - assert_match(/\* \* . . . .bin.true/, result.stdout, "err: #{agent}") + run_cron_on(agent, :list, 'tstuser') do + assert_match(%r{\* \* . . . .bin.true}, result.stdout, "err: #{agent}") end - end diff --git a/spec/acceptance/tests/resource/cron/should_be_idempotent.rb b/spec/acceptance/tests/resource/cron/should_be_idempotent.rb index 0d302c2..9b286f7 100644 --- a/spec/acceptance/tests/resource/cron/should_be_idempotent.rb +++ b/spec/acceptance/tests/resource/cron/should_be_idempotent.rb @@ -1,7 +1,7 @@ -test_name "Cron: check idempotency" -confine :except, :platform => 'windows' -confine :except, :platform => /^eos-/ # See PUP-5500 -confine :except, :platform => /^fedora-28/ +test_name 'Cron: check idempotency' +confine :except, platform: 'windows' +confine :except, platform: %r{^eos-} # See PUP-5500 +confine :except, platform: %r{^fedora-28} tag 'audit:medium', 'audit:refactor', # Use block style `test_name` 'audit:acceptance' # Could be done at the integration (or unit) layer though @@ -12,27 +12,26 @@ require 'puppet/acceptance/common_utils' extend Puppet::Acceptance::CronUtils teardown do - step "Cron: cleanup" + step 'Cron: cleanup' agents.each do |agent| clean agent end end - agents.each do |agent| - step "ensure the user exist via puppet" + step 'ensure the user exist via puppet' setup agent - step "Cron: basic - verify that it can be created" + step 'Cron: basic - verify that it can be created' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present,}') do - assert_match( /ensure: created/, result.stdout, "err: #{agent}") + assert_match(%r{ensure: created}, result.stdout, "err: #{agent}") end - run_cron_on(agent,:list,'tstuser') do - assert_match(/. . . . . .bin.true/, result.stdout, "err: #{agent}") + run_cron_on(agent, :list, 'tstuser') do + assert_match(%r{. . . . . .bin.true}, result.stdout, "err: #{agent}") end - step "Cron: basic - should not create again" + step 'Cron: basic - should not create again' apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present,}') do - assert_no_match( /ensure: created/, result.stdout, "err: #{agent}") + assert_no_match(%r{ensure: created}, result.stdout, "err: #{agent}") end end diff --git a/spec/acceptance/tests/resource/cron/should_create_cron.rb b/spec/acceptance/tests/resource/cron/should_create_cron.rb index 7c3b53f..29dcfc4 100644 --- a/spec/acceptance/tests/resource/cron/should_create_cron.rb +++ b/spec/acceptance/tests/resource/cron/should_create_cron.rb @@ -1,7 +1,7 @@ -test_name "should create cron" -confine :except, :platform => 'windows' -confine :except, :platform => /^eos-/ # See PUP-5500 -confine :except, :platform => /^fedora-28/ +test_name 'should create cron' +confine :except, platform: 'windows' +confine :except, platform: %r{^eos-} # See PUP-5500 +confine :except, platform: %r{^fedora-28} tag 'audit:medium', 'audit:refactor', # Use block style `test_name` 'audit:acceptance' # Could be done at the integration (or unit) layer though @@ -12,25 +12,24 @@ require 'puppet/acceptance/common_utils' extend Puppet::Acceptance::CronUtils teardown do - step "Cron: cleanup" + step 'Cron: cleanup' agents.each do |agent| clean agent end end agents.each do |host| - step "ensure the user exist via puppet" + step 'ensure the user exist via puppet' setup host - step "apply the resource on the host using puppet resource" - on(host, puppet_resource("cron", "crontest", "user=tstuser", - "command=/bin/true", "ensure=present")) do - assert_match(/created/, stdout, "Did not create crontab for tstuser on #{host}") + step 'apply the resource on the host using puppet resource' + on(host, puppet_resource('cron', 'crontest', 'user=tstuser', + 'command=/bin/true', 'ensure=present')) do + assert_match(%r{created}, stdout, "Did not create crontab for tstuser on #{host}") end - step "verify that crontab -l contains what you expected" + step 'verify that crontab -l contains what you expected' run_cron_on(host, :list, 'tstuser') do assert_match(/\* \* \* \* \* \/bin\/true/, stdout, "Incorrect crontab for tstuser on #{host}") end - end diff --git a/spec/acceptance/tests/resource/cron/should_match_existing.rb b/spec/acceptance/tests/resource/cron/should_match_existing.rb index a59d8ed..d309a84 100644 --- a/spec/acceptance/tests/resource/cron/should_match_existing.rb +++ b/spec/acceptance/tests/resource/cron/should_match_existing.rb @@ -1,35 +1,35 @@ -test_name "puppet should match existing job" -confine :except, :platform => 'windows' -confine :except, :platform => /^eos-/ # See PUP-5500 -confine :except, :platform => /^fedora-28/ +test_name 'puppet should match existing job' +confine :except, platform: 'windows' +confine :except, platform: %r{^eos-} # See PUP-5500 +confine :except, platform: %r{^fedora-28} tag 'audit:medium', - 'audit:refactor', # Use block style `test_name` + 'audit:refactor', # Use block style `test_name` 'audit:unit' require 'puppet/acceptance/common_utils' extend Puppet::Acceptance::CronUtils teardown do - step "Cron: cleanup" + step 'Cron: cleanup' agents.each do |agent| clean agent end end agents.each do |host| - step "ensure the user exist via puppet" + step 'ensure the user exist via puppet' setup host - step "Create the existing cron job by hand..." - run_cron_on(host,:add,'tstuser',"* * * * * /bin/true") + step 'Create the existing cron job by hand...' + run_cron_on(host, :add, 'tstuser', '* * * * * /bin/true') - step "Apply the resource on the host using puppet resource" - on(host, puppet_resource("cron", "crontest", "user=tstuser", - "command=/bin/true", "ensure=present")) do - assert_match(/present/, stdout, "Failed creating crontab for tstuser on #{host}") + step 'Apply the resource on the host using puppet resource' + on(host, puppet_resource('cron', 'crontest', 'user=tstuser', + 'command=/bin/true', 'ensure=present')) do + assert_match(%r{present}, stdout, "Failed creating crontab for tstuser on #{host}") end - step "Verify that crontab -l contains what you expected" + step 'Verify that crontab -l contains what you expected' run_cron_on(host, :list, 'tstuser') do assert_match(/\* \* \* \* \* \/bin\/true/, stdout, "Did not find crontab for tstuser on #{host}") end diff --git a/spec/acceptance/tests/resource/cron/should_remove_cron.rb b/spec/acceptance/tests/resource/cron/should_remove_cron.rb index 1320272..1759172 100644 --- a/spec/acceptance/tests/resource/cron/should_remove_cron.rb +++ b/spec/acceptance/tests/resource/cron/should_remove_cron.rb @@ -1,7 +1,7 @@ -test_name "puppet should remove a crontab entry as expected" -confine :except, :platform => 'windows' -confine :except, :platform => /^eos-/ # See PUP-5500 -confine :except, :platform => /^fedora-28/ +test_name 'puppet should remove a crontab entry as expected' +confine :except, platform: 'windows' +confine :except, platform: %r{^eos-} # See PUP-5500 +confine :except, platform: %r{^fedora-28} tag 'audit:medium', 'audit:refactor', # Use block style `test_name` 'audit:acceptance' # Could be done at the integration (or unit) layer though @@ -12,28 +12,27 @@ require 'puppet/acceptance/common_utils' extend Puppet::Acceptance::CronUtils teardown do - step "Cron: cleanup" + step 'Cron: cleanup' agents.each do |agent| clean agent end end agents.each do |host| - step "ensure the user exist via puppet" + step 'ensure the user exist via puppet' setup host - step "create the existing job by hand..." - run_cron_on(host,:add,'tstuser',"* * * * * /bin/true") + step 'create the existing job by hand...' + run_cron_on(host, :add, 'tstuser', '* * * * * /bin/true') - step "apply the resource on the host using puppet resource" - on(host, puppet_resource("cron", "crontest", "user=tstuser", - "command=/bin/true", "ensure=absent")) do - assert_match(/crontest\D+ensure:\s+removed/, stdout, "Didn't remove crobtab entry for tstuser on #{host}") + step 'apply the resource on the host using puppet resource' + on(host, puppet_resource('cron', 'crontest', 'user=tstuser', + 'command=/bin/true', 'ensure=absent')) do + assert_match(%r{crontest\D+ensure:\s+removed}, stdout, "Didn't remove crobtab entry for tstuser on #{host}") end - step "verify that crontab -l contains what you expected" + step 'verify that crontab -l contains what you expected' run_cron_on(host, :list, 'tstuser') do assert_no_match(/\/bin\/true/, stderr, "Error: Found entry for tstuser on #{host}") end - end diff --git a/spec/acceptance/tests/resource/cron/should_remove_leading_and_trailing_whitespace.rb b/spec/acceptance/tests/resource/cron/should_remove_leading_and_trailing_whitespace.rb index 33f7142..b643156 100644 --- a/spec/acceptance/tests/resource/cron/should_remove_leading_and_trailing_whitespace.rb +++ b/spec/acceptance/tests/resource/cron/should_remove_leading_and_trailing_whitespace.rb @@ -1,42 +1,42 @@ -test_name "(#656) leading and trailing whitespace in cron entries should should be stripped" -confine :except, :platform => 'windows' -confine :except, :platform => /^eos-/ # See PUP-5500 -confine :except, :platform => /^fedora-28/ +test_name '(#656) leading and trailing whitespace in cron entries should should be stripped' +confine :except, platform: 'windows' +confine :except, platform: %r{^eos-} # See PUP-5500 +confine :except, platform: %r{^fedora-28} tag 'audit:medium', - 'audit:refactor', # Use block style `test_name` + 'audit:refactor', # Use block style `test_name` 'audit:unit' require 'puppet/acceptance/common_utils' extend Puppet::Acceptance::CronUtils teardown do - step "Cron: cleanup" + step 'Cron: cleanup' agents.each do |agent| clean agent end end agents.each do |host| - step "create user account for testing cron entries" + step 'create user account for testing cron entries' setup host - step "apply the resource on the host using puppet resource" - on(host, puppet_resource("cron", "crontest", "user=tstuser", "command=' date > /dev/null '", "ensure=present")) do - assert_match(/created/, stdout, "Did not create crontab for tstuser on #{host}") + step 'apply the resource on the host using puppet resource' + on(host, puppet_resource('cron', 'crontest', 'user=tstuser', "command=' date > /dev/null '", 'ensure=present')) do + assert_match(%r{created}, stdout, "Did not create crontab for tstuser on #{host}") end - step "verify the added crontab entry has stripped whitespace" + step 'verify the added crontab entry has stripped whitespace' run_cron_on(host, :list, 'tstuser') do - assert_match(/\* \* \* \* \* date > .dev.null/, stdout, "Incorrect crontab for tstuser on #{host}") + assert_match(%r{\* \* \* \* \* date > .dev.null}, stdout, "Incorrect crontab for tstuser on #{host}") end - step "apply the resource with trailing whitespace and check nothing happened" - on(host, puppet_resource("cron", "crontest", "user=tstuser", "command='date > /dev/null '", "ensure=present")) do - assert_no_match(/ensure: created/, stdout, "Rewrote the line with trailing space in crontab for tstuser on #{host}") + step 'apply the resource with trailing whitespace and check nothing happened' + on(host, puppet_resource('cron', 'crontest', 'user=tstuser', "command='date > /dev/null '", 'ensure=present')) do + assert_no_match(%r{ensure: created}, stdout, "Rewrote the line with trailing space in crontab for tstuser on #{host}") end - step "apply the resource with leading whitespace and check nothing happened" - on(host, puppet_resource("cron", "crontest", "user=tstuser", "command=' date > /dev/null'", "ensure=present")) do - assert_no_match(/ensure: created/, stdout, "Rewrote the line with trailing space in crontab for tstuser on #{host}") + step 'apply the resource with leading whitespace and check nothing happened' + on(host, puppet_resource('cron', 'crontest', 'user=tstuser', "command=' date > /dev/null'", 'ensure=present')) do + assert_no_match(%r{ensure: created}, stdout, "Rewrote the line with trailing space in crontab for tstuser on #{host}") end end diff --git a/spec/acceptance/tests/resource/cron/should_remove_matching.rb b/spec/acceptance/tests/resource/cron/should_remove_matching.rb index 2857a4f..cfa3c17 100644 --- a/spec/acceptance/tests/resource/cron/should_remove_matching.rb +++ b/spec/acceptance/tests/resource/cron/should_remove_matching.rb @@ -1,7 +1,7 @@ -test_name "puppet should remove a crontab entry based on command matching" -confine :except, :platform => 'windows' -confine :except, :platform => /^eos-/ # See PUP-5500 -confine :except, :platform => /^fedora-28/ +test_name 'puppet should remove a crontab entry based on command matching' +confine :except, platform: 'windows' +confine :except, platform: %r{^eos-} # See PUP-5500 +confine :except, platform: %r{^fedora-28} tag 'audit:medium', 'audit:refactor', # Use block style `test_name` 'audit:acceptance' # Could be done at the integration (or unit) layer though @@ -12,29 +12,28 @@ require 'puppet/acceptance/common_utils' extend Puppet::Acceptance::CronUtils teardown do - step "Cron: cleanup" + step 'Cron: cleanup' agents.each do |agent| clean agent end end agents.each do |host| - step "ensure the user exist via puppet" + step 'ensure the user exist via puppet' setup host - step "create the existing job by hand..." - run_cron_on(host,:add,'tstuser',"* * * * * /bin/true") + step 'create the existing job by hand...' + run_cron_on(host, :add, 'tstuser', '* * * * * /bin/true') - step "Remove cron resource" - on(host, puppet_resource("cron", "bogus", "user=tstuser", - "command=/bin/true", "ensure=absent")) do - assert_match(/bogus\D+ensure: removed/, stdout, "Removing cron entry failed for tstuser on #{host}") + step 'Remove cron resource' + on(host, puppet_resource('cron', 'bogus', 'user=tstuser', + 'command=/bin/true', 'ensure=absent')) do + assert_match(%r{bogus\D+ensure: removed}, stdout, "Removing cron entry failed for tstuser on #{host}") end - step "verify that crontab -l contains what you expected" - run_cron_on(host,:list,'tstuser') do - count = stdout.scan("/bin/true").length + step 'verify that crontab -l contains what you expected' + run_cron_on(host, :list, 'tstuser') do + count = stdout.scan('/bin/true').length fail_test "found /bin/true the wrong number of times (#{count})" unless count == 0 end - end diff --git a/spec/acceptance/tests/resource/cron/should_update_existing.rb b/spec/acceptance/tests/resource/cron/should_update_existing.rb index a4bf177..eff634b 100644 --- a/spec/acceptance/tests/resource/cron/should_update_existing.rb +++ b/spec/acceptance/tests/resource/cron/should_update_existing.rb @@ -1,7 +1,7 @@ -test_name "puppet should update existing crontab entry" -confine :except, :platform => 'windows' -confine :except, :platform => /^eos-/ # See PUP-5500 -confine :except, :platform => /^fedora-28/ +test_name 'puppet should update existing crontab entry' +confine :except, platform: 'windows' +confine :except, platform: %r{^eos-} # See PUP-5500 +confine :except, platform: %r{^fedora-28} tag 'audit:medium', 'audit:refactor', # Use block style `test_name` 'audit:acceptance' # Could be done at the integration (or unit) layer though @@ -12,31 +12,31 @@ require 'puppet/acceptance/common_utils' extend Puppet::Acceptance::CronUtils teardown do - step "Cron: cleanup" + step 'Cron: cleanup' agents.each do |agent| clean agent end end agents.each do |host| - step "ensure the user exist via puppet" + step 'ensure the user exist via puppet' setup host - step "create the existing job by hand..." - run_cron_on(host,:add,'tstuser',"* * * * * /bin/true") + step 'create the existing job by hand...' + run_cron_on(host, :add, 'tstuser', '* * * * * /bin/true') - step "verify that crontab -l contains what you expected" - run_cron_on(host,:list,'tstuser') do + step 'verify that crontab -l contains what you expected' + run_cron_on(host, :list, 'tstuser') do assert_match(/\* \* \* \* \* \/bin\/true/, stdout, "Didn't find correct crobtab entry for tstuser on #{host}") end - step "apply the resource change on the host" - on(host, puppet_resource("cron", "crontest", "user=tstuser", "command=/bin/true", "ensure=present", "hour='0-6'")) do - assert_match(/hour\s+=>\s+\['0-6'\]/, stdout, "Modifying cron entry failed for tstuser on #{host}") + step 'apply the resource change on the host' + on(host, puppet_resource('cron', 'crontest', 'user=tstuser', 'command=/bin/true', 'ensure=present', "hour='0-6'")) do + assert_match(%r{hour\s+=>\s+\['0-6'\]}, stdout, "Modifying cron entry failed for tstuser on #{host}") end - step "verify that crontab -l contains what you expected" - run_cron_on(host,:list,'tstuser') do + step 'verify that crontab -l contains what you expected' + run_cron_on(host, :list, 'tstuser') do assert_match(/\* 0-6 \* \* \* \/bin\/true/, stdout, "Didn't find correctly modified time entry in crobtab entry for tstuser on #{host}") end end -- cgit v1.2.3