[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, 0.24.x, updated. puppet-0.24.5-rc3-457-g0dee418

Bryan Kearney bkearney at redhat.com
Wed Jun 9 19:49:07 UTC 2010


The following commit has been merged in the 0.24.x branch:
commit 9a264218419fdb0164246366de79ac65acee63cc
Author: Bryan Kearney <bkearney at redhat.com>
Date:   Thu Apr 9 09:59:15 2009 -0400

    Brought in lutters parse_commands patch and integrated it into the type.
    This includes reworking the get and match commands as well. This change
    introduces a few small changes. These are:
    
    1) There can be no ' or " characters around path elements.
    2) The context is now only prepended to relative paths. So, if a
    path is specified as /foo/bar the context will not be appended. It
    will only be appended if it is foo/bar
    3) The syntax for array matching in the onlyif is now eq or noteq.
    It was == before.
    4) The get and set commnands used to concatenate all items at the end
    of a string so "set path to some value" would be interpreted as
    "set" "path" "to some value". This is no longer supported. The caller
    must put ' or " around the "to some value" for it to work"

diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb
index 56e217a..618b672 100644
--- a/lib/puppet/provider/augeas/augeas.rb
+++ b/lib/puppet/provider/augeas/augeas.rb
@@ -18,6 +18,7 @@
 # Author: Bryan Kearney <bkearney at redhat.com>
 
 require 'augeas' if Puppet.features.augeas?
+require 'strscan'
 
 Puppet::Type.type(:augeas).provide(:augeas) do
     include Puppet::Util
@@ -29,6 +30,22 @@ Puppet::Type.type(:augeas).provide(:augeas) do
     SAVE_NOOP = "noop"
     SAVE_OVERWRITE = "overwrite"
 
+    COMMANDS = {
+      "set" => [ :path, :string ],
+      "rm" => [ :path ],
+      "clear" => [ :path ],
+      "insert" => [ :string, :string, :path ],
+      "get" => [ :path, :comparator, :string ],
+      "match" => [ :path, :glob ],
+      "size" => [:comparator, :int],
+      "include" => [:string],
+      "eq" => [:glob],
+      "noteq" => [:glob]
+    }
+
+    COMMANDS["ins"] = COMMANDS["insert"]
+    COMMANDS["remove"] = COMMANDS["rm"]    
+
     attr_accessor :aug
 
     # Extracts an 2 dimensional array of commands which are in the
@@ -38,42 +55,76 @@ Puppet::Type.type(:augeas).provide(:augeas) do
     # - A string with many commands per line
     # - An array of strings.
     def parse_commands(data)
-        commands = Array.new()
+        context = resource[:context]
+        # Add a trailing / if it is not there
+        if (context.length > 0)
+            context << "/" if context[-1, 1] != "/"
+        end
+
         if data.is_a?(String)
