1 require 'spec_helper_acceptance'
3 describe 'validate_augeas function', :unless => (fact('osfamily') == 'windows') do
5 it 'installs augeas for tests'
8 context 'with valid inputs with no 3rd argument' do
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|
16 validate_augeas($line, $lens)
18 it "validates a single argument for #{lens}" do
19 apply_manifest(pp1, :catch_failures => true)
24 context 'with valid inputs with 3rd and 4th arguments' do
25 line = 'root:x:0:0:root:/root:/bin/barsh\n'
27 restriction = '$file/*[shell="/bin/barsh"]'
31 $restriction = ['#{restriction}']
32 validate_augeas($line, $lens, $restriction, "my custom failure message")
34 it 'validates a restricted value' do
35 expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{my custom failure message})
39 context 'with invalid inputs' do
41 'root:x:0:0:root' => 'Passwd.lns',
42 '127.0.1.1' => 'Hosts.lns',
43 }.each do |line, lens|
47 validate_augeas($line, $lens)
49 it "validates a single argument for #{lens}" do
50 apply_manifest(pp3, :expect_failures => true)
54 context 'with garbage inputs' do
55 it 'raises an error on invalid inputs'
59 it 'handles improper number of arguments'