Skip to content

Commit 7443e8b

Browse files
committed
Merge pull request #245 from hunner/fix_augeas
Fix the validate_augeas beaker tests
2 parents 143a007 + af49ef4 commit 7443e8b

File tree

2 files changed

+63
-41
lines changed

2 files changed

+63
-41
lines changed
+62-39
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,62 @@
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

spec/spec_helper_acceptance.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
if host.is_pe?
99
install_pe
1010
else
11-
install_package host, 'rubygems'
12-
on host, 'gem install puppet --no-ri --no-rdoc'
11+
install_puppet
1312
on host, "mkdir -p #{host['distmoduledir']}"
1413
end
1514
end

0 commit comments

Comments
 (0)