-            data.each_line do |line|
-                cmd_array = Array.new()
-                single = line.index("'")
-                double = line.index('"')
-                tokens = nil
-                delim = " "
-                if ((single != nil) or (double != nil))
-                    single = 99999 if single == nil
-                    double = 99999 if double == nil
-                    delim = '"' if double < single
-                    delim = "'" if single < double
-                end
-                tokens = line.split(delim)
-                # If the length of tokens is 2, thn that means the pattern was
-                # command file "some text", therefore we need to re-split
-                # the first line
-                if tokens.length == 2
-                    tokens = (tokens[0].split(" ")) << tokens[1]
+            s = data
+            data = []
+            s.each_line { |line| data << line }
+        end
+        args = []
+        data.each do |line|
+            argline = []
+            sc = StringScanner.new(line)
+            cmd = sc.scan(/\w+/)
+            formals = COMMANDS[cmd]
+            fail("Unknown command #{cmd}") unless formals
+            argline << cmd
+            narg = 0
+            formals.each do |f|
+                sc.skip(/\s+/)
+                narg += 1
+                if f == :path
+                    start = sc.pos
+                    nbracket = 0
+                    begin
+                        sc.skip(/[^\]\[\s]+/)
+                        ch = sc.getch
+                        nbracket += 1 if ch == "["
+                        nbracket -= 1 if ch == "]"
+                        fail("unmatched [") if nbracket < 0
+                    end until nbracket == 0 && (sc.eos? || ch =~ /\s/)
+                        len = sc.pos - start
+                        len -= 1 unless sc.eos?
+                    unless p = sc.string[start, len]
+                        fail("missing path argument #{narg} for #{cmd}")
+                    end
+                    if p[0,1] != "$" && p[0,1] != "/"
+                        argline << context + p
+                    else
+                        argline << p
+                    end
+                elsif f == :string
+                    delim = sc.peek(1)
+                    if delim == "'" || delim == "\""
+                        sc.getch
+                        argline << sc.scan(/([^\\#{delim}]|(\\.))*/)
+                        sc.getch
+                    else
+                        argline << sc.scan(/[^\s]+/)
+                    end
+                    unless argline[-1]
+                        fail(raise Exception, "missing string argument #{narg} for #{cmd}")
+                    end
+                elsif f == :comparator
+                    argline << sc.scan(/(==|!=|=~|<|<=|>|>=)/)
+                    unless argline[-1]
+                        puts sc.rest() 
+                        fail(raise Exception, "invalid comparator for command #{cmd}")
+                    end
+                elsif f == :int
+                    argline << sc.scan(/\d+/).to_i
+                elsif f== :glob
+                    argline << sc.rest()
                 end
-                cmd = tokens.shift().strip()
-                delim = "" if delim == " "
-                file = tokens.shift().strip()
-                other = tokens.join(" ").strip()
-                cmd_array << cmd if !cmd.nil?
-                cmd_array << file if !file.nil?
-                cmd_array << other if other != ""
-                commands << cmd_array
-            end
-        elsif data.is_a?(Array)
-            data.each do |datum|
-                commands.concat(parse_commands(datum))
             end
+            args << argline
         end
-        return commands
+        return args
     end
 
 
@@ -137,10 +188,13 @@ Puppet::Type.type(:augeas).provide(:augeas) do
         return_value = false
 
         #validate and tear apart the command
-        fail("Invalid command: #{cmd_array.join(" ")}") if cmd_array.length < 4
+        fail("Invalid command: #{cmd_array.join(" ")}") if cmd_array.length < 3
         cmd = cmd_array.shift()
         path = cmd_array.shift()
-        verb = cmd_array.shift()
+
+        # Need to break apart the clause
+        clause_array = parse_commands(cmd_array.shift())[0]
+        verb = clause_array.shift()
 
         #Get the values from augeas
         result = @aug.match(path) || ''
@@ -148,21 +202,29 @@ Puppet::Type.type(:augeas).provide(:augeas) do
         unless (result.nil?)
             case verb
                 when "size":
-                    fail("Invalid command: #{cmd_array.join(" ")}") if cmd_array.length != 2
-                    comparator = cmd_array.shift()
-                    arg = cmd_array.shift().to_i
+                    fail("Invalid command: #{cmd_array.join(" ")}") if clause_array.length != 2
+                    comparator = clause_array.shift()
+                    arg = clause_array.shift()
                     return_value = true if (result.size.send(comparator, arg))
                 when "include":
-                    arg = cmd_array.join(" ")
+                    arg = clause_array.shift()
                     return_value = true if result.include?(arg)
-                when "==":
+                when "eq":
                     begin
-                        arg = cmd_array.join(" ")
+                        arg = clause_array.shift()
                         new_array = eval arg
                         return_value = true if result == new_array
                     rescue
                         fail("Invalid array in command: #{cmd_array.join(" ")}")
                     end
+                when "noteq":
+                    begin
+                        arg = clause_array.shift()
+                        new_array = eval arg
+                        return_value = true if result != new_array
+                    rescue
+                        fail("Invalid array in command: #{cmd_array.join(" ")}")
+                    end                    
             end
         end
         return_value
@@ -188,11 +250,9 @@ Puppet::Type.type(:augeas).provide(:augeas) do
         self.open_augeas()
         filter = resource[:onlyif]
         unless (filter == "")
-            cmd_array = filter.split
+            cmd_array = parse_commands(filter)[0]
             command = cmd_array[0];
-            cmd_array[1]= File.join(resource[:context], cmd_array[1])
             begin
-                data = nil
                 case command
                     when "get" then return_value = process_get(cmd_array)
                     when "match" then return_value = process_match(cmd_array)
@@ -244,35 +304,26 @@ Puppet::Type.type(:augeas).provide(:augeas) do
 
     # Actually execute the augeas changes.
     def do_execute_changes
-        commands = resource[:changes].clone()
-        context = resource[:context]
+        commands = parse_commands(resource[:changes])
         commands.each do |cmd_array|
-            cmd_array = cmd_array.clone()
             fail("invalid command #{cmd_array.join[" "]}") if cmd_array.length < 2
             command = cmd_array[0]
             cmd_array.shift()
             begin
                 case command
                     when "set":
-                        cmd_array[0]=File.join(context, cmd_array[0])
                         debug("sending command '#{command}' with params #{cmd_array.inspect}")
                         @aug.set(cmd_array[0], cmd_array[1])
                     when "rm", "remove":
-                        cmd_array[0]=File.join(context, cmd_array[0])
                         debug("sending command '#{command}' with params #{cmd_array.inspect}")
                         @aug.rm(cmd_array[0])
                     when "clear":
-                        cmd_array[0]=File.join(context, cmd_array[0])
                         debug("sending command '#{command}' with params #{cmd_array.inspect}")
                         @aug.clear(cmd_array[0])
                     when "insert", "ins"
-                        ext_array = cmd_array[1].split(" ") ;
-                        if cmd_array.size < 2 or ext_array.size < 2
-                            fail("ins requires 3 parameters")
-                        end
                         label = cmd_array[0]
-                        where = ext_array[0]
-                        path = File.join(context, ext_array[1])
+                        where = cmd_array[1]
+                        path = cmd_array[2]
                         case where
                             when "before": before = true
                             when "after": before = false
diff --git a/lib/puppet/type/augeas.rb b/lib/puppet/type/augeas.rb
index da9cff3..3022cbf 100644
--- a/lib/puppet/type/augeas.rb
+++ b/lib/puppet/type/augeas.rb
@@ -58,7 +58,9 @@ Puppet::Type.newtype(:augeas) do
     end
 
     newparam (:context) do
-        desc "Optional context path. This value is pre-pended to the paths of all changes"
+        desc "Optional context path. This value is pre-pended to the paths of all changes if the
+              path is relative. So a path specified as /files/foo will not be prepended with the
+              context whild files/foo will be prepended"
         defaultto ""
     end
 
@@ -69,7 +71,8 @@ Puppet::Type.newtype(:augeas) do
                get [AUGEAS_PATH] [COMPARATOR] [STRING]
                match [MATCH_PATH] size [COMPARATOR] [INT]
                match [MATCH_PATH] include [STRING]
-               match [MATCH_PATH] == [AN_ARRAY]
+               match [MATCH_PATH] eq [AN_ARRAY]
+               match [MATCH_PATH] noteq [AN_ARRAY]               
 
              where::
 
@@ -97,10 +100,6 @@ Puppet::Type.newtype(:augeas) do
           insert [LABEL] [WHERE] [PATH]
                                  Synonym for ins
         If the parameter 'context' is set that value is prepended to PATH"
-
-        munge do |value|
-            provider.parse_commands(value)
-        end
     end
 
 
diff --git a/spec/unit/provider/augeas/augeas.rb b/spec/unit/provider/augeas/augeas.rb
index 2841456..44f9bd5 100644
--- a/spec/unit/provider/augeas/augeas.rb
+++ b/spec/unit/provider/augeas/augeas.rb
@@ -5,135 +5,120 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
 provider_class = Puppet::Type.type(:augeas).provider(:augeas)
 
 describe provider_class do
+        
     describe "command parsing" do
-        it "should break apart a single line into three tokens" do
-            provider = provider_class.new()
-            tokens = provider.parse_commands("set /Jar/Jar Binks")
+        before do
+            @resource = stub("resource")          
+            @provider = provider_class.new(@resource)
+        end
+        
+        it "should break apart a single line into three tokens and clean up the context" do
+            @resource.stubs(:[]).returns("/context")          
+            tokens = @provider.parse_commands("set Jar/Jar Binks")      
             tokens.size.should == 1
             tokens[0].size.should == 3
             tokens[0][0].should == "set"
-            tokens[0][1].should == "/Jar/Jar"
+            tokens[0][1].should == "/context/Jar/Jar"
             tokens[0][2].should == "Binks"
         end
 
         it "should break apart a multiple line into six tokens" do
-            provider = provider_class.new()
-            tokens = provider.parse_commands("set /Jar/Jar Binks\nrm anakin skywalker")
+            @resource.stubs(:[]).returns("")              
+            tokens = @provider.parse_commands("set /Jar/Jar Binks\nrm anakin")           
             tokens.size.should == 2
             tokens[0].size.should == 3
-            tokens[1].size.should == 3
+            tokens[1].size.should == 2
             tokens[0][0].should == "set"
             tokens[0][1].should == "/Jar/Jar"
             tokens[0][2].should == "Binks"
             tokens[1][0].should == "rm"
             tokens[1][1].should == "anakin"
-            tokens[1][2].should == "skywalker"
         end
 
         it "should handle arrays" do
-            provider = provider_class.new()
-            commands = ["set /Jar/Jar Binks", "rm anakin skywalker"]
-            tokens = provider.parse_commands(commands)
+            @resource.stubs(:[]).returns("/foo/")            
+            commands = ["set /Jar/Jar Binks", "rm anakin"]
+            tokens = @provider.parse_commands(commands)
             tokens.size.should == 2
             tokens[0].size.should == 3
-            tokens[1].size.should == 3
+            tokens[1].size.should == 2
             tokens[0][0].should == "set"
             tokens[0][1].should == "/Jar/Jar"
             tokens[0][2].should == "Binks"
             tokens[1][0].should == "rm"
-            tokens[1][1].should == "anakin"
-            tokens[1][2].should == "skywalker"
-        end
-
-        it "should concat the last values" do
-            provider = provider_class.new()
-            tokens = provider.parse_commands("set /Jar/Jar Binks is my copilot")
+            tokens[1][1].should == "/foo/anakin"
+        end
+
+        # This is not supported in the new parsing class
+        #it "should concat the last values" do
+        #    provider = provider_class.new()
+        #    tokens = provider.parse_commands("set /Jar/Jar Binks is my copilot")
+        #    tokens.size.should == 1
+        #    tokens[0].size.should == 3
+        #    tokens[0][0].should == "set"
+        #    tokens[0][1].should == "/Jar/Jar"
+        #    tokens[0][2].should == "Binks is my copilot"
+        #end
+
+        it "should accept spaces in the value and single ticks" do
+            @resource.stubs(:[]).returns("/foo/")           
+            tokens = @provider.parse_commands("set JarJar 'Binks is my copilot'")
             tokens.size.should == 1
             tokens[0].size.should == 3
             tokens[0][0].should == "set"
-            tokens[0][1].should == "/Jar/Jar"
+            tokens[0][1].should == "/foo/JarJar"
             tokens[0][2].should == "Binks is my copilot"
         end
 
-        it "should accept spaces and and single ticks" do
-            provider = provider_class.new()
-            tokens = provider.parse_commands("set 'Jar Jar' Binks")
-            tokens.size.should == 1
-            tokens[0].size.should == 3
-            tokens[0][0].should == "set"
-            tokens[0][1].should == "Jar Jar"
-            tokens[0][2].should == "Binks"
-        end
-
-        it "should accept spaces in the value and and single ticks" do
-            provider = provider_class.new()
-            tokens = provider.parse_commands("set 'Jar Jar' 'Binks is my copilot'")
-            tokens.size.should == 1
-            tokens[0].size.should == 3
-            tokens[0][0].should == "set"
-            tokens[0][1].should == "Jar Jar"
-            tokens[0][2].should == "Binks is my copilot"
-        end
-
-        it "should accept spaces and and double ticks" do
-            provider = provider_class.new()
-            tokens = provider.parse_commands('set "Jar Jar" Binks')
-            tokens.size.should == 1
-            tokens[0].size.should == 3
-            tokens[0][0].should == "set"
-            tokens[0][1].should == 'Jar Jar'
-            tokens[0][2].should == 'Binks'
-        end
-
-        it "should accept spaces in the value and and double ticks" do
-            provider = provider_class.new()
-            tokens = provider.parse_commands('set "Jar Jar" "Binks is my copilot"')
+        it "should accept spaces in the value and double ticks" do
+            @resource.stubs(:[]).returns("/foo/") 
+            tokens = @provider.parse_commands('set /JarJar "Binks is my copilot"')
             tokens.size.should == 1
             tokens[0].size.should == 3
             tokens[0][0].should == "set"
-            tokens[0][1].should == 'Jar Jar'
+            tokens[0][1].should == '/JarJar'
             tokens[0][2].should == 'Binks is my copilot'
         end
 
         it "should accept mixed ticks" do
-            provider = provider_class.new()
-            tokens = provider.parse_commands('set "Jar Jar" "Some \'Test\'"')
+            @resource.stubs(:[]).returns("/foo/") 
+            tokens = @provider.parse_commands('set JarJar "Some \'Test\'"')
             tokens.size.should == 1
             tokens[0].size.should == 3
             tokens[0][0].should == "set"
-            tokens[0][1].should == 'Jar Jar'
+            tokens[0][1].should == '/foo/JarJar'
             tokens[0][2].should == "Some \'Test\'"
         end
 
-        it "should accept only the last value using ticks" do
-            provider = provider_class.new()
-            tokens = provider.parse_commands('set /Jar/Jar "Binks is my copilot"')
-            tokens.size.should == 1
-            tokens[0].size.should == 3
-            tokens[0][0].should == "set"
-            tokens[0][1].should == '/Jar/Jar'
-            tokens[0][2].should == "Binks is my copilot"
+        it "should handle complex rm calls" do
+            @resource.stubs(:[]).returns("/foo/") 
+            tokens = @provider.parse_commands("rm */*[module='pam_console.so']")
+            tokens.should == [["rm", "/foo/*/*[module='pam_console.so']"]]
         end
 
-        it "should accept only the first value using ticks" do
-            provider = provider_class.new()
-            tokens = provider.parse_commands('set "Jar Jar" copilot')
-            tokens.size.should == 1
-            tokens[0].size.should == 3
-            tokens[0][0].should == "set"
-            tokens[0][1].should == 'Jar Jar'
-            tokens[0][2].should == "copilot"
+        it "should handle insert with xpath queries" do
+            @resource.stubs(:[]).returns("/foo/") 
+            tokens = @provider.parse_commands("ins 42 before /files/etc/hosts/*/ipaddr[ . = '127.0.0.1' ]")
+            tokens.should == [["ins", "42", "before","/files/etc/hosts/*/ipaddr[ . = '127.0.0.1' ]"]]        
         end
 
-        it "should accept only the first value using ticks and the last values being concatenated" do
-            provider = provider_class.new()
-            tokens = provider.parse_commands('set "Jar Jar" Binks is my copilot')
-            tokens.size.should == 1
-            tokens[0].size.should == 3
-            tokens[0][0].should == "set"
-            tokens[0][1].should == 'Jar Jar'
-            tokens[0][2].should == "Binks is my copilot"
+        it "should handle set with xpath queries" do
+            @resource.stubs(:[]).returns("/foo/") 
+            tokens = @provider.parse_commands("set /files/etc/*/*[ipaddr = '127.0.0.1'] \"foo bar\"")
+            tokens.should == [["set", "/files/etc/*/*[ipaddr = '127.0.0.1']", "foo bar"]]        
+        end
+
+        it "should handle clear with xpath queries" do
+            @resource.stubs(:[]).returns("/foo/") 
+            tokens = @provider.parse_commands("clear pam.d/*/*[module = 'system-auth'][type = 'account']")
+            tokens.should == [["clear", "/foo/pam.d/*/*[module = 'system-auth'][type = 'account']"]]       
         end
+
+        it "should handle some odd test" do
+            @resource.stubs(:[]).returns("/foo/") 
+            tokens = @provider.parse_commands("set /foo \"''\\\"''\"")
+            tokens.should == [[ "set", "/foo", "''\\\"''" ]]       
+        end    
     end
 
     describe "get filters" do
@@ -166,46 +151,57 @@ describe provider_class do
 
     describe "match filters" do
         before do
+            resource = stub("resource", :[] => "")
             augeas_stub = stub("augeas", :match => ["set", "of", "values"])
-            @provider = provider_class.new()
+            @provider = provider_class.new(resource)
             @provider.aug= augeas_stub
         end
 
         it "should return true for size match" do
-            command = ["match", "fake value", "size", "==", "3"]
+            command = ["match", "fake value", "size == 3"]
             @provider.process_match(command).should == true
         end
 
         it "should return false for a size non match" do
-            command = ["match", "fake value", "size", "<", "3"]
+            command = ["match", "fake value", "size < 3"]
             @provider.process_match(command).should == false
         end
 
         it "should return true for includes match" do
-            command = ["get", "fake value", "include", "values"]
+            command = ["match", "fake value", "include values"]
             @provider.process_match(command).should == true
         end
 
         it "should return false for includes non match" do
-            command = ["get", "fake value", "include", "JarJar"]
+            command = ["match", "fake value", "include JarJar"]
             @provider.process_match(command).should == false
         end
 
         it "should return true for an array match" do
-            command = ["get", "fake value", "==", "['set', 'of', 'values']"]
+            command = ["match", "fake value", "eq ['set', 'of', 'values']"]
             @provider.process_match(command).should == true
         end
 
         it "should return false for an array non match" do
-            command = ["get", "fake value", "==", "['this', 'should', 'not', 'match']"]
+            command = ["match", "fake value", "eq ['this', 'should', 'not', 'match']"]
+            @provider.process_match(command).should == false
+        end
+
+        it "should return false for an array match with noteq" do
+            command = ["match", "fake value", "noteq ['set', 'of', 'values']"]
             @provider.process_match(command).should == false
         end
+
+        it "should return true for an array non match with noteq" do
+            command = ["match", "fake value", "noteq ['this', 'should', 'not', 'match']"]
+            @provider.process_match(command).should == true
+        end        
     end
 
     describe "need to run" do
         it "should handle no filters" do
             resource = stub("resource")
-            resource.stubs(:[]).returns(false).then.returns("")
+            resource.stubs(:[]).returns(false).then.returns("").then.returns("")
             augeas_stub = stub("augeas", :match => ["set", "of", "values"])
             augeas_stub.stubs("close")
             provider = provider_class.new(resource)
@@ -215,7 +211,7 @@ describe provider_class do
 
         it "should return true when a get filter matches" do
             resource = stub("resource")
-            resource.stubs(:[]).returns(false).then.returns("get path == value")
+            resource.stubs(:[]).returns(false).then.returns("get path == value").then.returns("")
             provider = provider_class.new(resource)
             augeas_stub = stub("augeas", :get => "value")
             augeas_stub.stubs("close")
@@ -226,7 +222,7 @@ describe provider_class do
 
         it "should return false when a get filter does not match" do
             resource = stub("resource")
-            resource.stubs(:[]).returns(false).then.returns("get path == another value")
+            resource.stubs(:[]).returns(false).then.returns("get path == another value").then.returns("")
             provider = provider_class.new(resource)
             augeas_stub = stub("augeas", :get => "value")
             augeas_stub.stubs("close")
@@ -237,7 +233,7 @@ describe provider_class do
 
         it "should return true when a match filter matches" do
             resource = stub("resource")
-            resource.stubs(:[]).returns(false).then.returns("match path size == 3")
+            resource.stubs(:[]).returns(false).then.returns("match path size == 3").then.returns("")
             provider = provider_class.new(resource)
             augeas_stub = stub("augeas", :match => ["set", "of", "values"])
             augeas_stub.stubs("close")
@@ -248,7 +244,7 @@ describe provider_class do
 
         it "should return false when a match filter does not match" do
             resource = stub("resource")
-            resource.stubs(:[]).returns(false).then.returns("match path size == 2")
+            resource.stubs(:[]).returns(false).then.returns("match path size == 2").then.returns("")
             provider = provider_class.new(resource)
             augeas_stub = stub("augeas", :match => ["set", "of", "values"])
             augeas_stub.stubs("close")
@@ -260,7 +256,7 @@ describe provider_class do
         #This is a copy of the last one, with setting the force to true
         it "setting force should not change the above logic" do
             resource = stub("resource")
-            resource.stubs(:[]).returns(true).then.returns("match path size == 2")
+            resource.stubs(:[]).returns(true).then.returns("match path size == 2").then.returns("")
             provider = provider_class.new(resource)
             augeas_stub = stub("augeas", :match => ["set", "of", "values"])
             augeas_stub.stubs("close")
@@ -281,17 +277,17 @@ describe provider_class do
         end
 
         it "should handle set commands" do
-            command = [["set", "/Jar/Jar", "Binks"]]
-            context = "/some/path"
+            command = "set JarJar Binks"
+            context = "/some/path/"
             @resource.expects(:[]).times(2).returns(command).then.returns(context)
-            @augeas.expects(:set).with("/some/path/Jar/Jar", "Binks")
+            @augeas.expects(:set).with("/some/path/JarJar", "Binks")
             @augeas.expects(:save).returns(true)
             @augeas.expects(:close)
             @provider.execute_changes.should == :executed
         end
 
         it "should handle rm commands" do
-            command = [["rm", "/Jar/Jar"]]
+            command = "rm /Jar/Jar"
             context = ""
             @resource.expects(:[]).times(2).returns(command).then.returns(context)
             @augeas.expects(:rm).with("/Jar/Jar")
@@ -301,7 +297,7 @@ describe provider_class do
         end
 
         it "should handle remove commands" do
-            command = [["remove", "Jar/Jar"]]
+            command = "remove /Jar/Jar"
             context = ""
             @resource.expects(:[]).times(2).returns(command).then.returns(context)
             @augeas.expects(:rm).with("/Jar/Jar")
@@ -311,8 +307,8 @@ describe provider_class do
         end
 
         it "should handle clear commands" do
-            command = [["clear", "/Jar/Jar"]]
-            context = "/foo"
+            command = "clear Jar/Jar"
+            context = "/foo/"
             @resource.expects(:[]).times(2).returns(command).then.returns(context)
             @augeas.expects(:clear).with("/foo/Jar/Jar")
             @augeas.expects(:save).returns(true)
@@ -322,7 +318,7 @@ describe provider_class do
 
 
         it "should handle ins commands with before" do
-            command = [["ins", "Binks", "before /Jar/Jar"]]
+            command = "ins Binks before Jar/Jar"
             context = "/foo"
             @resource.expects(:[]).times(2).returns(command).then.returns(context)
             @augeas.expects(:insert).with("/foo/Jar/Jar", "Binks", true)
@@ -331,18 +327,18 @@ describe provider_class do
             @provider.execute_changes.should == :executed
         end
 
-        it "should handle ins commands with before" do
-            command = [["ins", "Binks", "after /Jar/Jar"]]
+        it "should handle ins commands with after" do
+            command = "ins Binks after /Jar/Jar"
             context = "/foo"
             @resource.expects(:[]).times(2).returns(command).then.returns(context)
-            @augeas.expects(:insert).with("/foo/Jar/Jar", "Binks", false)
+            @augeas.expects(:insert).with("/Jar/Jar", "Binks", false)
             @augeas.expects(:save).returns(true)
             @augeas.expects(:close)
             @provider.execute_changes.should == :executed
         end
 
         it "should handle ins with no context" do
-            command = [["ins", "Binks", "after /Jar/Jar"]]
+            command = "ins Binks after /Jar/Jar"
             context = "" # this is the default
             @resource.expects(:[]).times(2).returns(command).then.returns(context)
             @augeas.expects(:insert).with("/Jar/Jar", "Binks", false)
@@ -352,10 +348,10 @@ describe provider_class do
         end
 
         it "should handle multiple commands" do
-            command = [["ins", "Binks", "after /Jar/Jar"], ["clear", "/Jar/Jar"]]
-            context = "/foo"
+            command = ["ins Binks after /Jar/Jar", "clear Jar/Jar"]
+            context = "/foo/"
             @resource.expects(:[]).times(2).returns(command).then.returns(context)
-            @augeas.expects(:insert).with("/foo/Jar/Jar", "Binks", false)
+            @augeas.expects(:insert).with("/Jar/Jar", "Binks", false)
             @augeas.expects(:clear).with("/foo/Jar/Jar")
             @augeas.expects(:save).returns(true)
             @augeas.expects(:close)

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list