source: other-projects/hathitrust/vagrant-solr-cluster/trunk/modules/stdlib/spec/acceptance/validate_augeas_spec.rb@ 30960

Last change on this file since 30960 was 30960, checked in by davidb, 7 years ago

Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster

  • Property svn:executable set to *
File size: 2.0 KB
Line 
1#! /usr/bin/env ruby -S rspec
2require 'spec_helper_acceptance'
3
4describe 'validate_augeas function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows')) do
5 describe 'prep' do
6 it 'installs augeas for tests'
7 end
8 describe 'success' do
9 context 'valid inputs with no 3rd argument' do
10 {
11 'root:x:0:0:root:/root:/bin/bash\n' => 'Passwd.lns',
12 'proc /proc proc nodev,noexec,nosuid 0 0\n' => 'Fstab.lns'
13 }.each do |line,lens|
14 it "validates a single argument for #{lens}" do
15 pp = <<-EOS
16 $line = "#{line}"
17 $lens = "#{lens}"
18 validate_augeas($line, $lens)
19 EOS
20
21 apply_manifest(pp, :catch_failures => true)
22 end
23 end
24 end
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'
28 lens = 'Passwd.lns'
29 restriction = '$file/*[shell="/bin/barsh"]'
30 pp = <<-EOS
31 $line = "#{line}"
32 $lens = "#{lens}"
33 $restriction = ['#{restriction}']
34 validate_augeas($line, $lens, $restriction, "my custom failure message")
35 EOS
36
37 expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/my custom failure message/)
38 end
39 end
40 context 'invalid inputs' do
41 {
42 'root:x:0:0:root' => 'Passwd.lns',
43 '127.0.1.1' => 'Hosts.lns'
44 }.each do |line,lens|
45 it "validates a single argument for #{lens}" do
46 pp = <<-EOS
47 $line = "#{line}"
48 $lens = "#{lens}"
49 validate_augeas($line, $lens)
50 EOS
51
52 apply_manifest(pp, :expect_failures => true)
53 end
54 end
55 end
56 context 'garbage inputs' do
57 it 'raises an error on invalid inputs'
58 end
59 end
60 describe 'failure' do
61 it 'handles improper number of arguments'
62 end
63end
Note: See TracBrowser for help on using the repository browser.