diff options
author | Josh Cooper <josh@puppet.com> | 2018-07-09 22:30:55 -0700 |
---|---|---|
committer | Josh Cooper <josh@puppet.com> | 2018-07-10 11:03:14 -0700 |
commit | fa61bde37d75c0482d0a0d8822d635a1bc02662b (patch) | |
tree | dfcc296fe48ae82e3cb5674f1119ba8ebd4616f8 /spec/acceptance/tests/pup_2289_should_not_destroy_data_when_malformed_spec.rb | |
parent | 9c626516d265d7b3aa7bee08f23be6a36a3d8280 (diff) | |
download | puppet-hosts_core-fa61bde37d75c0482d0a0d8822d635a1bc02662b.tar.gz puppet-hosts_core-fa61bde37d75c0482d0a0d8822d635a1bc02662b.tar.bz2 |
Rename beaker tests to end with _spec
Diffstat (limited to 'spec/acceptance/tests/pup_2289_should_not_destroy_data_when_malformed_spec.rb')
-rw-r--r-- | spec/acceptance/tests/pup_2289_should_not_destroy_data_when_malformed_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/acceptance/tests/pup_2289_should_not_destroy_data_when_malformed_spec.rb b/spec/acceptance/tests/pup_2289_should_not_destroy_data_when_malformed_spec.rb new file mode 100644 index 0000000..95cf6ed --- /dev/null +++ b/spec/acceptance/tests/pup_2289_should_not_destroy_data_when_malformed_spec.rb @@ -0,0 +1,31 @@ +test_name 'should not delete data when existing content is malformed' + +tag 'audit:low', + 'audit:refactor', # Use block style `test_name` + 'audit:acceptance' # Could be done at the integration (or unit) layer though +# actual changing of resources could irreparably damage a +# host running this, or require special permissions. + +agents.each do |agent| + file = agent.tmpfile('host-not-delete-data') + + teardown do + on(agent, "rm -f #{file}", acceptable_exit_codes: (0..255)) + end + + step '(setup) populate test file with host information' + on(agent, "printf '127.0.0.2 existing alias\n' > #{file}") + + step '(setup) populate test file with a malformed line' + on(agent, "printf '==\n' >> #{file}") + + step 'tell puppet to add another host entry' + on(agent, puppet_resource('host', 'test', "target=#{file}", + 'ensure=present', 'ip=127.0.0.3', 'host_aliases=foo')) + + step 'verify that the initial host entry was not deleted' + on(agent, "cat #{file}") do |res| + fail_test 'existing host data was deleted' unless + res.stdout.include? 'existing' + end +end |