1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper_acceptance'
4 describe 'validate_augeas function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows')) do
6 it 'installs augeas for tests'
9 context 'valid inputs with no 3rd argument' do
11 'root:x:0:0:root:/root:/bin/bash\n' => 'Passwd.lns',
12 'proc /proc proc nodev,noexec,nosuid 0 0\n' => 'Fstab.lns'
14 it "validates a single argument for #{lens}" do
18 validate_augeas($line, $lens)
21 apply_manifest(pp, :catch_failures => true)
25 context 'valid inputs with 3rd and 4th arguments' do
26 it "validates a restricted value" do
27 line = 'root:x:0:0:root:/root:/bin/barsh\n'
29 restriction = '$file/*[shell="/bin/barsh"]'
33 $restriction = ['#{restriction}']
34 validate_augeas($line, $lens, $restriction, "my custom failure message")
37 expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/my custom failure message/)
40 context 'invalid inputs' do
42 'root:x:0:0:root' => 'Passwd.lns',
43 '127.0.1.1' => 'Hosts.lns'
45 it "validates a single argument for #{lens}" do
49 validate_augeas($line, $lens)
52 apply_manifest(pp, :expect_failures => true)
56 context 'garbage inputs' do
57 it 'raises an error on invalid inputs'
61 it 'handles improper number of arguments'