Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / acceptance / validate_augeas_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'validate_augeas function', :unless => (fact('osfamily') == 'windows') do
4   describe 'prep' do
5     it 'installs augeas for tests'
6   end
7   describe 'success' do
8     context 'with 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         pp1 = <<-DOC
14           $line = "#{line}"
15           $lens = "#{lens}"
16           validate_augeas($line, $lens)
17         DOC
18         it "validates a single argument for #{lens}" do
19           apply_manifest(pp1, :catch_failures => true)
20         end
21       end
22     end
23
24     context 'with valid inputs with 3rd and 4th arguments' do
25       line        = 'root:x:0:0:root:/root:/bin/barsh\n'
26       lens        = 'Passwd.lns'
27       restriction = '$file/*[shell="/bin/barsh"]'
28       pp2 = <<-DOC
29         $line        = "#{line}"
30         $lens        = "#{lens}"
31         $restriction = ['#{restriction}']
32         validate_augeas($line, $lens, $restriction, "my custom failure message")
33       DOC
34       it 'validates a restricted value' do
35         expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{my custom failure message})
36       end
37     end
38
39     context 'with 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         pp3 = <<-DOC
45           $line = "#{line}"
46           $lens = "#{lens}"
47           validate_augeas($line, $lens)
48         DOC
49         it "validates a single argument for #{lens}" do
50           apply_manifest(pp3, :expect_failures => true)
51         end
52       end
53     end
54     context 'with garbage inputs' do
55       it 'raises an error on invalid inputs'
56     end
57   end
58   describe 'failure' do
59     it 'handles improper number of arguments'
60   end
61 end