diff options
author | Hunter Haugen <hunter@puppetlabs.com> | 2014-05-02 12:56:22 -0700 |
---|---|---|
committer | Hunter Haugen <hunter@puppetlabs.com> | 2014-05-02 12:56:22 -0700 |
commit | af49ef4ca2e4c2219c1c547bdc7f368d3eb777eb (patch) | |
tree | 1bbef627bf89a1f5cbe4d067e0959a68d1355f6f /spec | |
parent | 143a0078b01fdde118b19e89486b96644f1d5d7e (diff) | |
download | puppet-stdlib-af49ef4ca2e4c2219c1c547bdc7f368d3eb777eb.tar.gz puppet-stdlib-af49ef4ca2e4c2219c1c547bdc7f368d3eb777eb.tar.bz2 |
Fix the validate_augeas beaker tests
Diffstat (limited to 'spec')
-rw-r--r-- | spec/acceptance/validate_augeas_spec.rb | 101 | ||||
-rw-r--r-- | spec/spec_helper_acceptance.rb | 3 |
2 files changed, 63 insertions, 41 deletions
diff --git a/spec/acceptance/validate_augeas_spec.rb b/spec/acceptance/validate_augeas_spec.rb index 2175ada..98ee6d1 100644 --- a/spec/acceptance/validate_augeas_spec.rb +++ b/spec/acceptance/validate_augeas_spec.rb @@ -1,39 +1,62 @@ -#require 'spec_helper_acceptance' -# -#describe 'validate_augeas function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do -# describe 'prep' do -# it 'installs augeas for tests' -# end -# describe 'success' do -# it 'validates a single argument' do -# pp = <<-EOS -# $one = { 'a' => 1 } -# validate_hash($one) -# EOS -# -# apply_manifest(pp, :catch_failures => true) -# end -# it 'validates an multiple arguments' do -# pp = <<-EOS -# $one = { 'a' => 1 } -# $two = { 'b' => 2 } -# validate_hash($one,$two) -# EOS -# -# apply_manifest(pp, :catch_failures => true) -# end -# it 'validates a non-hash' do -# { -# %{validate_hash('{ "not" => "hash" }')} => "String", -# %{validate_hash('string')} => "String", -# %{validate_hash(["array"])} => "Array", -# %{validate_hash(undef)} => "String", -# }.each do |pp,type| -# expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/) -# end -# end -# end -# describe 'failure' do -# it 'handles improper number of arguments' -# end -#end +require 'spec_helper_acceptance' + +describe 'validate_augeas function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do + describe 'prep' do + it 'installs augeas for tests' + end + describe 'success' do + context 'valid inputs with no 3rd argument' do + { + 'root:x:0:0:root:/root:/bin/bash\n' => 'Passwd.lns', + 'proc /proc proc nodev,noexec,nosuid 0 0\n' => 'Fstab.lns' + }.each do |line,lens| + it "validates a single argument for #{lens}" do + pp = <<-EOS + $line = "#{line}" + $lens = "#{lens}" + validate_augeas($line, $lens) + EOS + + apply_manifest(pp, :catch_failures => true) + end + end + end + context 'valid inputs with 3rd and 4th arguments' do + it "validates a restricted value" do + line = 'root:x:0:0:root:/root:/bin/barsh\n' + lens = 'Passwd.lns' + restriction = '$file/*[shell="/bin/barsh"]' + pp = <<-EOS + $line = "#{line}" + $lens = "#{lens}" + $restriction = ['#{restriction}'] + validate_augeas($line, $lens, $restriction, "my custom failure message") + EOS + + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/my custom failure message/) + end + end + context 'invalid inputs' do + { + 'root:x:0:0:root' => 'Passwd.lns', + '127.0.1.1' => 'Hosts.lns' + }.each do |line,lens| + it "validates a single argument for #{lens}" do + pp = <<-EOS + $line = "#{line}" + $lens = "#{lens}" + validate_augeas($line, $lens) + EOS + + apply_manifest(pp, :expect_failures => true) + end + end + end + context 'garbage inputs' do + it 'raises an error on invalid inputs' + end + end + describe 'failure' do + it 'handles improper number of arguments' + end +end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index e9d0be8..1a0bba0 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -8,8 +8,7 @@ unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' if host.is_pe? install_pe else - install_package host, 'rubygems' - on host, 'gem install puppet --no-ri --no-rdoc' + install_puppet on host, "mkdir -p #{host['distmoduledir']}" end end |