|
1 |
| -#require 'spec_helper_acceptance' |
2 |
| -# |
3 |
| -#describe 'validate_augeas function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do |
4 |
| -# describe 'prep' do |
5 |
| -# it 'installs augeas for tests' |
6 |
| -# end |
7 |
| -# describe 'success' do |
8 |
| -# it 'validates a single argument' do |
9 |
| -# pp = <<-EOS |
10 |
| -# $one = { 'a' => 1 } |
11 |
| -# validate_hash($one) |
12 |
| -# EOS |
13 |
| -# |
14 |
| -# apply_manifest(pp, :catch_failures => true) |
15 |
| -# end |
16 |
| -# it 'validates an multiple arguments' do |
17 |
| -# pp = <<-EOS |
18 |
| -# $one = { 'a' => 1 } |
19 |
| -# $two = { 'b' => 2 } |
20 |
| -# validate_hash($one,$two) |
21 |
| -# EOS |
22 |
| -# |
23 |
| -# apply_manifest(pp, :catch_failures => true) |
24 |
| -# end |
25 |
| -# it 'validates a non-hash' do |
26 |
| -# { |
27 |
| -# %{validate_hash('{ "not" => "hash" }')} => "String", |
28 |
| -# %{validate_hash('string')} => "String", |
29 |
| -# %{validate_hash(["array"])} => "Array", |
30 |
| -# %{validate_hash(undef)} => "String", |
31 |
| -# }.each do |pp,type| |
32 |
| -# expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/) |
33 |
| -# end |
34 |
| -# end |
35 |
| -# end |
36 |
| -# describe 'failure' do |
37 |
| -# it 'handles improper number of arguments' |
38 |
| -# end |
39 |
| -#end |
| 1 | +require 'spec_helper_acceptance' |
| 2 | + |
| 3 | +describe 'validate_augeas function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do |
| 4 | + describe 'prep' do |
| 5 | + it 'installs augeas for tests' |
| 6 | + end |
| 7 | + describe 'success' do |
| 8 | + context 'valid inputs with no 3rd argument' do |
| 9 | + { |
| 10 | + 'root:x:0:0:root:/root:/bin/bash\n' => 'Passwd.lns', |
| 11 | + 'proc /proc proc nodev,noexec,nosuid 0 0\n' => 'Fstab.lns' |
| 12 | + }.each do |line,lens| |
| 13 | + it "validates a single argument for #{lens}" do |
| 14 | + pp = <<-EOS |
| 15 | + $line = "#{line}" |
| 16 | + $lens = "#{lens}" |
| 17 | + validate_augeas($line, $lens) |
| 18 | + EOS |
| 19 | + |
| 20 | + apply_manifest(pp, :catch_failures => true) |
| 21 | + end |
| 22 | + end |
| 23 | + end |
| 24 | + context 'valid inputs with 3rd and 4th arguments' do |
| 25 | + it "validates a restricted value" do |
| 26 | + line = 'root:x:0:0:root:/root:/bin/barsh\n' |
| 27 | + lens = 'Passwd.lns' |
| 28 | + restriction = '$file/*[shell="/bin/barsh"]' |
| 29 | + pp = <<-EOS |
| 30 | + $line = "#{line}" |
| 31 | + $lens = "#{lens}" |
| 32 | + $restriction = ['#{restriction}'] |
| 33 | + validate_augeas($line, $lens, $restriction, "my custom failure message") |
| 34 | + EOS |
| 35 | + |
| 36 | + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/my custom failure message/) |
| 37 | + end |
| 38 | + end |
| 39 | + context 'invalid inputs' do |
| 40 | + { |
| 41 | + 'root:x:0:0:root' => 'Passwd.lns', |
| 42 | + '127.0.1.1' => 'Hosts.lns' |
| 43 | + }.each do |line,lens| |
| 44 | + it "validates a single argument for #{lens}" do |
| 45 | + pp = <<-EOS |
| 46 | + $line = "#{line}" |
| 47 | + $lens = "#{lens}" |
| 48 | + validate_augeas($line, $lens) |
| 49 | + EOS |
| 50 | + |
| 51 | + apply_manifest(pp, :expect_failures => true) |
| 52 | + end |
| 53 | + end |
| 54 | + end |
| 55 | + context 'garbage inputs' do |
| 56 | + it 'raises an error on invalid inputs' |
| 57 | + end |
| 58 | + end |
| 59 | + describe 'failure' do |
| 60 | + it 'handles improper number of arguments' |
| 61 | + end |
| 62 | +end |
0 commit comments