<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/puppet/executables/client/certhandler.rb</filename>
    </added>
    <added>
      <filename>lib/puppet/provider/confine/variable.rb</filename>
    </added>
    <added>
      <filename>lib/puppet/util/resource_template.rb</filename>
    </added>
    <added>
      <filename>spec/unit/executables/client/certhandler.rb</filename>
    </added>
    <added>
      <filename>spec/unit/provider/confine/variable.rb</filename>
    </added>
    <added>
      <filename>spec/unit/util/resource_template.rb</filename>
    </added>
    <added>
      <filename>spec/unit/util/warnings.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -23,7 +23,7 @@ project = Rake::RedLabProject.new(&quot;puppet&quot;) do |p|
         'lib/puppet.rb',
         'lib/puppet/**/*.rb',
         'lib/puppet/**/*.py',
-        'test/**/*.rb',
+        'test/**/*',
         'bin/**/*',
         'ext/**/*',
         'examples/**/*',
@@ -102,7 +102,7 @@ def daily(package)
     edir = &quot;/tmp/daily-export&quot;
     Dir.mkdir edir
     Dir.chdir(edir) do
-        sh %{svn export http://reductivelabs.com/svn/#{package}/trunk #{package} &gt;/dev/null}
+        sh %{git clone git://reductivelabs.com/#{package} #{package} &gt;/dev/null}
         sh %{tar cf - #{package} | gzip -c &gt; #{dailyfile(package)}}
     end
     FileUtils.rm_rf(edir)</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -162,6 +162,7 @@ trap(:INT) do
 end
 
 require 'puppet'
+require 'puppet/executables/client/certhandler'
 require 'puppet/network/client'
 require 'getoptlong'
 
@@ -347,35 +348,8 @@ if Puppet[:daemonize]
     client.daemonize
 end
 
-caclient = Puppet::Network::Client.ca.new()
-
-unless caclient.read_cert
-    if options[:waitforcert] &gt; 0
-        begin
-            while ! caclient.request_cert do
-                Puppet.notice &quot;Did not receive certificate&quot;
-                sleep options[:waitforcert]
-            end
-        rescue =&gt; detail
-            Puppet.err &quot;Could not request certificate: %s&quot; % detail.to_s
-            exit(23)
-        end
-    else
-        unless caclient.request_cert
-            Puppet.notice &quot;No certificates; exiting&quot;
-            exit(1)
-        end
-    end
-
-    # Now read the new cert in.
-    if caclient.read_cert
-        # If we read it in, then get rid of our existing http connection.
-        client.recycle_connection
-        Puppet.notice &quot;Got signed certificate&quot;
-    else
-        Puppet.err &quot;Could not read certificates after retrieving them&quot;
-        exit(34)
-    end
+unless Puppet::Executables::Client::CertHandler.new(options[:waitforcert], options[:onetime]).read_retrieve
+    client.recycle_connection
 end
 
 objects = []</diff>
      <filename>bin/puppetd</filename>
    </modified>
    <modified>
      <diff>@@ -103,15 +103,16 @@ that array, else return nil.&quot;
       (let ((opoint (point))
             (apoint (search-backward &quot;[&quot; nil t)))
         (when apoint
-          ;; An array opens before point.  If it doesn't close before
-          ;; point, then point must be in it.
-          ;; ### TODO: of course, the '[' could be in a string literal,
-          ;; ### in which case this whole idea is bogus.  But baby
-          ;; ### steps, baby steps.  A more robust strategy might be
-          ;; ### to walk backwards by sexps, until hit a wall, then
-          ;; ### inspect the nature of that wall.
-          (if (= (puppet-count-matches &quot;\\]&quot; apoint opoint) 0)
-              apoint))))))
+          ;; This is a bit of a hack and doesn't allow for strings.  We really
+          ;; want to parse by sexps at some point.
+          (let ((close-brackets (puppet-count-matches &quot;]&quot; apoint opoint))
+                (open-brackets 0))
+            (while (and apoint (&gt; close-brackets open-brackets))
+              (setq apoint (search-backward &quot;[&quot; nil t))
+              (when apoint
+                (setq close-brackets (puppet-count-matches &quot;]&quot; apoint opoint))
+                (setq open-brackets (1+ open-brackets)))))
+          apoint)))))
 
 (defun puppet-in-include ()
   &quot;If point is in a continued list of include statements, return the position
@@ -206,14 +207,14 @@ of the initial include plus puppet-include-indent.&quot;
              ;; Brace or paren not on a line by itself will be indented one
              ;; level too much, but don't catch cases where the block is
              ;; started and closed on the same line.
-             ((looking-at &quot;^[^\({]*[\)}]\\s-*$&quot;)
+             ((looking-at &quot;^[^\n\({]*[\)}]\\s-*$&quot;)
               (setq cur-indent (- (current-indentation) puppet-indent-level))
               (setq not-indented nil))
 
              ;; Indent by one level more than the start of our block.  We lose
              ;; if there is more than one block opened and closed on the same
              ;; line but it's still unbalanced; hopefully people don't do that.
-             ((looking-at &quot;^.*{[^}]*$&quot;)
+             ((looking-at &quot;^.*{[^\n}]*$&quot;)
               (setq cur-indent (+ (current-indentation) puppet-indent-level)) 
               (setq not-indented nil))
 
@@ -225,7 +226,7 @@ of the initial include plus puppet-include-indent.&quot;
              ;; Semicolon ends a block for a resource when multiple resources
              ;; are defined in the same block, but try not to get the case of
              ;; a complete resource on a single line wrong.
-             ((looking-at &quot;^\\([^'\&quot;:\n]\\|\&quot;[^\&quot;]*\&quot;\\|'[^']'\\)**;\\s-*$&quot;)
+             ((looking-at &quot;^\\([^'\&quot;:\n]\\|\&quot;[^\n\&quot;]*\&quot;\\|'[^\n']'\\)**;\\s-*$&quot;)
               (setq cur-indent (- (current-indentation) puppet-indent-level))
               (setq not-indented nil))
 
@@ -306,7 +307,6 @@ of the initial include plus puppet-include-indent.&quot;
      ;; variables
      '(&quot;\\(^\\|[^_:.@$]\\)\\b\\(true\\|false\\)\\&gt;&quot;
        2 font-lock-variable-name-face)
-     ;; variables
      '(&quot;\\(\\$\\([^a-zA-Z0-9 \n]\\|[0-9]\\)\\)\\W&quot;
        1 font-lock-variable-name-face)
      '(&quot;\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\|:\\)+&quot;
@@ -314,8 +314,8 @@ of the initial include plus puppet-include-indent.&quot;
      ;; usage of types
      '(&quot;^\\s *\\([a-zA-Z_-]+\\)\\s +{&quot;
        1 font-lock-type-face)
-     ;; overrides
-     '(&quot;^\\s +\\([a-zA-Z_-]+\\)\\[&quot;
+     ;; overrides and type references
+     '(&quot;\\s +\\([A-Z][a-zA-Z_:-]*\\)\\[&quot;
        1 font-lock-type-face)
      ;; general delimited string
      '(&quot;\\(^\\|[[ \t\n&lt;+(,=]\\)\\(%[xrqQwW]?\\([^&lt;[{(a-zA-Z0-9 \n]\\)[^\n\\\\]*\\(\\\\.[^\n\\\\]*\\)*\\(\\3\\)\\)&quot;</diff>
      <filename>ext/emacs/puppet-mode.el</filename>
    </modified>
    <modified>
      <diff>@@ -78,7 +78,7 @@ rdoc  = glob(%w{bin/* sbin/* lib/**/*.rb README README-library CHANGELOG TODO In
 ri    = glob(%w(bin/*.rb sbin/* lib/**/*.rb)).reject { |e| e=~ /\.(bat|cmd)$/ }
 man   = glob(%w{man/man8/*})
 libs  = glob(%w{lib/**/*.rb lib/**/*.py})
-tests = glob(%w{tests/**/*.rb})
+tests = glob(%w{test/**/*.rb})
 
 def do_bins(bins, target, strip = 's?bin/')
   bins.each do |bf|
@@ -393,7 +393,7 @@ EOS
 check_prereqs
 prepare_installation
 
-run_tests(tests) if InstallOptions.tests
+#run_tests(tests) if InstallOptions.tests
 #build_rdoc(rdoc) if InstallOptions.rdoc
 #build_ri(ri) if InstallOptions.ri
 #build_man(bins) if InstallOptions.man</diff>
      <filename>install.rb</filename>
    </modified>
    <modified>
      <diff>@@ -167,8 +167,12 @@ module Puppet
     end
 
     Puppet.setdefaults(:main,
-        :certname =&gt; [fqdn, &quot;The name to use when handling certificates.  Defaults
-            to the fully qualified domain name.&quot;],
+        # We have to downcase the fqdn, because the current ssl stuff (as oppsed to in master) doesn't have good facilities for 
+        # manipulating naming.
+        :certname =&gt; {:default =&gt; fqdn.downcase, :desc =&gt; &quot;The name to use when handling certificates.  Defaults
+            to the fully qualified domain name.&quot;,
+            :call_on_define =&gt; true, # Call our hook with the default value, so we're always downcased
+            :hook =&gt; proc { |value| raise(ArgumentError, &quot;Certificate names must be lower case; see #1168&quot;) unless value == value.downcase }},
         :certdnsnames =&gt; ['', &quot;The DNS names on the Server certificate as a colon-separated list.
             If it's anything other than an empty string, it will be used as an alias in the created
             certificate.  By default, only the server gets an alias set up, and only for 'puppet'.&quot;],</diff>
      <filename>lib/puppet/defaults.rb</filename>
    </modified>
    <modified>
      <diff>@@ -89,7 +89,7 @@ class Puppet::Node::Catalog::Compiler &lt; Puppet::Indirector::Code
         #    key = client
         #end
 
-        return nil unless node = Puppet::Node.find_by_any_name(key)
+        return nil unless node = Puppet::Node.find(key)
 
         # Add any external data to the node.
         add_node_data(node)</diff>
      <filename>lib/puppet/indirector/catalog/compiler.rb</filename>
    </modified>
    <modified>
      <diff>@@ -256,7 +256,7 @@ class Puppet::Indirector::Indirection
     def check_authorization(request, terminus)
         # At this point, we're assuming authorization makes no sense without
         # client information.
-        return unless request.options[:node]
+        return unless request.node
 
         # This is only to authorize via a terminus-specific authorization hook.
         return unless terminus.respond_to?(:authorized?)</diff>
      <filename>lib/puppet/indirector/indirection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,14 +1,16 @@
 require 'puppet/indirector/terminus'
 
 class Puppet::Indirector::Ldap &lt; Puppet::Indirector::Terminus
-    # Perform our ldap search and process the result.
-    def find(request)
+    # We split this apart so it's easy to call multiple times with different names.
+    def entry2hash(name)
         # We have to use 'yield' here because the LDAP::Entry objects
         # get destroyed outside the scope of the search, strangely.
-        ldapsearch(request.key) { |entry| return process(request.key, entry) }
+        ldapsearch(name) { |entry| return process(name, entry) }
+    end
 
-        # Return nil if we haven't found something.
-        return nil
+    # Perform our ldap search and process the result.
+    def find(request)
+        return entry2hash(request.key) || nil
     end
 
     # Process the found entry.  We assume that we don't just want the</diff>
      <filename>lib/puppet/indirector/ldap.rb</filename>
    </modified>
    <modified>
      <diff>@@ -30,6 +30,13 @@ class Puppet::Node::Exec &lt; Puppet::Indirector::Exec
     def create_node(name, result)
         node = Puppet::Node.new(name)
         set = false
+        if current = result[:parameters]
+            result[:parameters] = current.inject({}) do |strings, ary|
+                param, value = ary
+                strings[param] = value.to_s
+                strings
+            end
+        end
         [:parameters, :classes, :environment].each do |param|
             if value = result[param]
                 node.send(param.to_s + &quot;=&quot;, value)</diff>
      <filename>lib/puppet/indirector/node/exec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,9 @@ require 'puppet/indirector/ldap'
 
 class Puppet::Node::Ldap &lt; Puppet::Indirector::Ldap
     desc &quot;Search in LDAP for node configuration information.  See
-    the `LdapNodes`:trac: page for more information.&quot;
+    the `LdapNodes`:trac: page for more information.  This will first
+    search for whatever the certificate name is, then (if that name
+    contains a '.') for the short name, then 'default'.&quot;
 
     # The attributes that Puppet class information is stored in.
     def class_attributes
@@ -13,57 +15,23 @@ class Puppet::Node::Ldap &lt; Puppet::Indirector::Ldap
 
     # Look for our node in ldap.
     def find(request)
-        return nil unless information = super
-
-        name = request.key
-
-        node = Puppet::Node.new(name)
-
-        information[:stacked_parameters] = {}
-
-        parent_info = nil
-        parent = information[:parent]
-        parents = [name]
-        while parent
-            if parents.include?(parent)
-                raise ArgumentError, &quot;Found loop in LDAP node parents; %s appears twice&quot; % parent
-            end
-            parents &lt;&lt; parent
-
-            ldapsearch(parent) { |entry| parent_info = process(parent, entry) }
-
-            unless parent_info
-                raise Puppet::Error.new(&quot;Could not find parent node '%s'&quot; % parent)
-            end
-            information[:classes] += parent_info[:classes]
-            parent_info[:stacked].each do |value|
-                param = value.split('=', 2)
-                information[:stacked_parameters][param[0]] = param[1]
-            end
-            parent_info[:parameters].each do |param, value|
-                # Specifically test for whether it's set, so false values are handled
-                # correctly.
-                information[:parameters][param] = value unless information[:parameters].include?(param)
-            end
-
-            information[:environment] ||= parent_info[:environment]
-
-            parent = parent_info[:parent]
+        names = [request.key]
+        if request.key.include?(&quot;.&quot;) # we assume it's an fqdn
+            names &lt;&lt; request.key.sub(/\..+/, '')
         end
+        names &lt;&lt; &quot;default&quot;
 
-        information[:stacked].each do |value|
-            param = value.split('=', 2)
-            information[:stacked_parameters][param[0]] = param[1]
+        information = nil
+        names.each do |name|
+            break if information = entry2hash(name)
         end
+        return nil unless information
 
-        information[:stacked_parameters].each do |param, value|
-            information[:parameters][param] = value unless information[:parameters].include?(param)
-        end
+        name = request.key
 
-        node.classes = information[:classes].uniq unless information[:classes].empty?
-        node.parameters = information[:parameters] unless information[:parameters].empty?
-        node.environment = information[:environment] if information[:environment]
-        node.fact_merge
+        node = Puppet::Node.new(name)
+
+        add_to_node(node, information)
 
         return node
     end
@@ -155,4 +123,64 @@ class Puppet::Node::Ldap &lt; Puppet::Indirector::Ldap
         end
         filter
     end
+
+    private
+
+    # Add our hash of ldap information to the node instance.
+    def add_to_node(node, information)
+        information[:stacked_parameters] = {}
+
+        parent_info = nil
+        parent = information[:parent]
+        parents = [node.name]
+        while parent
+            if parents.include?(parent)
+                raise ArgumentError, &quot;Found loop in LDAP node parents; %s appears twice&quot; % parent
+            end
+            parents &lt;&lt; parent
+            parent = find_and_merge_parent(parent, information)
+        end
+
+        if information[:stacked]
+            information[:stacked].each do |value|
+                param = value.split('=', 2)
+                information[:stacked_parameters][param[0]] = param[1]
+            end
+        end
+
+        if information[:stacked_parameters]
+            information[:stacked_parameters].each do |param, value|
+                information[:parameters][param] = value unless information[:parameters].include?(param)
+            end
+        end
+
+        node.classes = information[:classes].uniq unless information[:classes].nil? or information[:classes].empty?
+        node.parameters = information[:parameters] unless information[:parameters].nil? or information[:parameters].empty?
+        node.environment = information[:environment] if information[:environment]
+        node.fact_merge
+    end
+
+    # Find information for our parent and merge it into the current info.
+    def find_and_merge_parent(parent, information)
+        parent_info = nil
+        ldapsearch(parent) { |entry| parent_info = process(parent, entry) }
+
+        unless parent_info
+            raise Puppet::Error.new(&quot;Could not find parent node '%s'&quot; % parent)
+        end
+        information[:classes] += parent_info[:classes]
+        parent_info[:stacked].each do |value|
+            param = value.split('=', 2)
+            information[:stacked_parameters][param[0]] = param[1]
+        end
+        parent_info[:parameters].each do |param, value|
+            # Specifically test for whether it's set, so false values are handled
+            # correctly.
+            information[:parameters][param] = value unless information[:parameters].include?(param)
+        end
+
+        information[:environment] ||= parent_info[:environment]
+
+        parent_info[:parent]
+    end
 end</diff>
      <filename>lib/puppet/indirector/node/ldap.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,10 +3,29 @@ require 'puppet/indirector'
 # Provide any attributes or functionality needed for indirected
 # instances.
 class Puppet::Indirector::Request
-    attr_accessor :indirection_name, :key, :method, :options, :instance
+    attr_accessor :indirection_name, :key, :method, :options, :instance, :node, :ip, :authenticated
+
+    # Is this an authenticated request?
+    def authenticated?
+        # Double negative, so we just get true or false
+        ! ! authenticated
+    end
 
     def initialize(indirection_name, method, key, options = {})
-        @indirection_name, @method, @options = indirection_name, method, (options || {})
+        options ||= {}
+        raise ArgumentError, &quot;Request options must be a hash, not %s&quot; % options.class unless options.is_a?(Hash)
+
+        @indirection_name, @method = indirection_name, method
+
+        @options = options.inject({}) do |result, ary|
+            param, value = ary
+            if respond_to?(param.to_s + &quot;=&quot;)
+                send(param.to_s + &quot;=&quot;, value)
+            else
+                result[param] = value
+            end
+            result
+        end
 
         if key.is_a?(String) or key.is_a?(Symbol)
             @key = key
@@ -14,8 +33,6 @@ class Puppet::Indirector::Request
             @instance = key
             @key = @instance.name
         end
-
-        raise ArgumentError, &quot;Request options must be a hash, not %s&quot; % @options.class unless @options.is_a?(Hash)
     end
 
     # Look up the indirection based on the name provided.</diff>
      <filename>lib/puppet/indirector/request.rb</filename>
    </modified>
    <modified>
      <diff>@@ -56,7 +56,8 @@ class Puppet::Network::Handler
         # Call our various handlers; this handler is getting deprecated.
         def getconfig(facts, format = &quot;marshal&quot;, client = nil, clientip = nil)
             facts = decode_facts(facts)
-            client, clientip = clientname(client, clientip, facts)
+
+            client ||= facts[&quot;hostname&quot;]
 
             # Pass the facts to the fact handler
             Puppet::Node::Facts.new(client, facts).save unless local?
@@ -66,27 +67,6 @@ class Puppet::Network::Handler
             return translate(catalog.extract)
         end
 
-        private
-
-        # Manipulate the client name as appropriate.
-        def clientname(name, ip, facts)
-            # Always use the hostname from Facter.
-            client = facts[&quot;hostname&quot;]
-            clientip = facts[&quot;ipaddress&quot;]
-            if Puppet[:node_name] == 'cert'
-                if name
-                    client = name
-                    facts[&quot;fqdn&quot;] = client
-                    facts[&quot;hostname&quot;], facts[&quot;domain&quot;] = client.split('.', 2)
-                end
-                if ip
-                    clientip = ip
-                end
-            end
-
-            return client, clientip
-        end
-
         # 
         def decode_facts(facts)
             if @local</diff>
      <filename>lib/puppet/network/handler/master.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,30 +1,30 @@
 module Puppet::Network::HTTP::Handler
-    
+
     def initialize_for_puppet(args = {})
         raise ArgumentError unless @server = args[:server]
         raise ArgumentError unless @handler = args[:handler]
         @model = find_model_for_handler(@handler)
     end
-    
+
     # handle an HTTP request
     def process(request, response)
         return do_find(request, response)       if get?(request)    and singular?(request)
         return do_search(request, response)     if get?(request)    and plural?(request)
         return do_destroy(request, response)    if delete?(request) and singular?(request)
-        return do_save(request, response)       if put?(request) and singular?(request)
+        return do_save(request, response)       if put?(request)    and singular?(request)
         raise ArgumentError, &quot;Did not understand HTTP #{http_method(request)} request for '#{path(request)}'&quot;
     rescue Exception =&gt; e
         return do_exception(request, response, e)
     end
-    
+
   private
 
     def model
         @model
     end
-    
+
     def do_find(request, response)
-        key = request_key(request) || raise(ArgumentError, &quot;Could not locate lookup key in request path [#{path}]&quot;)
+        key = request_key(request) || raise(ArgumentError, &quot;Could not locate lookup key in request path [#{path(request)}]&quot;)
         args = params(request)
         result = model.find(key, args).to_yaml
         encode_result(request, response, result)
@@ -37,7 +37,7 @@ module Puppet::Network::HTTP::Handler
     end
 
     def do_destroy(request, response)
-        key = request_key(request) || raise(ArgumentError, &quot;Could not locate lookup key in request path [#{path}]&quot;)
+        key = request_key(request) || raise(ArgumentError, &quot;Could not locate lookup key in request path [#{path(request)}]&quot;)
         args = params(request)
         result = model.destroy(key, args)
         encode_result(request, response, YAML.dump(result))
@@ -46,70 +46,73 @@ module Puppet::Network::HTTP::Handler
     def do_save(request, response)
         data = body(request).to_s
         raise ArgumentError, &quot;No data to save&quot; if !data or data.empty?
-        # args = params(request)
+        args = params(request)
         obj = model.from_yaml(data)
-        result = save_object(obj).to_yaml
+        result = save_object(obj, args).to_yaml
         encode_result(request, response, result)
     end
-    
-    def save_object(obj)
-        obj.save
+
+    # LAK:NOTE This has to be here for testing; it's a stub-point so
+    # we keep infinite recursion from happening.
+    def save_object(object, args)
+        object.save(args)
     end
-  
+
     def do_exception(request, response, exception, status=404)
         encode_result(request, response, exception.to_yaml, status)
     end
-  
+
     def find_model_for_handler(handler)
         Puppet::Indirector::Indirection.model(handler) || 
             raise(ArgumentError, &quot;Cannot locate indirection [#{handler}].&quot;)
     end
-    
+
     def get?(request)
         http_method(request) == 'GET'
     end
-    
+
     def put?(request)
         http_method(request) == 'PUT'
     end
-    
+
     def delete?(request)
         http_method(request) == 'DELETE'
     end
-    
+
     def singular?(request)
         %r{/#{@handler.to_s}$}.match(path(request))
     end
-    
+
     def plural?(request)
         %r{/#{@handler.to_s}s$}.match(path(request))
     end
-    
+
     # methods to be overridden by the including web server class
+
     def register_handler
         raise NotImplementedError
     end
-    
+
     def http_method(request)
         raise NotImplementedError
     end
-    
+
     def path(request)
         raise NotImplementedError
     end    
-    
+
     def request_key(request)
         raise NotImplementedError
     end
-    
+
     def body(request)
         raise NotImplementedError
     end
-    
+
     def params(request)
         raise NotImplementedError
     end
-    
+
     def encode_result(request, response, result, status = 200)
         raise NotImplementedError
     end</diff>
      <filename>lib/puppet/network/http/handler.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,45 +3,64 @@ require 'puppet/network/http/handler'
 class Puppet::Network::HTTP::MongrelREST &lt; Mongrel::HttpHandler
 
     include Puppet::Network::HTTP::Handler
-  
+
     def initialize(args={})
         super()
         initialize_for_puppet(args)
     end
 
+    # Return the query params for this request.  We had to expose this method for
+    # testing purposes.
+    def params(request)
+        Mongrel::HttpRequest.query_parse(request.params[&quot;QUERY_STRING&quot;]).merge(client_info(request))
+    end
+
   private
- 
+
     # which HTTP verb was used in this request
     def http_method(request)
         request.params[Mongrel::Const::REQUEST_METHOD]
     end
-    
+
     # what path was requested?
     def path(request)
         # LAK:NOTE See http://snurl.com/21zf8  [groups_google_com] 
         x = '/' + request.params[Mongrel::Const::REQUEST_PATH].split('/')[1]
     end
-    
+
     # return the key included in the request path
     def request_key(request)
         # LAK:NOTE See http://snurl.com/21zf8  [groups_google_com] 
         x = request.params[Mongrel::Const::REQUEST_PATH].split('/')[2]        
     end
-    
+
     # return the request body
     def body(request)
         request.body
     end
-    
-    # return the query params for this request
-    def params(request)
-        Mongrel::HttpRequest.query_parse(request.params[&quot;QUERY_STRING&quot;])
-    end
-    
+
     # produce the body of the response
     def encode_result(request, response, result, status = 200)
         response.start(status) do |head, body|
             body.write(result)
         end
     end
+
+    def client_info(request)
+        result = {}
+        params = request.params
+        result[:ip] = params[&quot;REMOTE_ADDR&quot;]
+
+        # JJM #906 The following dn.match regular expression is forgiving
+        # enough to match the two Distinguished Name string contents
+        # coming from Apache, Pound or other reverse SSL proxies.
+        if dn = params[Puppet[:ssl_client_header]] and dn_matchdata = dn.match(/^.*?CN\s*=\s*(.*)/)
+            result[:node] = dn_matchdata[1].to_str
+            result[:authenticated] = (params[Puppet[:ssl_client_verify_header]] == 'SUCCESS')
+        else
+            result[:authenticated] = false
+        end
+
+        return result
+    end
 end</diff>
      <filename>lib/puppet/network/http/mongrel/rest.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,46 +1,67 @@
 require 'puppet/network/http/handler'
 
 class Puppet::Network::HTTP::WEBrickREST &lt; WEBrick::HTTPServlet::AbstractServlet
-  
+
     include Puppet::Network::HTTP::Handler
-    
+
     def initialize(server, handler)
-      raise ArgumentError, &quot;server is required&quot; unless server
-      super(server)
-      initialize_for_puppet(:server =&gt; server, :handler =&gt; handler)
+        raise ArgumentError, &quot;server is required&quot; unless server
+        super(server)
+        initialize_for_puppet(:server =&gt; server, :handler =&gt; handler)
+    end
+
+    # We had to expose this method for testing purposes.
+    def params(request)
+        result = request.query
+        result.merge(client_information(request))
     end
 
     # WEBrick uses a service() method to respond to requests.  Simply delegate to the handler response() method.
     def service(request, response)
         process(request, response)
     end
-    
+
   private
-    
+
     def http_method(request)
         request.request_method
     end
-    
+
     def path(request)
         # LAK:NOTE See http://snurl.com/21zf8  [groups_google_com] 
         x = '/' + request.path.split('/')[1]
     end
-    
+
     def request_key(request)
         # LAK:NOTE See http://snurl.com/21zf8  [groups_google_com] 
         x = request.path.split('/')[2]
     end
-    
+
     def body(request)
         request.body
     end
-    
-    def params(request)
-        request.query
-    end
-    
+
     def encode_result(request, response, result, status = 200)
         response.status = status
         response.body = result
     end
+
+    # Retrieve node/cert/ip information from the request object.
+    def client_information(request)
+        result = {}
+        if peer = request.peeraddr and ip = peer[3]
+            result[:ip] = ip
+        end
+
+        # If they have a certificate (which will almost always be true)
+        # then we get the hostname from the cert, instead of via IP
+        # info
+        result[:authenticated] = false
+        if cert = request.client_cert and nameary = cert.subject.to_a.find { |ary| ary[0] == &quot;CN&quot; }
+            result[:node] = nameary[1]
+            result[:authenticated] = true
+        end
+
+        result
+    end
 end</diff>
      <filename>lib/puppet/network/http/webrick/rest.rb</filename>
    </modified>
    <modified>
      <diff>@@ -13,85 +13,7 @@ class Puppet::Node
     indirects :node, :terminus_setting =&gt; :node_terminus, :doc =&gt; &quot;Where to find node information.
         A node is composed of its name, its facts, and its environment.&quot;
 
-    # Retrieve a node from the node source, with some additional munging
-    # thrown in for kicks.
-    def self.find_by_any_name(key)
-        return nil unless key
-
-        facts = node_facts(key)
-        node = nil
-        names = node_names(key, facts)
-        names.each do |name|
-            name = name.to_s if name.is_a?(Symbol)
-            break if node = find(name)
-        end
-
-        # If they made it this far, we haven't found anything, so look for a
-        # default node.
-        unless node or names.include?(&quot;default&quot;)
-            if node = find(&quot;default&quot;)
-                Puppet.notice &quot;Using default node for %s&quot; % key
-            end
-        end
-
-        if node
-            node.names = names
-
-            return node
-        else
-            return nil
-        end
-    end
-
-    private
-
-    # Look up the node facts so we can generate the node names to use.
-    def self.node_facts(key)
-        if facts = Puppet::Node::Facts.find(key)
-            facts.values
-        else
-            {}
-        end
-    end
-
-    # Calculate the list of node names we should use for looking
-    # up our node.
-    def self.node_names(key, facts = nil)
-        facts ||= node_facts(key)
-        names = []
-
-        if hostname = facts[&quot;hostname&quot;]
-            unless hostname == key
-                names &lt;&lt; hostname
-            end
-        else
-            hostname = key
-        end
-
-        if fqdn = facts[&quot;fqdn&quot;]
-            hostname = fqdn
-            names &lt;&lt; fqdn
-        end
-
-        # Make sure both the fqdn and the short name of the
-        # host can be used in the manifest
-        if hostname =~ /\./
-            names &lt;&lt; hostname.sub(/\..+/,'')
-        elsif domain = facts['domain']
-            names &lt;&lt; hostname + &quot;.&quot; + domain
-        end
-
-        # Sort the names inversely by name length.
-        names.sort! { |a,b| b.length &lt;=&gt; a.length }
-
-        # And make sure the key is first, since that's the most
-        # likely usage.
-        ([key] + names).uniq
-    end
-
-    public
-
-    attr_accessor :name, :classes, :parameters, :source, :ipaddress, :names
+    attr_accessor :name, :classes, :parameters, :source, :ipaddress
     attr_reader :time
 
     # Set the environment, making sure that it's valid.
@@ -164,4 +86,39 @@ class Puppet::Node
 
         @parameters[&quot;environment&quot;] ||= self.environment if self.environment
     end
+
+    # Calculate the list of names we might use for looking
+    # up our node.  This is only used for AST nodes.
+    def names
+        names = []
+
+        # First, get the fqdn
+        unless fqdn = parameters[&quot;fqdn&quot;]
+            if domain = parameters[&quot;domain&quot;]
+                fqdn = parameters[&quot;hostname&quot;] + &quot;.&quot; + parameters[&quot;domain&quot;]
+            end
+        end
+
+        # Now that we (might) have the fqdn, add each piece to the name
+        # list to search, in order of longest to shortest.
+        if fqdn
+            list = fqdn.split(&quot;.&quot;)
+            tmp = []
+            list.each_with_index do |short, i|
+                tmp &lt;&lt; list[0..i].join(&quot;.&quot;)
+            end
+            names += tmp.reverse
+        end
+
+        # And make sure the node name is first, since that's the most
+        # likely usage.
+        #   The name is usually the Certificate CN, but it can be
+        # set to the 'facter' hostname instead.
+        if Puppet[:node_name] == 'cert'
+            names.unshift name
+        else
+            names.unshift parameters[&quot;hostname&quot;]
+        end
+        names.uniq
+    end
 end</diff>
      <filename>lib/puppet/node.rb</filename>
    </modified>
    <modified>
      <diff>@@ -483,6 +483,9 @@ class Puppet::Node::Catalog &lt; Puppet::PGraph
             if resource.is_a?(Puppet::TransObject)
                 resource = resource.dup
                 resource.catalog = result
+            elsif resource.is_a?(Puppet::Parser::Resource)
+                resource = resource.to_transobject
+                resource.catalog = result
             end
 
             newres = resource.send(convert)</diff>
      <filename>lib/puppet/node/catalog.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,12 @@ class Puppet::Parser::Collector
     # Call the collection method, mark all of the returned objects as non-virtual,
     # and then delete this object from the list of collections to evaluate.
     def evaluate
+        # Shortcut if we're not using storeconfigs and they're trying to collect
+        # exported resources.
+        if form == :exported and Puppet[:storeconfigs] != true
+            Puppet.warning &quot;Not collecting exported resources without storeconfigs&quot;
+            return false
+        end
         if self.resources
             if objects = collect_resources and ! objects.empty?
                 return objects</diff>
      <filename>lib/puppet/parser/collector.rb</filename>
    </modified>
    <modified>
      <diff>@@ -188,6 +188,22 @@ module Functions
         result
     end
 
+    newfunction(:fqdn_rand, :type =&gt; :rvalue, :doc =&gt; &quot;Generates random 
+    numbers based on the node's fqdn. The first argument sets the range.
+    The second argument specifies a number to add to the seed and is
+    optional.&quot;) do |args|
+	require 'md5'
+	max = args[0] 
+	if args[1] then
+	     seed = args[1]
+	else
+	     seed = 1
+	end
+	fqdn_seed = MD5.new(lookupvar('fqdn')).to_s.hex
+	srand(seed+fqdn_seed)
+	rand(max).to_s
+    end 
+
     newfunction(:fail, :doc =&gt; &quot;Fail with a parse error.&quot;) do |vals|
         vals = vals.collect { |s| s.to_s }.join(&quot; &quot;) if vals.is_a? Array
         raise Puppet::ParseError, vals.to_s</diff>
      <filename>lib/puppet/parser/functions.rb</filename>
    </modified>
    <modified>
      <diff>@@ -152,7 +152,7 @@ virtualresource:  at resource {
     type = val[0]
 
     if (type == :exported and ! Puppet[:storeconfigs]) and ! Puppet[:parseonly]
-        error &quot;You cannot collect without storeconfigs being set&quot;
+        Puppet.warning addcontext(&quot;You cannot collect without storeconfigs being set&quot;)
     end
 
     if val[1].is_a? AST::ResourceDefaults
@@ -193,7 +193,7 @@ collection:     classref collectrhand {
         args[:form] = val[1]
     end
     if args[:form] == :exported and ! Puppet[:storeconfigs] and ! Puppet[:parseonly]
-        error &quot;You cannot collect exported resources without storeconfigs being set&quot;
+        Puppet.warning addcontext(&quot;You cannot collect exported resources without storeconfigs being set; the collection will be ignored&quot;)
     end
     result = ast AST::Collection, args
 }</diff>
      <filename>lib/puppet/parser/grammar.ra</filename>
    </modified>
    <modified>
      <diff>@@ -50,23 +50,8 @@ class Puppet::Parser::Interpreter
     # Return the parser for a specific environment.
     def parser(environment)
         if ! @parsers[environment] or @parsers[environment].reparse?
-            # This will throw an exception if it does not succeed.  We only
-            # want to get rid of the old parser if we successfully create a new
-            # one.
-            begin
-                tmp = create_parser(environment)
-                @parsers[environment].clear if @parsers[environment]
-                @parsers[environment] = tmp
-            rescue =&gt; detail
-                # If a parser already exists, than assume that we logged the
-                # exception elsewhere and reuse the parser.  If one doesn't
-                # exist, then reraise.
-                if @parsers[environment]
-                    Puppet.err(detail.to_s + &quot;; using previously parsed manifests&quot;)
-                else
-                    raise detail
-                end
-            end
+            # This will throw an exception if it does not succeed.
+            @parsers[environment] = create_parser(environment)
         end
         @parsers[environment]
     end</diff>
      <filename>lib/puppet/parser/interpreter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -29,7 +29,7 @@ module Puppet
 
     class Parser &lt; Racc::Parser
 
-module_eval &lt;&lt;'..end grammar.ra modeval..idfef5d70c9f', 'grammar.ra', 638
+module_eval &lt;&lt;'..end grammar.ra modeval..id9145566289', 'grammar.ra', 638
 
 # It got too annoying having code in a file that needs to be compiled.
 require 'puppet/parser/parser_support'
@@ -41,7 +41,7 @@ require 'puppet/parser/parser_support'
 
 # $Id$
 
-..end grammar.ra modeval..idfef5d70c9f
+..end grammar.ra modeval..id9145566289
 
 ##### racc 1.4.5 generates ###
 
@@ -958,7 +958,7 @@ module_eval &lt;&lt;'.,.,', 'grammar.ra', 174
     type = val[0]
 
     if (type == :exported and ! Puppet[:storeconfigs]) and ! Puppet[:parseonly]
-        error &quot;You cannot collect without storeconfigs being set&quot;
+        Puppet.warning addcontext(&quot;You cannot collect without storeconfigs being set&quot;)
     end
 
     if val[1].is_a? AST::ResourceDefaults
@@ -1011,7 +1011,7 @@ module_eval &lt;&lt;'.,.,', 'grammar.ra', 199
         args[:form] = val[1]
     end
     if args[:form] == :exported and ! Puppet[:storeconfigs] and ! Puppet[:parseonly]
-        error &quot;You cannot collect exported resources without storeconfigs being set&quot;
+        Puppet.warning addcontext(&quot;You cannot collect exported resources without storeconfigs being set; the collection will be ignored&quot;)
     end
     result = ast AST::Collection, args
    result</diff>
      <filename>lib/puppet/parser/parser.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,8 +15,8 @@ class Puppet::Provider::ConfineCollection
                 @confines &lt;&lt; klass.new(values)
                 @confines[-1].for_binary = true if for_binary
             else
-                confine = Puppet::Provider::Confine.test(:facter).new(values)
-                confine.fact = test
+                confine = Puppet::Provider::Confine.test(:variable).new(values)
+                confine.name = test
                 @confines &lt;&lt; confine
             end
         end</diff>
      <filename>lib/puppet/provider/confine_collection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,7 +12,7 @@ Puppet::Type.type(:group).provide :ldap, :parent =&gt; Puppet::Provider::Ldap do
         as it iterates across all existing groups to pick the appropriate next
         one.&quot;
 
-    confine :true =&gt; Puppet.features.ldap?
+    confine :true =&gt; Puppet.features.ldap?, :false =&gt; (Puppet[:ldapuser] == &quot;&quot;)
 
     # We're mapping 'members' here because we want to make it
     # easy for the ldap user provider to manage groups.  This
@@ -23,12 +23,14 @@ Puppet::Type.type(:group).provide :ldap, :parent =&gt; Puppet::Provider::Ldap do
     # Find the next gid after the current largest gid.
     provider = self
     manager.generates(:gidNumber).with do 
-        largest = 0
-        provider.manager.search.each do |hash|
-            next unless value = hash[:gid]
-            num = value[0].to_i
-            if num &gt; largest
-                largest = num
+        largest = 500
+        if existing = provider.manager.search
+                existing.each do |hash|
+                next unless value = hash[:gid]
+                num = value[0].to_i
+                if num &gt; largest
+                    largest = num
+                end
             end
         end
         largest + 1</diff>
      <filename>lib/puppet/provider/group/ldap.rb</filename>
    </modified>
    <modified>
      <diff>@@ -53,7 +53,22 @@ Puppet::Type.type(:package).provide :dpkg, :parent =&gt; Puppet::Provider::Package
         unless file = @resource[:source]
             raise ArgumentError, &quot;You cannot install dpkg packages without a source&quot;
         end
-        dpkg &quot;-i&quot;, file
+        
+        args = []
+
+        if config = @resource[:configfiles]
+            case config
+            when :keep
+                args &lt;&lt; '--force-confold'
+            when :replace
+                args &lt;&lt; '--force-confnew'
+            else
+                raise Puppet::Error, &quot;Invalid 'configfiles' value %s&quot; % config
+            end
+        end
+        args &lt;&lt; '-i' &lt;&lt; file
+
+        dpkg(*args)
     end
 
     def update</diff>
      <filename>lib/puppet/provider/package/dpkg.rb</filename>
    </modified>
    <modified>
      <diff>@@ -28,66 +28,7 @@
 require 'puppet/provider/package'
 
 Puppet::Type.type(:package).provide :pkgdmg, :parent =&gt; Puppet::Provider::Package do
-    desc &quot;Package management based on Apple's Installer.app and DiskUtility.app
-    
-Author: Jeff McCune &lt;jeff@northstarlabs.net&gt;
-
-Please direct questions about this provider to the puppet-users mailing list.
-
-This package works by checking the contents of a DMG image for Apple pkg or
-mpkg files. Any number of pkg or mpkg files may exist in the root directory of
-the DMG file system. Sub directories are not checked for packages.
-
-This provider always assumes the label (formerly called 'name') attribute
-declared in the manifest will always exactly match the file name (without
-path) of the DMG file itself. Therefore, if you want to install packages in
-'Foobar.pkg.dmg' you must explicitly specify the label::
-
-    package { Foobar.pkg.dmg: ensure =&gt; installed, provider =&gt; pkgdmg }
-
-Only the dmg file name itself is used when puppet determines if the packages
-contained within are currently installed. For example, if a package resource
-named 'Foobar.pkg.dmg' is named for installation and contains multiple
-packages, this provider will install all packages in the root directory of
-this file system, then create a small cookie for the whole bundle, located at
-/var/db/.puppet_pkgdmg_installed_Foobar.pkg.dmg
-
-As a result, if you change the contents of the DMG file in any way, Puppet
-will not update or re-install the packages contained within unless you change
-the file name of the DMG wrapper itself. Therefore, if you use this provider,
-I recommend you name the DMG wrapper files in a manner that lends itself to
-incremental version changes. I include some version or date string in the DMG
-name, like so::
-
-    Firefox-2.0.0.3-1.pkg.dmg
-
-If I realize I've mis-packaged this DMG, then I have the option to increment
-the package version, yielding Firefox-2.0.0.3-2.pkg.dmg.
-
-This provider allows you to host DMG files within an FTP or HTTP server. This
-is primarily how the author provider distributes software. Any URL mechanism
-curl or Ruby's open-uri module supports is supported by this provider. Curl
-supported URL's yield much faster data throughput than open-uri, so I
-recommend HTTP, HTTPS, or FTP for source package repositories.
-
-Because the provider assumes packages will be transfered via CURL, a two stage
-process occurs. First, if a URL is detected, curl is invoked to transfer the
-file into a temporary directory. If no URL is present, the provider skips
-straight to step 2. In step two, the source file is mounted, then packages
-installed, and finally the DMG file is removed.
-
-If this is a problem for you, please patch the code, or bug Jeff to fix this.
-
-Example usage::
-
-    package { Thunderbird-2.0.0.4-1.pkg.dmg:
-      provider =&gt; pkgdmg, ensure =&gt; present
-      source =&gt; 'http://0.0.0.0:8000/packages/Thunderbird-2.0.0.4-1.pkg.dmg',
-    }
-
-**WARNING**: Because I assume files will be downloaded to /tmp, the current
-implementation attempts to delete DMG files if you install directly from the
-file system and not via a URL method.&quot;
+    desc &quot;Package management based on Apple's Installer.app and DiskUtility.app.  This package works by checking the contents of a DMG image for Apple pkg or mpkg files. Any number of pkg or mpkg files may exist in the root directory of the DMG file system. Sub directories are not checked for packages.  See `the wiki docs &lt;/trac/puppet/wiki/DmgPackages&gt;` for more detail.&quot;
   
     confine :exists =&gt; &quot;/Library/Receipts&quot;
     commands :installer =&gt; &quot;/usr/sbin/installer&quot;</diff>
      <filename>lib/puppet/provider/package/pkgdmg.rb</filename>
    </modified>
    <modified>
      <diff>@@ -43,19 +43,20 @@ Puppet::Type.type(:package).provide :rpm, :source =&gt; :rpm, :parent =&gt; Puppet::Pr
     # a hash with entries :instance =&gt; fully versioned package name, and 
     # :ensure =&gt; version-release
     def query
-        unless @property_hash[:epoch]
-            cmd = [&quot;-q&quot;, @resource[:name], &quot;--nosignature&quot;, &quot;--nodigest&quot;, &quot;--qf&quot;, &quot;#{NEVRAFORMAT}\n&quot;]
-
-            begin
-                output = rpm(*cmd)
-            rescue Puppet::ExecutionFailure
-                return nil
-            end
-            
-            # FIXME: We could actually be getting back multiple packages
-            # for multilib
-            @property_hash.update(self.class.nevra_to_hash(output))
+        #NOTE: Prior to a fix for issue 1243, this method potentially returned a cached value
+        #IF YOU CALL THIS METHOD, IT WILL CALL RPM
+        #Use get(:property) to check if cached values are available 
+        cmd = [&quot;-q&quot;, @resource[:name], &quot;--nosignature&quot;, &quot;--nodigest&quot;, &quot;--qf&quot;, &quot;#{NEVRAFORMAT}\n&quot;]
+
+        begin
+            output = rpm(*cmd)
+        rescue Puppet::ExecutionFailure
+            return nil
         end
+        
+        # FIXME: We could actually be getting back multiple packages
+        # for multilib
+        @property_hash.update(self.class.nevra_to_hash(output))
 
         return @property_hash.dup
     end</diff>
      <filename>lib/puppet/provider/package/rpm.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,7 +12,7 @@ Puppet::Type.type(:user).provide :ldap, :parent =&gt; Puppet::Provider::Ldap do
         as it iterates across all existing users to pick the appropriate next
         one.&quot;
 
-    confine :true =&gt; Puppet.features.ldap?
+    confine :feature =&gt; :ldap, :false =&gt; (Puppet[:ldapuser] == &quot;&quot;)
 
     manages(:posixAccount, :person).at(&quot;ou=People&quot;).named_by(:uid).and.maps :name =&gt; :uid,
         :password =&gt; :userPassword,
@@ -32,12 +32,14 @@ Puppet::Type.type(:user).provide :ldap, :parent =&gt; Puppet::Provider::Ldap do
     # Find the next uid after the current largest uid.
     provider = self
     manager.generates(:uidNumber).with do 
-        largest = 0
-        provider.manager.search.each do |hash|
-            next unless value = hash[:uid]
-            num = value[0].to_i
-            if num &gt; largest
-                largest = num
+        largest = 500
+        if existing = provider.manager.search
+            existing.each do |hash|
+                next unless value = hash[:uid]
+                num = value[0].to_i
+                if num &gt; largest
+                    largest = num
+                end
             end
         end
         largest + 1</diff>
      <filename>lib/puppet/provider/user/ldap.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,17 +1,17 @@
 class AddCreatedAtToAllTables &lt; ActiveRecord::Migration
-  def self.up
-    ActiveRecord::Base.connection.tables.each do |t|
-      unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?(&quot;created_at&quot;)
-        add_column t.to_s, :created_at, :datetime 
-      end  
-    end 
-  end
+    def self.up
+        ActiveRecord::Base.connection.tables.each do |t|
+            unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?(&quot;created_at&quot;)
+                add_column t.to_s, :created_at, :datetime 
+            end    
+        end 
+    end
 
-  def self.down
-    ActiveRecord::Base.connection.tables.each do |t|
-      unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?(&quot;created_at&quot;)
-        remove_column t.to_s, :created_at
-      end  
-    end  
-  end
+    def self.down
+        ActiveRecord::Base.connection.tables.each do |t|
+            unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?(&quot;created_at&quot;)
+                remove_column t.to_s, :created_at
+            end    
+        end    
+    end
 end</diff>
      <filename>lib/puppet/rails/database/001_add_created_at_to_all_tables.rb</filename>
    </modified>
    <modified>
      <diff>@@ -63,9 +63,13 @@ providers = Puppet::Util::Reference.newreference :providers, :title =&gt; &quot;Provider
                     case test
                     when :exists:
                         details += &quot;  - Missing files %s\n&quot; % values.join(&quot;, &quot;)
-                    when :facter:
+                    when :variable:
                         values.each do |name, facts|
-                            details += &quot;  - Fact %s (currently %s) not in list %s\n&quot; % [name, Facter.value(name).inspect, facts.join(&quot;, &quot;)]
+                            if Puppet.settings.valid?(name)
+                                details += &quot;  - Setting %s (currently %s) not in list %s\n&quot; % [name, Puppet.settings.value(name).inspect, facts.join(&quot;, &quot;)]
+                            else
+                                details += &quot;  - Fact %s (currently %s) not in list %s\n&quot; % [name, Facter.value(name).inspect, facts.join(&quot;, &quot;)]
+                            end
                         end
                     when :true:
                         details += &quot;  - Got %s true tests that should have been false\n&quot; % values</diff>
      <filename>lib/puppet/reference/providers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,7 +23,7 @@ class Puppet::SSL::Base
     end
 
     def initialize(name)
-        @name = name
+        @name = name.downcase
     end
 
     # Read content from disk appropriately.</diff>
      <filename>lib/puppet/ssl/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -155,7 +155,7 @@ class Puppet::SSL::Host
     end
 
     def initialize(name = nil)
-        @name = name || Puppet[:certname]
+        @name = (name || Puppet[:certname]).downcase
         @key = @certificate = @certificate_request = nil
         @ca = (name == self.class.ca_name)
     end</diff>
      <filename>lib/puppet/ssl/host.rb</filename>
    </modified>
    <modified>
      <diff>@@ -97,7 +97,7 @@ class Puppet::SSLCertificates::CA
         if @config[:capass] and File.readable?(@config[:capass])
             return File.read(@config[:capass])
         else
-            raise Puppet::Error, &quot;Could not read CA passfile %s&quot; % @config[:capass]
+            raise Puppet::Error, &quot;Could not decrypt CA key with password: %s&quot; % detail
         end
     end
 
@@ -379,9 +379,14 @@ class Puppet::SSLCertificates::CA
     def sign_with_key(signable, digest = OpenSSL::Digest::SHA1.new)
         cakey = nil
         if @config[:password]
-            cakey = OpenSSL::PKey::RSA.new(
-                File.read(@config[:cakey]), @config[:password]
-            )
+            begin
+                cakey = OpenSSL::PKey::RSA.new(
+                    File.read(@config[:cakey]), @config[:password]
+                )
+            rescue
+                raise Puppet::Error,
+                    &quot;Decrypt of CA private key with password stored in @config[:capass] not possible&quot;
+            end
         else
             cakey = OpenSSL::PKey::RSA.new(
                 File.read(@config[:cakey])</diff>
      <filename>lib/puppet/sslcertificates/ca.rb</filename>
    </modified>
    <modified>
      <diff>@@ -499,11 +499,13 @@ class Transaction
     
     # Prepare to evaluate the resources in a transaction.
     def prepare
-        prefetch()
-    
         # Now add any dynamically generated resources
         generate()
 
+        # Then prefetch.  It's important that we generate and then prefetch,
+        # so that any generated resources also get prefetched.
+        prefetch()
+        
         # This will throw an error if there are cycles in the graph.
         @sorted_resources = relationship_graph.topsort
     end</diff>
      <filename>lib/puppet/transaction.rb</filename>
    </modified>
    <modified>
      <diff>@@ -54,6 +54,8 @@ module Puppet
         def insync?(currentvalue)
             if [:nochange, :notlink].include?(self.should) or @resource.recurse?
                 return true
+            elsif ! @resource.replace? and File.exists?(@resource[:path])
+                return true 
             else
                 return super(currentvalue)
             end</diff>
      <filename>lib/puppet/type/file/target.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,6 +9,13 @@ module Puppet::Util::Warnings
             Puppet.warning msg
             $stampwarnings[self.class] &lt;&lt; msg
         end
+
+        return nil
+    end
+
+    def clear_warnings()
+        $stampwarnings = {}
+        return nil
     end
 end
 </diff>
      <filename>lib/puppet/util/warnings.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,8 @@ require 'puppet/defaults'
 
 describe &quot;Puppet defaults&quot; do
     after { Puppet.settings.clear }
-    describe &quot;when configuring the :crl&quot; do
+
+    describe &quot;when setting the :factpath&quot; do
         it &quot;should add the :factpath to Facter's search paths&quot; do
             Facter.expects(:search).with(&quot;/my/fact/path&quot;)
 
@@ -14,8 +15,13 @@ describe &quot;Puppet defaults&quot; do
         end
     end
 
-    describe &quot;when setting the :factpath&quot; do
+    describe &quot;when setting the :certname&quot; do
+        it &quot;should fail if the certname is not downcased&quot; do
+            lambda { Puppet.settings[:certname] = &quot;Host.Domain.Com&quot; }.should raise_error(ArgumentError)
+        end
+    end
 
+    describe &quot;when configuring the :crl&quot; do
         it &quot;should warn if :cacrl is set to false&quot; do
             Puppet.expects(:warning)
             Puppet.settings[:cacrl] = 'false'</diff>
      <filename>spec/integration/defaults.rb</filename>
    </modified>
    <modified>
      <diff>@@ -29,8 +29,6 @@ end
 class Puppet::TestIndirectedFoo::Rest &lt; Puppet::Indirector::REST
 end
 
-# This way the retrieval of the class by name works.
-Puppet::Indirector::Terminus.register_terminus_class(Puppet::TestIndirectedFoo::Rest)
 
 describe Puppet::Indirector::REST do
     before do
@@ -65,18 +63,11 @@ describe Puppet::Indirector::REST do
 
             ca = Puppet::SSL::CertificateAuthority.new
             ca.generate(Puppet[:certname]) unless Puppet::SSL::Certificate.find(Puppet[:certname])
-            
+
             @params = { :address =&gt; &quot;127.0.0.1&quot;, :port =&gt; 34343, :handlers =&gt; [ :test_indirected_foo ], :xmlrpc_handlers =&gt; [ :status ] }
             @server = Puppet::Network::Server.new(@params)
             @server.listen
         end
-
-        after do
-            @server.unlisten
-            @tmpfile.delete
-            Puppet.settings.clear
-            Puppet::Util::Cacher.invalidate
-        end
     
         describe &quot;when finding a model instance over REST&quot; do
             describe &quot;when a matching model instance can be found&quot; do
@@ -87,7 +78,6 @@ describe Puppet::Indirector::REST do
                 end
             
                 it &quot;should not fail&quot; do
-                    Puppet::TestIndirectedFoo.find('bar')
                     lambda { Puppet::TestIndirectedFoo.find('bar') }.should_not raise_error
                 end
     
@@ -151,7 +141,15 @@ describe Puppet::Indirector::REST do
                 end
     
                 it 'should return the instance of the model class associated with the provided lookup key' do
-                    Puppet::TestIndirectedFoo.search('bar').collect(&amp;:value).should == @model_instances.collect(&amp;:value)
+                    Puppet::TestIndirectedFoo.search('bar').collect { |i| i.value }.should == @model_instances.collect { |i| i.value }
+                end
+    
+                it 'should set a version timestamp on model instances' do
+                    pending(&quot;Luke looking at why this version magic might not be working&quot;) do
+                        Puppet::TestIndirectedFoo.search('bar').each do |result|
+                            result.version.should_not be_nil
+                        end
+                    end
                 end
             end
         
@@ -264,6 +262,10 @@ describe Puppet::Indirector::REST do
                 end
             end
         end
+
+        after :each do
+            @server.unlisten
+        end
     end
 
     describe &quot;when using mongrel&quot; do
@@ -283,7 +285,7 @@ describe Puppet::Indirector::REST do
             @server.listen
         end
 
-        after :each do
+        after do
             @server.unlisten
         end
     
@@ -359,7 +361,7 @@ describe Puppet::Indirector::REST do
                 end
     
                 it 'should return the instance of the model class associated with the provided lookup key' do
-                    Puppet::TestIndirectedFoo.search('bar').collect(&amp;:value).should == @model_instances.collect(&amp;:value)
+                    Puppet::TestIndirectedFoo.search('bar').collect { |i| i.value }.should == @model_instances.collect { |i| i.value }
                 end
     
                 it 'should set an expiration on model instances' do
@@ -438,6 +440,9 @@ describe Puppet::Indirector::REST do
                 @instance = Puppet::TestIndirectedFoo.new(42)
                 @mock_model = stub('faked model', :from_yaml =&gt; @instance)
                 Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:model).returns(@mock_model)                
+
+                # LAK:NOTE This stub is necessary to prevent the REST call from calling
+                # REST.save again, thus producing painful infinite recursion.
                 Puppet::Network::HTTP::MongrelREST.any_instance.stubs(:save_object).returns(@instance)                
             end
             </diff>
      <filename>spec/integration/indirector/rest.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,46 +1,48 @@
+#!/usr/bin/env ruby
+
 require File.dirname(__FILE__) + '/../../../spec_helper'
 require 'puppet/network/server'
 require 'socket'
 
 describe Puppet::Network::Server do
-  describe &quot;when using mongrel&quot; do
-    confine &quot;Mongrel is not available&quot; =&gt; Puppet.features.mongrel?
-    
-    before :each do
-      Puppet[:servertype] = 'mongrel'
-      @params = { :address =&gt; &quot;127.0.0.1&quot;, :port =&gt; 34346, :handlers =&gt; [ :node ], :xmlrpc_handlers =&gt; [ :status ] }
-      @server = Puppet::Network::Server.new(@params)      
-    end
+    describe &quot;when using mongrel&quot; do
+        confine &quot;Mongrel is not available&quot; =&gt; Puppet.features.mongrel?
+        
+        before :each do
+            Puppet[:servertype] = 'mongrel'
+            @params = { :address =&gt; &quot;127.0.0.1&quot;, :port =&gt; 34346, :handlers =&gt; [ :node ] }
+            @server = Puppet::Network::Server.new(@params)            
+        end
 
-    describe &quot;before listening&quot; do
-      it &quot;should not be reachable at the specified address and port&quot; do
-        lambda { TCPSocket.new('127.0.0.1', 34346) }.should raise_error(Errno::ECONNREFUSED)
-      end
-    end
+        describe &quot;before listening&quot; do
+            it &quot;should not be reachable at the specified address and port&quot; do
+                lambda { TCPSocket.new('127.0.0.1', 34346) }.should raise_error(Errno::ECONNREFUSED)
+            end
+        end
 
-    describe &quot;when listening&quot; do
-      it &quot;should be reachable on the specified address and port&quot; do
-        @server.listen
-        lambda { TCPSocket.new('127.0.0.1', 34346) }.should_not raise_error      
-      end
+        describe &quot;when listening&quot; do
+            it &quot;should be reachable on the specified address and port&quot; do
+                @server.listen
+                lambda { TCPSocket.new('127.0.0.1', 34346) }.should_not raise_error            
+            end
 
-      it &quot;should not allow multiple servers to listen on the same address and port&quot; do
-        @server.listen
-        @server2 = Puppet::Network::Server.new(@params)
-        lambda { @server2.listen }.should raise_error
-      end
-    end
-    
-    describe &quot;after unlistening&quot; do
-      it &quot;should not be reachable on the port and address assigned&quot; do
-        @server.listen
-        @server.unlisten
-        lambda { TCPSocket.new('127.0.0.1', 34346) }.should raise_error(Errno::ECONNREFUSED)        
-      end
+            it &quot;should not allow multiple servers to listen on the same address and port&quot; do
+                @server.listen
+                @server2 = Puppet::Network::Server.new(@params)
+                lambda { @server2.listen }.should raise_error
+            end
+        end
+        
+        describe &quot;after unlistening&quot; do
+            it &quot;should not be reachable on the port and address assigned&quot; do
+                @server.listen
+                @server.unlisten
+                lambda { TCPSocket.new('127.0.0.1', 34346) }.should raise_error(Errno::ECONNREFUSED)                
+            end
+        end
+            
+        after :each do
+            @server.unlisten if @server.listening?
+        end    
     end
-      
-    after :each do
-      @server.unlisten if @server.listening?
-    end  
-  end
 end</diff>
      <filename>spec/integration/network/server/mongrel.rb</filename>
    </modified>
    <modified>
      <diff>@@ -41,13 +41,13 @@ describe Puppet::Network::Server do
 
         describe &quot;when listening&quot; do
             it &quot;should be reachable on the specified address and port&quot; do
-                @server = Puppet::Network::Server.new(@params.merge(:port =&gt; 34343))      
+                @server = Puppet::Network::Server.new(@params.merge(:port =&gt; 34343))            
                 @server.listen
-                lambda { TCPSocket.new('127.0.0.1', 34343) }.should_not raise_error      
+                lambda { TCPSocket.new('127.0.0.1', 34343) }.should_not raise_error            
             end
 
             it &quot;should not allow multiple servers to listen on the same address and port&quot; do
-                @server = Puppet::Network::Server.new(@params.merge(:port =&gt; 34343))      
+                @server = Puppet::Network::Server.new(@params.merge(:port =&gt; 34343))            
                 @server.listen
                 @server2 = Puppet::Network::Server.new(@params.merge(:port =&gt; 34343))
                 lambda { @server2.listen }.should raise_error</diff>
      <filename>spec/integration/network/server/webrick.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 dir = File.expand_path(File.dirname(__FILE__))
 [ &quot;#{dir}/../../lib&quot;, &quot;#{dir}/../../test/lib&quot;].each do |dir|
-    fulldir = File.expand_path(dir)
-    $LOAD_PATH.unshift(fulldir) unless $LOAD_PATH.include?(fulldir)
+        fulldir = File.expand_path(dir)
+        $LOAD_PATH.unshift(fulldir) unless $LOAD_PATH.include?(fulldir)
 end
 
 require 'spec'
@@ -9,35 +9,35 @@ require 'puppettest'
 require 'puppettest/runnable_test'
 
 module Spec
-  module Runner
-    class ExampleGroupRunner
-      def run
-        prepare
-        success = true
-        example_groups.each do |example_group|
-          next unless example_group.runnable?
-          success = success &amp; example_group.run
+    module Runner
+        class ExampleGroupRunner
+            def run
+                prepare
+                success = true
+                example_groups.each do |example_group|
+                    next unless example_group.runnable?
+                    success = success &amp; example_group.run
+                end
+                return success
+            ensure
+                finish
+            end
         end
-        return success
-      ensure
-        finish
-      end
     end
-  end
 end
 
 module Spec
-  module Example
-    class ExampleGroup
-      extend PuppetTest::RunnableTest
+    module Example
+        class ExampleGroup
+            extend PuppetTest::RunnableTest
+        end
     end
-  end
 end
 
 module Test
-  module Unit
-    class TestCase
-      extend PuppetTest::RunnableTest
+    module Unit
+        class TestCase
+            extend PuppetTest::RunnableTest
+        end
     end
-  end
 end</diff>
      <filename>spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,7 +23,7 @@ require 'spec'
 Dir[&quot;#{dir}/monkey_patches/*.rb&quot;].map { |file| require file }
 
 Spec::Runner.configure do |config|
-  config.mock_with :mocha
+    config.mock_with :mocha
 
 #  config.prepend_before :all do
 #      setup_mocks_for_rspec
@@ -34,3 +34,8 @@ Spec::Runner.configure do |config|
 #      teardown() if respond_to? :teardown
 #  end
 end
+
+# Set the confdir and vardir to gibberish so that tests
+# have to be correctly mocked.
+Puppet[:confdir] = &quot;/dev/null&quot;
+Puppet[:vardir] = &quot;/dev/null&quot;</diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,8 +23,8 @@ describe Puppet::Node::Catalog::Compiler do
         node1 = stub 'node1', :merge =&gt; nil
         node2 = stub 'node2', :merge =&gt; nil
         compiler.stubs(:compile)
-        Puppet::Node.stubs(:find_by_any_name).with('node1').returns(node1)
-        Puppet::Node.stubs(:find_by_any_name).with('node2').returns(node2)
+        Puppet::Node.stubs(:find).with('node1').returns(node1)
+        Puppet::Node.stubs(:find).with('node2').returns(node2)
 
         compiler.find(stub('request', :key =&gt; 'node1', :options =&gt; {}))
         compiler.find(stub('node2request', :key =&gt; 'node2', :options =&gt; {}))
@@ -69,7 +69,7 @@ describe Puppet::Node::Catalog::Compiler, &quot; when finding nodes&quot; do
 
     it &quot;should look node information up via the Node class with the provided key&quot; do
         @node.stubs :merge 
-        Puppet::Node.expects(:find_by_any_name).with(@name).returns(@node)
+        Puppet::Node.expects(:find).with(@name).returns(@node)
         @compiler.find(@request)
     end
 end
@@ -77,7 +77,6 @@ end
 describe Puppet::Node::Catalog::Compiler, &quot; after finding nodes&quot; do
     before do
         Puppet.expects(:version).returns(1)
-        Puppet.settings.stubs(:value).with(:node_name).returns(&quot;cert&quot;)
         Facter.expects(:value).with('fqdn').returns(&quot;my.server.com&quot;)
         Facter.expects(:value).with('ipaddress').returns(&quot;my.ip.address&quot;)
         @compiler = Puppet::Node::Catalog::Compiler.new
@@ -85,7 +84,7 @@ describe Puppet::Node::Catalog::Compiler, &quot; after finding nodes&quot; do
         @node = mock 'node'
         @request = stub 'request', :key =&gt; @name, :options =&gt; {}
         @compiler.stubs(:compile)
-        Puppet::Node.stubs(:find_by_any_name).with(@name).returns(@node)
+        Puppet::Node.stubs(:find).with(@name).returns(@node)
     end
 
     it &quot;should add the server's Puppet version to the node's parameters as 'serverversion'&quot; do
@@ -102,13 +101,6 @@ describe Puppet::Node::Catalog::Compiler, &quot; after finding nodes&quot; do
         @node.expects(:merge).with { |args| args[&quot;serverip&quot;] == &quot;my.ip.address&quot; }
         @compiler.find(@request)
     end
-
-    # LAK:TODO This is going to be difficult, because this whole process is so
-    # far removed from the actual connection that the certificate information
-    # will be quite hard to come by, dum by, gum by.
-    it &quot;should search for the name using the client certificate's DN if the :node_name setting is set to 'cert'&quot; do
-        pending &quot;Probably will end up in the REST work&quot;
-    end
 end
 
 describe Puppet::Node::Catalog::Compiler, &quot; when creating catalogs&quot; do
@@ -122,18 +114,18 @@ describe Puppet::Node::Catalog::Compiler, &quot; when creating catalogs&quot; do
         @node = Puppet::Node.new @name
         @node.stubs(:merge)
         @request = stub 'request', :key =&gt; @name, :options =&gt; {}
-        Puppet::Node.stubs(:find_by_any_name).with(@name).returns(@node)
+        Puppet::Node.stubs(:find).with(@name).returns(@node)
     end
 
     it &quot;should directly use provided nodes&quot; do
-        Puppet::Node.expects(:find_by_any_name).never
+        Puppet::Node.expects(:find).never
         @compiler.interpreter.expects(:compile).with(@node)
         @request.stubs(:options).returns(:node =&gt; @node)
         @compiler.find(@request)
     end
 
     it &quot;should fail if no node is passed and none can be found&quot; do
-        Puppet::Node.stubs(:find_by_any_name).with(@name).returns(nil)
+        Puppet::Node.stubs(:find).with(@name).returns(nil)
         proc { @compiler.find(@request) }.should raise_error(ArgumentError)
     end
 </diff>
      <filename>spec/unit/indirector/catalog/compiler.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@ require 'puppet/indirector/indirection'
 
 describe &quot;Indirection Delegator&quot;, :shared =&gt; true do
     it &quot;should create a request object with the appropriate method name and all of the passed arguments&quot; do
-        request = stub 'request', :options =&gt; {}
+        request = stub 'request', :node =&gt; nil
 
         @indirection.expects(:request).with(@method, &quot;mystuff&quot;, :one =&gt; :two).returns request
 
@@ -342,7 +342,7 @@ describe Puppet::Indirector::Indirection do
                 end
 
                 it &quot;should use a request to save the object to the cache&quot; do
-                    request = stub 'request', :instance =&gt; @instance, :options =&gt; {}
+                    request = stub 'request', :instance =&gt; @instance, :node =&gt; nil
 
                     @indirection.expects(:request).returns request
 
@@ -373,8 +373,8 @@ describe Puppet::Indirector::Indirection do
                 end
 
                 it &quot;should use a request instance to search in and remove objects from the cache&quot; do
-                    destroy = stub 'destroy_request', :key =&gt; &quot;/my/key&quot;, :options =&gt; {}
-                    find = stub 'destroy_request', :key =&gt; &quot;/my/key&quot;, :options =&gt; {}
+                    destroy = stub 'destroy_request', :key =&gt; &quot;/my/key&quot;, :node =&gt; nil
+                    find = stub 'destroy_request', :key =&gt; &quot;/my/key&quot;, :node =&gt; nil
 
                     @indirection.expects(:request).with(:destroy, &quot;/my/key&quot;).returns destroy
                     @indirection.expects(:request).with(:find, &quot;/my/key&quot;).returns find</diff>
      <filename>spec/unit/indirector/indirection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,24 +10,24 @@ require 'puppet/indirector/module_files'
 
 describe Puppet::Indirector::ModuleFiles do
 
-  before :each do
-      Puppet::Node::Environment.stubs(:new).returns(stub('env', :name =&gt; &quot;myenv&quot;))
-      Puppet::Indirector::Terminus.stubs(:register_terminus_class)
-      @model = mock 'model'
-      @indirection = stub 'indirection', :name =&gt; :mystuff, :register_terminus_type =&gt; nil, :model =&gt; @model
-      Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
-
-      @module_files_class = Class.new(Puppet::Indirector::ModuleFiles) do
-          def self.to_s
-              &quot;Testing::Mytype&quot;
-          end
-      end
-
-      @module_files = @module_files_class.new
-
-      @uri = &quot;puppetmounts://host/modules/my/local/file&quot;
-      @module = Puppet::Module.new(&quot;mymod&quot;, &quot;/module/path&quot;)
-  end
+    before :each do
+        Puppet::Node::Environment.stubs(:new).returns(stub('env', :name =&gt; &quot;myenv&quot;))
+        Puppet::Indirector::Terminus.stubs(:register_terminus_class)
+        @model = mock 'model'
+        @indirection = stub 'indirection', :name =&gt; :mystuff, :register_terminus_type =&gt; nil, :model =&gt; @model
+        Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
+  
+        @module_files_class = Class.new(Puppet::Indirector::ModuleFiles) do
+            def self.to_s
+                &quot;Testing::Mytype&quot;
+            end
+        end
+  
+        @module_files = @module_files_class.new
+  
+        @uri = &quot;puppetmounts://host/modules/my/local/file&quot;
+        @module = Puppet::Module.new(&quot;mymod&quot;, &quot;/module/path&quot;)
+    end
 
     describe Puppet::Indirector::ModuleFiles, &quot; when finding files&quot; do
 </diff>
      <filename>spec/unit/indirector/module_files.rb</filename>
    </modified>
    <modified>
      <diff>@@ -49,6 +49,12 @@ describe Puppet::Node::Exec do
             @searcher.find(@request)
         end
 
+        it &quot;should convert all parameters into strings&quot; do
+            @result[:parameters] = {&quot;a&quot; =&gt; true, &quot;c&quot; =&gt; 100}
+            @node.expects(:parameters=).with &quot;a&quot; =&gt; &quot;true&quot;, &quot;c&quot; =&gt; &quot;100&quot;
+            @searcher.find(@request)
+        end
+
         it &quot;should set the resulting classes as the node classes&quot; do
             @result[:classes] = %w{one two}
             @node.expects(:classes=).with %w{one two}</diff>
      <filename>spec/unit/indirector/node/exec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -21,14 +21,32 @@ describe Puppet::Node::Ldap do
             @searcher.stubs(:search_base).returns(:yay)
             @searcher.stubs(:search_filter).returns(:filter)
 
-            @node = mock 'node'
+            @name = &quot;mynode.domain.com&quot;
+            @node = stub 'node', :name =&gt; @name
             @node.stubs(:fact_merge)
-            @name = &quot;mynode&quot;
             Puppet::Node.stubs(:new).with(@name).returns(@node)
 
             @request = stub 'request', :key =&gt; @name
         end
 
+        it &quot;should search first for the provided key&quot; do
+            @searcher.expects(:entry2hash).with(&quot;mynode.domain.com&quot;).returns({})
+            @searcher.find(@request)
+        end
+
+        it &quot;should search for the short version of the provided key if the key looks like a hostname and no results are found for the key itself&quot; do
+            @searcher.expects(:entry2hash).with(&quot;mynode.domain.com&quot;).returns(nil)
+            @searcher.expects(:entry2hash).with(&quot;mynode&quot;).returns({})
+            @searcher.find(@request)
+        end
+
+        it &quot;should search for default information if no information can be found for the key&quot; do
+            @searcher.expects(:entry2hash).with(&quot;mynode.domain.com&quot;).returns(nil)
+            @searcher.expects(:entry2hash).with(&quot;mynode&quot;).returns(nil)
+            @searcher.expects(:entry2hash).with(&quot;default&quot;).returns({})
+            @searcher.find(@request)
+        end
+
         it &quot;should return nil if no results are found in ldap&quot; do
             @connection.stubs(:search)
             @searcher.find(@request).should be_nil</diff>
      <filename>spec/unit/indirector/node/ldap.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,6 +8,10 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
 require 'puppet/indirector/report/processor'
 
 describe Puppet::Transaction::Report::Processor do
+    before do
+        Puppet.settings.stubs(:use).returns(true)
+    end
+
     it &quot;should provide a method for saving reports&quot; do
         Puppet::Transaction::Report::Processor.new.should respond_to(:save)
     end</diff>
      <filename>spec/unit/indirector/report/processor.rb</filename>
    </modified>
    <modified>
      <diff>@@ -43,6 +43,38 @@ describe Puppet::Indirector::Request do
         it &quot;should use an empty options hash if nil was provided&quot; do
             Puppet::Indirector::Request.new(:ind, :method, :key, nil).options.should == {}
         end
+
+        it &quot;should default to a nil node&quot; do
+            Puppet::Indirector::Request.new(:ind, :method, :key, nil).node.should be_nil
+        end
+
+        it &quot;should set its node attribute if provided in the options&quot; do
+            Puppet::Indirector::Request.new(:ind, :method, :key, :node =&gt; &quot;foo.com&quot;).node.should == &quot;foo.com&quot;
+        end
+
+        it &quot;should default to a nil ip&quot; do
+            Puppet::Indirector::Request.new(:ind, :method, :key, nil).ip.should be_nil
+        end
+
+        it &quot;should set its ip attribute if provided in the options&quot; do
+            Puppet::Indirector::Request.new(:ind, :method, :key, :ip =&gt; &quot;192.168.0.1&quot;).ip.should == &quot;192.168.0.1&quot;
+        end
+
+        it &quot;should default to being unauthenticated&quot; do
+            Puppet::Indirector::Request.new(:ind, :method, :key, nil).should_not be_authenticated
+        end
+
+        it &quot;should set be marked authenticated if configured in the options&quot; do
+            Puppet::Indirector::Request.new(:ind, :method, :key, :authenticated =&gt; &quot;eh&quot;).should be_authenticated
+        end
+
+        it &quot;should keep its options as a hash even if a node is specified&quot; do
+            Puppet::Indirector::Request.new(:ind, :method, :key, :node =&gt; &quot;eh&quot;).options.should be_instance_of(Hash)
+        end
+
+        it &quot;should keep its options as a hash even if another option is specified&quot; do
+            Puppet::Indirector::Request.new(:ind, :method, :key, :foo =&gt; &quot;bar&quot;).options.should be_instance_of(Hash)
+        end
     end
 
     it &quot;should look use the Indirection class to return the appropriate indirection&quot; do</diff>
      <filename>spec/unit/indirector/request.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,8 +9,10 @@ require 'puppet/network/client'
 
 describe Puppet::Network::Client do
     before do
+        Puppet.settings.stubs(:use).returns(true)
         Puppet::Network::HttpPool.stubs(:cert_setup)
     end
+
     describe &quot;when keep-alive is enabled&quot; do
         before do
             Puppet::Network::HttpPool.stubs(:keep_alive?).returns true</diff>
      <filename>spec/unit/network/client.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,6 +8,7 @@ require 'puppet/network/client/master'
 
 describe Puppet::Network::Client::Master, &quot; when retrieving the catalog&quot; do
     before do
+        Puppet.settings.stubs(:use).returns(true)
         @master = mock 'master'
         @client = Puppet::Network::Client.master.new(
             :Master =&gt; @master
@@ -218,6 +219,7 @@ end
 
 describe Puppet::Network::Client::Master, &quot; when using the cached catalog&quot; do
     before do
+        Puppet.settings.stubs(:use).returns(true)
         @master = mock 'master'
         @client = Puppet::Network::Client.master.new(
             :Master =&gt; @master</diff>
      <filename>spec/unit/network/client/master.rb</filename>
    </modified>
    <modified>
      <filename>spec/unit/network/http.rb</filename>
    </modified>
    <modified>
      <filename>spec/unit/network/http/mongrel.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,11 @@
+#!/usr/bin/env ruby
+
 require File.dirname(__FILE__) + '/../../../../spec_helper'
 require 'puppet/network/http'
 
 describe Puppet::Network::HTTP::MongrelREST, &quot;when initializing&quot; do
     confine &quot;Mongrel is not available&quot; =&gt; Puppet.features.mongrel?
-    
+
     before do
         @mock_mongrel = mock('Mongrel server')
         @mock_mongrel.stubs(:register)
@@ -11,20 +13,20 @@ describe Puppet::Network::HTTP::MongrelREST, &quot;when initializing&quot; do
         Puppet::Indirector::Indirection.stubs(:model).with(:foo).returns(@mock_model)
         @params = { :server =&gt; @mock_mongrel, :handler =&gt; :foo }
     end
-    
+
     it &quot;should require access to a Mongrel server&quot; do
         Proc.new { Puppet::Network::HTTP::MongrelREST.new(@params.delete_if {|k,v| :server == k })}.should raise_error(ArgumentError)
     end
-    
+
     it &quot;should require an indirection name&quot; do
         Proc.new { Puppet::Network::HTTP::MongrelREST.new(@params.delete_if {|k,v| :handler == k })}.should raise_error(ArgumentError)        
     end
-    
+
     it &quot;should look up the indirection model from the indirection name&quot; do
         Puppet::Indirector::Indirection.expects(:model).with(:foo).returns(@mock_model)
         Puppet::Network::HTTP::MongrelREST.new(@params)
     end
-    
+
     it &quot;should fail if the indirection is not known&quot; do
         Puppet::Indirector::Indirection.expects(:model).with(:foo).returns(nil)
         Proc.new { Puppet::Network::HTTP::MongrelREST.new(@params) }.should raise_error(ArgumentError)
@@ -33,7 +35,7 @@ end
 
 describe Puppet::Network::HTTP::MongrelREST, &quot;when receiving a request&quot; do
     confine &quot;Mongrel is not available&quot; =&gt; Puppet.features.mongrel?
-    
+
     before do
         @mock_request = stub('mongrel http request')
         @mock_head = stub('response head')
@@ -45,28 +47,28 @@ describe Puppet::Network::HTTP::MongrelREST, &quot;when receiving a request&quot; do
         Puppet::Indirector::Indirection.stubs(:model).with(:foo).returns(@mock_model_class)
         @handler = Puppet::Network::HTTP::MongrelREST.new(:server =&gt; @mock_mongrel, :handler =&gt; :foo)
     end
-    
+
     def setup_find_request(params = {})
         @mock_request.stubs(:params).returns({  Mongrel::Const::REQUEST_METHOD =&gt; 'GET', 
                                                 Mongrel::Const::REQUEST_PATH =&gt; '/foo/key',
                                                 'QUERY_STRING' =&gt; ''}.merge(params))
         @mock_model_class.stubs(:find)
     end
-    
+
     def setup_search_request(params = {})
         @mock_request.stubs(:params).returns({  Mongrel::Const::REQUEST_METHOD =&gt; 'GET', 
                                                 Mongrel::Const::REQUEST_PATH =&gt; '/foos',
                                                 'QUERY_STRING' =&gt; '' }.merge(params))
         @mock_model_class.stubs(:search).returns([])        
     end
-    
+
     def setup_destroy_request(params = {})
         @mock_request.stubs(:params).returns({  Mongrel::Const::REQUEST_METHOD =&gt; 'DELETE', 
                                                 Mongrel::Const::REQUEST_PATH =&gt; '/foo/key',
                                                 'QUERY_STRING' =&gt; '' }.merge(params))
         @mock_model_class.stubs(:destroy)
     end
-    
+
     def setup_save_request(params = {})
         @mock_request.stubs(:params).returns({  Mongrel::Const::REQUEST_METHOD =&gt; 'PUT', 
                                                 Mongrel::Const::REQUEST_PATH =&gt; '/foo',
@@ -75,26 +77,26 @@ describe Puppet::Network::HTTP::MongrelREST, &quot;when receiving a request&quot; do
         @mock_model_instance = stub('indirected model instance', :save =&gt; true)
         @mock_model_class.stubs(:from_yaml).returns(@mock_model_instance)
     end
-    
+
     def setup_bad_request
         @mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD =&gt; 'POST', Mongrel::Const::REQUEST_PATH =&gt; '/foos'})        
     end
 
     it &quot;should call the model find method if the request represents a singular HTTP GET&quot; do
         setup_find_request
-        @mock_model_class.expects(:find).with('key', {})
+        @mock_model_class.expects(:find).with { |key, args| key == 'key' }
         @handler.process(@mock_request, @mock_response)
     end
 
     it &quot;should call the model search method if the request represents a plural HTTP GET&quot; do
         setup_search_request
-        @mock_model_class.expects(:search).with({}).returns([])
+        @mock_model_class.expects(:search).returns([])
         @handler.process(@mock_request, @mock_response)
     end
-    
+
     it &quot;should call the model destroy method if the request represents an HTTP DELETE&quot; do
         setup_destroy_request
-        @mock_model_class.expects(:destroy).with('key', {})
+        @mock_model_class.expects(:destroy).with { |key, args| key == 'key' }
         @handler.process(@mock_request, @mock_response)
     end
 
@@ -103,13 +105,13 @@ describe Puppet::Network::HTTP::MongrelREST, &quot;when receiving a request&quot; do
         @mock_model_instance.expects(:save)
         @handler.process(@mock_request, @mock_response)
     end
-    
+
     it &quot;should fail if the HTTP method isn't supported&quot; do
         @mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD =&gt; 'POST', Mongrel::Const::REQUEST_PATH =&gt; '/foo'})
         @mock_response.expects(:start).with(404)
         @handler.process(@mock_request, @mock_response)
     end
-    
+
     it &quot;should fail if the request's pluralization is wrong&quot; do
         @mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD =&gt; 'DELETE', Mongrel::Const::REQUEST_PATH =&gt; '/foos/key'})
         @mock_response.expects(:start).with(404)
@@ -127,8 +129,74 @@ describe Puppet::Network::HTTP::MongrelREST, &quot;when receiving a request&quot; do
         @mock_response.expects(:start).with(404)
         @handler.process(@mock_request, @mock_response)
     end
-    
-    
+
+    describe &quot;and determining the request parameters&quot;, :shared =&gt; true do
+        before do
+            @mock_request.stubs(:params).returns({})
+        end
+
+        it &quot;should include the HTTP request parameters&quot; do
+            @mock_request.expects(:params).returns('QUERY_STRING' =&gt; 'foo=baz&amp;bar=xyzzy')
+            result = @handler.params(@mock_request)
+            result[&quot;foo&quot;].should == &quot;baz&quot;
+            result[&quot;bar&quot;].should == &quot;xyzzy&quot;
+        end
+
+        it &quot;should pass the client's ip address to model find&quot; do
+            @mock_request.stubs(:params).returns(&quot;REMOTE_ADDR&quot; =&gt; &quot;ipaddress&quot;)
+            @handler.params(@mock_request)[:ip].should == &quot;ipaddress&quot;
+        end
+
+        it &quot;should use the :ssl_client_header to determine the parameter when looking for the certificate&quot; do
+            Puppet.settings.stubs(:value).returns &quot;eh&quot;
+            Puppet.settings.expects(:value).with(:ssl_client_header).returns &quot;myheader&quot;
+            @mock_request.stubs(:params).returns(&quot;myheader&quot; =&gt; &quot;/CN=host.domain.com&quot;)
+            @handler.params(@mock_request)
+        end
+
+        it &quot;should retrieve the hostname by matching the certificate parameter&quot; do
+            Puppet.settings.stubs(:value).returns &quot;eh&quot;
+            Puppet.settings.expects(:value).with(:ssl_client_header).returns &quot;myheader&quot;
+            @mock_request.stubs(:params).returns(&quot;myheader&quot; =&gt; &quot;/CN=host.domain.com&quot;)
+            @handler.params(@mock_request)[:node].should == &quot;host.domain.com&quot;
+        end
+
+        it &quot;should use the :ssl_client_header to determine the parameter for checking whether the host certificate is valid&quot; do
+            Puppet.settings.stubs(:value).with(:ssl_client_header).returns &quot;certheader&quot;
+            Puppet.settings.expects(:value).with(:ssl_client_verify_header).returns &quot;myheader&quot;
+            @mock_request.stubs(:params).returns(&quot;myheader&quot; =&gt; &quot;SUCCESS&quot;, &quot;certheader&quot; =&gt; &quot;/CN=host.domain.com&quot;)
+            @handler.params(@mock_request)
+        end
+
+        it &quot;should consider the host authenticated if the validity parameter contains 'SUCCESS'&quot; do
+            Puppet.settings.stubs(:value).with(:ssl_client_header).returns &quot;certheader&quot;
+            Puppet.settings.stubs(:value).with(:ssl_client_verify_header).returns &quot;myheader&quot;
+            @mock_request.stubs(:params).returns(&quot;myheader&quot; =&gt; &quot;SUCCESS&quot;, &quot;certheader&quot; =&gt; &quot;/CN=host.domain.com&quot;)
+            @handler.params(@mock_request)[:authenticated].should be_true
+        end
+
+        it &quot;should consider the host unauthenticated if the validity parameter does not contain 'SUCCESS'&quot; do
+            Puppet.settings.stubs(:value).with(:ssl_client_header).returns &quot;certheader&quot;
+            Puppet.settings.stubs(:value).with(:ssl_client_verify_header).returns &quot;myheader&quot;
+            @mock_request.stubs(:params).returns(&quot;myheader&quot; =&gt; &quot;whatever&quot;, &quot;certheader&quot; =&gt; &quot;/CN=host.domain.com&quot;)
+            @handler.params(@mock_request)[:authenticated].should be_false
+        end
+
+        it &quot;should consider the host unauthenticated if no certificate information is present&quot; do
+            Puppet.settings.stubs(:value).with(:ssl_client_header).returns &quot;certheader&quot;
+            Puppet.settings.stubs(:value).with(:ssl_client_verify_header).returns &quot;myheader&quot;
+            @mock_request.stubs(:params).returns(&quot;myheader&quot; =&gt; nil, &quot;certheader&quot; =&gt; &quot;SUCCESS&quot;)
+            @handler.params(@mock_request)[:authenticated].should be_false
+        end
+
+        it &quot;should not pass a node name to model method if no certificate information is present&quot; do
+            Puppet.settings.stubs(:value).returns &quot;eh&quot;
+            Puppet.settings.expects(:value).with(:ssl_client_header).returns &quot;myheader&quot;
+            @mock_request.stubs(:params).returns(&quot;myheader&quot; =&gt; nil)
+            @handler.params(@mock_request).should_not be_include(:node)
+        end
+    end
+
     describe &quot;when finding a model instance&quot; do |variable|
         it &quot;should fail to find model if key is not specified&quot; do
             @mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD =&gt; 'GET', Mongrel::Const::REQUEST_PATH =&gt; '/foo'})
@@ -136,20 +204,21 @@ describe Puppet::Network::HTTP::MongrelREST, &quot;when receiving a request&quot; do
             @handler.process(@mock_request, @mock_response)
         end
 
-        it &quot;should pass HTTP request parameters to model find&quot; do
+        it &quot;should use a common method for determining the request parameters&quot; do
             setup_find_request('QUERY_STRING' =&gt; 'foo=baz&amp;bar=xyzzy')
+            @handler.expects(:params).returns(:foo =&gt; :baz, :bar =&gt; :xyzzy)
             @mock_model_class.expects(:find).with do |key, args|
-                key == 'key' and args['foo'] == 'baz' and args['bar'] == 'xyzzy'
+                args[:foo] == :baz and args[:bar] == :xyzzy
             end
             @handler.process(@mock_request, @mock_response)
         end
-        
+
         it &quot;should generate a 200 response when a model find call succeeds&quot; do
             setup_find_request
             @mock_response.expects(:start).with(200)
             @handler.process(@mock_request, @mock_response)
         end
-        
+
         it &quot;should return a serialized object when a model find call succeeds&quot; do
             setup_find_request
             @mock_model_instance = stub('model instance')
@@ -157,7 +226,7 @@ describe Puppet::Network::HTTP::MongrelREST, &quot;when receiving a request&quot; do
             @mock_model_class.stubs(:find).returns(@mock_model_instance)
             @handler.process(@mock_request, @mock_response)                  
         end
-        
+
         it &quot;should serialize a controller exception when an exception is thrown by find&quot; do
            setup_find_request
            @mock_model_class.expects(:find).raises(ArgumentError) 
@@ -172,7 +241,16 @@ describe Puppet::Network::HTTP::MongrelREST, &quot;when receiving a request&quot; do
             @mock_response.expects(:start).with(404)
             @handler.process(@mock_request, @mock_response)
         end
-        
+
+        it &quot;should use a common method for determining the request parameters&quot; do
+            setup_destroy_request('QUERY_STRING' =&gt; 'foo=baz&amp;bar=xyzzy')
+            @handler.expects(:params).returns(:foo =&gt; :baz, :bar =&gt; :xyzzy)
+            @mock_model_class.expects(:destroy).with do |key, args|
+                args[:foo] == :baz and args[:bar] == :xyzzy
+            end
+            @handler.process(@mock_request, @mock_response)
+        end
+
         it &quot;should pass HTTP request parameters to model destroy&quot; do
             setup_destroy_request('QUERY_STRING' =&gt; 'foo=baz&amp;bar=xyzzy')
             @mock_model_class.expects(:destroy).with do |key, args|
@@ -180,20 +258,20 @@ describe Puppet::Network::HTTP::MongrelREST, &quot;when receiving a request&quot; do
             end
             @handler.process(@mock_request, @mock_response)
         end
-        
+
         it &quot;should generate a 200 response when a model destroy call succeeds&quot; do
             setup_destroy_request
             @mock_response.expects(:start).with(200)
             @handler.process(@mock_request, @mock_response)
         end
-        
+
         it &quot;should return a serialized success result when a model destroy call succeeds&quot; do
             setup_destroy_request
             @mock_model_class.stubs(:destroy).returns(true)
             @mock_body.expects(:write).with(&quot;--- true\n&quot;)
             @handler.process(@mock_request, @mock_response)
         end
-        
+
         it &quot;should serialize a controller exception when an exception is thrown by destroy&quot; do
             setup_destroy_request
             @mock_model_class.expects(:destroy).raises(ArgumentError) 
@@ -201,7 +279,7 @@ describe Puppet::Network::HTTP::MongrelREST, &quot;when receiving a request&quot; do
             @handler.process(@mock_request, @mock_response)                 
         end
     end
-    
+
     describe &quot;when saving a model instance&quot; do |variable|    
         it &quot;should fail to save model if data is not specified&quot; do
             @mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD =&gt; 'PUT', Mongrel::Const::REQUEST_PATH =&gt; '/foo'})
@@ -209,20 +287,29 @@ describe Puppet::Network::HTTP::MongrelREST, &quot;when receiving a request&quot; do
             @mock_response.expects(:start).with(404)
             @handler.process(@mock_request, @mock_response)
         end
-        
+
+        it &quot;should use a common method for determining the request parameters&quot; do
+            setup_save_request('QUERY_STRING' =&gt; 'foo=baz&amp;bar=xyzzy')
+            @handler.expects(:params).returns(:foo =&gt; :baz, :bar =&gt; :xyzzy)
+            @mock_model_instance.expects(:save).with do |args|
+                args[:foo] == :baz and args[:bar] == :xyzzy
+            end
+            @handler.process(@mock_request, @mock_response)
+        end
+
         it &quot;should generate a 200 response when a model save call succeeds&quot; do
             setup_save_request
             @mock_response.expects(:start).with(200)
             @handler.process(@mock_request, @mock_response)
         end
-        
+
         it &quot;should return a serialized object when a model save call succeeds&quot; do
             setup_save_request
             @mock_model_instance.stubs(:save).returns(@mock_model_instance)
             @mock_model_instance.expects(:to_yaml).returns('foo')
             @handler.process(@mock_request, @mock_response)        
         end
-        
+
         it &quot;should serialize a controller exception when an exception is thrown by save&quot; do
             setup_save_request
             @mock_model_instance.expects(:save).raises(ArgumentError) 
@@ -230,8 +317,17 @@ describe Puppet::Network::HTTP::MongrelREST, &quot;when receiving a request&quot; do
             @handler.process(@mock_request, @mock_response)                         
         end
     end
-    
+
     describe &quot;when searching for model instances&quot; do |variable|
+        it &quot;should use a common method for determining the request parameters&quot; do
+            setup_search_request('QUERY_STRING' =&gt; 'foo=baz&amp;bar=xyzzy')
+            @handler.expects(:params).returns(:foo =&gt; :baz, :bar =&gt; :xyzzy)
+            @mock_model_class.expects(:search).with do |args|
+                args[:foo] == :baz and args[:bar] == :xyzzy
+            end
+            @handler.process(@mock_request, @mock_response)
+        end
+
         it &quot;should pass HTTP request parameters to model search&quot; do
             setup_search_request('QUERY_STRING' =&gt; 'foo=baz&amp;bar=xyzzy')
             @mock_model_class.expects(:search).with do |args|
@@ -245,7 +341,7 @@ describe Puppet::Network::HTTP::MongrelREST, &quot;when receiving a request&quot; do
             @mock_response.expects(:start).with(200)
             @handler.process(@mock_request, @mock_response)
         end
-        
+
         it &quot;should return a list of serialized objects when a model search call succeeds&quot; do
             setup_search_request
             mock_matches = [1..5].collect {|i| mock(&quot;model instance #{i}&quot;, :to_yaml =&gt; &quot;model instance #{i}&quot;) }
@@ -260,7 +356,7 @@ describe Puppet::Network::HTTP::MongrelREST, &quot;when receiving a request&quot; do
             @handler.process(@mock_request, @mock_response)                
         end
     end    
-    
+
     it &quot;should serialize a controller exception if the request fails&quot; do
         setup_bad_request     
         @mock_response.expects(:start).with(404)</diff>
      <filename>spec/unit/network/http/mongrel/rest.rb</filename>
    </modified>
    <modified>
      <filename>spec/unit/network/http/mongrel/xmlrpc.rb</filename>
    </modified>
    <modified>
      <diff>@@ -162,7 +162,7 @@ describe Puppet::Network::HTTP::WEBrick, &quot;when looking up the class to handle a
     end
 
     it &quot;should accept a protocol&quot; do
-        lambda { Puppet::Network::HTTP::WEBrick.class_for_protocol(&quot;bob&quot;) }.should_not raise_error(ArgumentError)    
+        lambda { Puppet::Network::HTTP::WEBrick.class_for_protocol(&quot;bob&quot;) }.should_not raise_error(ArgumentError)        
     end
 
     it &quot;should use a WEBrick + REST class when a REST protocol is specified&quot; do</diff>
      <filename>spec/unit/network/http/webrick.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,5 @@
+#!/usr/bin/env ruby
+
 require File.dirname(__FILE__) + '/../../../../spec_helper'
 require 'puppet/network/http'
 
@@ -8,23 +10,23 @@ describe Puppet::Network::HTTP::WEBrickREST, &quot;when initializing&quot; do
         Puppet::Indirector::Indirection.stubs(:model).returns(@mock_model)
         @params = [ @mock_webrick, :foo ]
     end
-    
+
     it &quot;should require access to a WEBrick server&quot; do
         Proc.new { 
             @params[0] = nil
             Puppet::Network::HTTP::WEBrickREST.new(*@params)
         }.should raise_error(ArgumentError)
     end
-    
+
     it &quot;should require an indirection name&quot; do
         Proc.new { Puppet::Network::HTTP::WEBrickREST.new(@params.first) }.should raise_error(ArgumentError)        
     end
-    
+
     it &quot;should look up the indirection model from the indirection name&quot; do
         Puppet::Indirector::Indirection.expects(:model).returns(@mock_model)
         Puppet::Network::HTTP::WEBrickREST.new(*@params)
     end
-    
+
     it &quot;should fail if the indirection is not known&quot; do
         Puppet::Indirector::Indirection.expects(:model).returns(nil)
         Proc.new { Puppet::Network::HTTP::WEBrickREST.new(*@params) }.should raise_error(ArgumentError)
@@ -33,7 +35,7 @@ end
 
 describe Puppet::Network::HTTP::WEBrickREST, &quot;when receiving a request&quot; do
     before do
-        @mock_request     = stub('webrick http request', :query =&gt; {})
+        @mock_request     = stub('webrick http request', :query =&gt; {}, :peeraddr =&gt; %w{eh boo host ip}, :client_cert =&gt; nil)
         @mock_response    = stub('webrick http response', :status= =&gt; true, :body= =&gt; true)
         @mock_model_class = stub('indirected model class')
         @mock_webrick     = stub('webrick http server', :mount =&gt; true, :[] =&gt; {})
@@ -46,19 +48,19 @@ describe Puppet::Network::HTTP::WEBrickREST, &quot;when receiving a request&quot; do
         @mock_request.stubs(:path).returns('/foo/key')
         @mock_model_class.stubs(:find)
     end
-    
+
     def setup_search_request
         @mock_request.stubs(:request_method).returns('GET')
         @mock_request.stubs(:path).returns('/foos')
         @mock_model_class.stubs(:search).returns([])
     end
-    
+
     def setup_destroy_request
         @mock_request.stubs(:request_method).returns('DELETE')
         @mock_request.stubs(:path).returns('/foo/key')
         @mock_model_class.stubs(:destroy)
     end
-    
+
     def setup_save_request
         @mock_request.stubs(:request_method).returns('PUT')
         @mock_request.stubs(:path).returns('/foo')
@@ -66,44 +68,48 @@ describe Puppet::Network::HTTP::WEBrickREST, &quot;when receiving a request&quot; do
         @mock_model_instance = stub('indirected model instance', :save =&gt; true)
         @mock_model_class.stubs(:from_yaml).returns(@mock_model_instance)
     end
-    
+
     def setup_bad_request
         @mock_request.stubs(:request_method).returns('POST')
         @mock_request.stubs(:path).returns('/foos')
     end
-    
-    
+
+    it &quot;should delegate its :service method to its :process method&quot; do
+        @handler.expects(:process).with(@mock_request, @mock_response).returns &quot;stuff&quot;
+        @handler.service(@mock_request, @mock_response).should == &quot;stuff&quot;
+    end
+
     it &quot;should call the model find method if the request represents a singular HTTP GET&quot; do
         setup_find_request
-        @mock_model_class.expects(:find).with('key', {})
-        @handler.service(@mock_request, @mock_response)
+        @mock_model_class.expects(:find).with { |key, args| key == 'key' }
+        @handler.process(@mock_request, @mock_response)
     end
 
     it &quot;should call the model search method if the request represents a plural HTTP GET&quot; do
         setup_search_request
         @mock_model_class.expects(:search).returns([])
-        @handler.service(@mock_request, @mock_response)
+        @handler.process(@mock_request, @mock_response)
     end
-    
+
     it &quot;should call the model destroy method if the request represents an HTTP DELETE&quot; do
         setup_destroy_request
-        @mock_model_class.expects(:destroy).with('key', {})
-        @handler.service(@mock_request, @mock_response)
+        @mock_model_class.expects(:destroy).with { |key, args| key == 'key' }
+        @handler.process(@mock_request, @mock_response)
     end
 
     it &quot;should call the model save method if the request represents an HTTP PUT&quot; do
         setup_save_request
         @mock_model_instance.expects(:save)
-        @handler.service(@mock_request, @mock_response)
+        @handler.process(@mock_request, @mock_response)
     end
-    
+
     it &quot;should fail if the HTTP method isn't supported&quot; do
         @mock_request.stubs(:request_method).returns('POST')
         @mock_request.stubs(:path).returns('/foo')
         @mock_response.expects(:status=).with(404)
         @handler.process(@mock_request, @mock_response)            
     end
-    
+
     it &quot;should fail if delete request's pluralization is wrong&quot; do
         @mock_request.stubs(:request_method).returns('DELETE')
         @mock_request.stubs(:path).returns('/foos/key')
@@ -125,6 +131,42 @@ describe Puppet::Network::HTTP::WEBrickREST, &quot;when receiving a request&quot; do
         @handler.process(@mock_request, @mock_response)            
     end
 
+    describe &quot;and determining the request parameters&quot; do
+        it &quot;should include the HTTP request parameters&quot; do
+            @mock_request.stubs(:query).returns(:foo =&gt; :baz, :bar =&gt; :xyzzy)
+            result = @handler.params(@mock_request)
+            result[:foo].should == :baz
+            result[:bar].should == :xyzzy
+        end
+
+        it &quot;should pass the client's ip address to model find&quot; do
+            @mock_request.stubs(:peeraddr).returns(%w{noidea dunno hostname ipaddress})
+            @handler.params(@mock_request)[:ip].should == &quot;ipaddress&quot;
+        end
+
+        it &quot;should set 'authenticated' to true if a certificate is present&quot; do
+            cert = stub 'cert', :subject =&gt; [%w{CN host.domain.com}]
+            @mock_request.stubs(:client_cert).returns cert
+            @handler.params(@mock_request)[:authenticated].should be_true
+        end
+
+        it &quot;should set 'authenticated' to false if no certificate is present&quot; do
+            @mock_request.stubs(:client_cert).returns nil
+            @handler.params(@mock_request)[:authenticated].should be_false
+        end
+
+        it &quot;should pass the client's certificate name to model method if a certificate is present&quot; do
+            cert = stub 'cert', :subject =&gt; [%w{CN host.domain.com}]
+            @mock_request.stubs(:client_cert).returns cert
+            @handler.params(@mock_request)[:node].should == &quot;host.domain.com&quot;
+        end
+
+        it &quot;should not pass a node name to model method if no certificate is present&quot; do
+            @mock_request.stubs(:client_cert).returns nil
+            @handler.params(@mock_request).should_not be_include(:node)
+        end
+    end
+
     describe &quot;when finding a model instance&quot; do |variable|
         it &quot;should fail to find model if key is not specified&quot; do
             @mock_request.stubs(:request_method).returns('GET')
@@ -132,22 +174,22 @@ describe Puppet::Network::HTTP::WEBrickREST, &quot;when receiving a request&quot; do
             @mock_response.expects(:status=).with(404)
             @handler.process(@mock_request, @mock_response)            
         end
-        
-        it &quot;should pass HTTP request parameters to model find&quot; do
+
+        it &quot;should use a common method for determining the request parameters&quot; do
             setup_find_request
-            @mock_request.stubs(:query).returns(:foo =&gt; :baz, :bar =&gt; :xyzzy)
+            @handler.stubs(:params).returns(:foo =&gt; :baz, :bar =&gt; :xyzzy)
             @mock_model_class.expects(:find).with do |key, args|
-                key == 'key' and args[:foo] == :baz and args[:bar] == :xyzzy
+                args[:foo] == :baz and args[:bar] == :xyzzy
             end
-            @handler.service(@mock_request, @mock_response)
+            @handler.process(@mock_request, @mock_response)
         end
-        
+
         it &quot;should generate a 200 response when a model find call succeeds&quot; do
             setup_find_request
             @mock_response.expects(:status=).with(200)
             @handler.process(@mock_request, @mock_response)      
         end
-        
+
         it &quot;should return a serialized object when a model find call succeeds&quot; do
             setup_find_request
             @mock_model_instance = stub('model instance')
@@ -155,7 +197,7 @@ describe Puppet::Network::HTTP::WEBrickREST, &quot;when receiving a request&quot; do
             @mock_model_class.stubs(:find).returns(@mock_model_instance)
             @handler.process(@mock_request, @mock_response)                  
         end
-        
+
         it &quot;should serialize a controller exception when an exception is thrown by find&quot; do
            setup_find_request
            @mock_model_class.expects(:find).raises(ArgumentError) 
@@ -163,7 +205,7 @@ describe Puppet::Network::HTTP::WEBrickREST, &quot;when receiving a request&quot; do
            @handler.process(@mock_request, @mock_response)        
         end
     end
-    
+
     describe &quot;when destroying a model instance&quot; do |variable|
         it &quot;should fail to destroy model if key is not specified&quot; do
             @mock_request.stubs(:request_method).returns('DELETE')
@@ -171,37 +213,37 @@ describe Puppet::Network::HTTP::WEBrickREST, &quot;when receiving a request&quot; do
             @mock_response.expects(:status=).with(404)
             @handler.process(@mock_request, @mock_response)            
         end
-        
-        it &quot;should pass HTTP request parameters to model destroy&quot; do
+
+        it &quot;should use a common method for determining the request parameters&quot; do
             setup_destroy_request
-            @mock_request.stubs(:query).returns(:foo =&gt; :baz, :bar =&gt; :xyzzy)
+            @handler.stubs(:params).returns(:foo =&gt; :baz, :bar =&gt; :xyzzy)
             @mock_model_class.expects(:destroy).with do |key, args|
-                key == 'key' and args[:foo] == :baz and args[:bar] == :xyzzy
+                args[:foo] == :baz and args[:bar] == :xyzzy
             end
-            @handler.service(@mock_request, @mock_response)
+            @handler.process(@mock_request, @mock_response)
         end
-        
+
         it &quot;should generate a 200 response when a model destroy call succeeds&quot; do
             setup_destroy_request
             @mock_response.expects(:status=).with(200)
             @handler.process(@mock_request, @mock_response)      
         end
-        
+
         it &quot;should return a serialized success result when a model destroy call succeeds&quot; do
             setup_destroy_request
             @mock_model_class.stubs(:destroy).returns(true)
             @mock_response.expects(:body=).with(&quot;--- true\n&quot;)
             @handler.process(@mock_request, @mock_response)
         end
-        
-        it &quot;should serialize a controller exception when an exception is thrown by search&quot; do
-            setup_search_request
-            @mock_model_class.expects(:search).raises(ArgumentError) 
+
+        it &quot;should serialize a controller exception when an exception is thrown by destroy&quot; do
+            setup_destroy_request
+            @mock_model_class.expects(:destroy).raises(ArgumentError) 
             @mock_response.expects(:status=).with(404)
-            @handler.process(@mock_request, @mock_response)                
-        end
+            @handler.process(@mock_request, @mock_response)                 
+        end       
     end
-    
+
     describe &quot;when saving a model instance&quot; do
         it &quot;should fail to save model if data is not specified&quot; do
             @mock_request.stubs(:request_method).returns('PUT')
@@ -210,20 +252,29 @@ describe Puppet::Network::HTTP::WEBrickREST, &quot;when receiving a request&quot; do
             @mock_response.expects(:status=).with(404)
             @handler.process(@mock_request, @mock_response)            
         end
-        
+
+        it &quot;should use a common method for determining the request parameters&quot; do
+            setup_save_request
+            @handler.stubs(:params).returns(:foo =&gt; :baz, :bar =&gt; :xyzzy)
+            @mock_model_instance.expects(:save).with do |args|
+                args[:foo] == :baz and args[:bar] == :xyzzy
+            end
+            @handler.process(@mock_request, @mock_response)
+        end
+
         it &quot;should generate a 200 response when a model save call succeeds&quot; do
             setup_save_request
             @mock_response.expects(:status=).with(200)
             @handler.process(@mock_request, @mock_response)            
         end
-        
+
         it &quot;should return a serialized object when a model save call succeeds&quot; do
             setup_save_request
             @mock_model_instance.stubs(:save).returns(@mock_model_instance)
             @mock_model_instance.expects(:to_yaml).returns('foo')
             @handler.process(@mock_request, @mock_response)        
         end
-        
+
         it &quot;should serialize a controller exception when an exception is thrown by save&quot; do
             setup_save_request
             @mock_model_instance.expects(:save).raises(ArgumentError) 
@@ -231,15 +282,15 @@ describe Puppet::Network::HTTP::WEBrickREST, &quot;when receiving a request&quot; do
             @handler.process(@mock_request, @mock_response)                         
         end
     end
-    
+
     describe &quot;when searching for model instances&quot; do
-        it &quot;should pass HTTP request parameters to model search&quot; do
+        it &quot;should use a common method for determining the request parameters&quot; do
             setup_search_request
-            @mock_request.stubs(:query).returns(:foo =&gt; :baz, :bar =&gt; :xyzzy)
+            @handler.stubs(:params).returns(:foo =&gt; :baz, :bar =&gt; :xyzzy)
             @mock_model_class.expects(:search).with do |args|
                 args[:foo] == :baz and args[:bar] == :xyzzy
-            end.returns([])
-            @handler.service(@mock_request, @mock_response)
+            end
+            @handler.process(@mock_request, @mock_response)
         end
 
         it &quot;should generate a 200 response when a model search call succeeds&quot; do
@@ -247,20 +298,20 @@ describe Puppet::Network::HTTP::WEBrickREST, &quot;when receiving a request&quot; do
             @mock_response.expects(:status=).with(200)
             @handler.process(@mock_request, @mock_response)      
         end
-        
+
         it &quot;should return a list of serialized objects when a model search call succeeds&quot; do
             setup_search_request
             mock_matches = [1..5].collect {|i| mock(&quot;model instance #{i}&quot;, :to_yaml =&gt; &quot;model instance #{i}&quot;) }
             @mock_model_class.stubs(:search).returns(mock_matches)
             @handler.process(@mock_request, @mock_response)                          
         end
-        
-        it &quot;should serialize a controller exception when an exception is thrown by destroy&quot; do
-            setup_destroy_request
-            @mock_model_class.expects(:destroy).raises(ArgumentError) 
+
+        it &quot;should serialize a controller exception when an exception is thrown by search&quot; do
+            setup_search_request
+            @mock_model_class.expects(:search).raises(ArgumentError) 
             @mock_response.expects(:status=).with(404)
-            @handler.process(@mock_request, @mock_response)                 
-        end       
+            @handler.process(@mock_request, @mock_response)                
+        end
     end
 
     it &quot;should serialize a controller exception if the request fails&quot; do</diff>
      <filename>spec/unit/network/http/webrick/rest.rb</filename>
    </modified>
    <modified>
      <filename>spec/unit/network/http/webrick/xmlrpc.rb</filename>
    </modified>
    <modified>
      <diff>@@ -64,10 +64,8 @@ describe Puppet::Network::HttpPool do
             Puppet.settings[:http_enable_post_connection_check].should be_true
         end
 
-        # JJM: I'm not sure if this is correct, as this really follows the
-        # configuration option.
         it &quot;should set enable_post_connection_check true &quot; do
-            Puppet::Network::HttpPool.http_instance(&quot;me&quot;, 54321).instance_variable_get(&quot;@enable_post_connection_check&quot;).should be_true
+            Puppet::Network::HttpPool.http_instance(&quot;me&quot;, 54321).instance_variable_get(&quot;@enable_post_connection_check&quot;).should be(Puppet.settings[:http_enable_post_connection_check])
         end
 
         it &quot;should create the http instance with the proxy host and port set if the http_proxy is not set to 'none'&quot; do</diff>
      <filename>spec/unit/network/http_pool.rb</filename>
    </modified>
    <modified>
      <filename>spec/unit/network/server.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@
 
 require File.dirname(__FILE__) + '/../spec_helper'
 
-describe Puppet::Node, &quot; when initializing&quot; do
+describe Puppet::Node, &quot;when initializing&quot; do
     before do
         @node = Puppet::Node.new(&quot;testnode&quot;)
     end
@@ -54,14 +54,9 @@ describe Puppet::Node, &quot; when initializing&quot; do
         Puppet.settings.stubs(:value).with(:environments).returns(&quot;myenv&quot;)
         proc { Puppet::Node.new(&quot;testing&quot;, :environment =&gt; &quot;other&quot;) }.should raise_error(ArgumentError)
     end
-
-    it &quot;should accept names passed in&quot; do
-        @node = Puppet::Node.new(&quot;testing&quot;, :names =&gt; [&quot;myenv&quot;])
-        @node.names.should == [&quot;myenv&quot;]
-    end
 end
 
-describe Puppet::Node, &quot; when returning the environment&quot; do
+describe Puppet::Node, &quot;when returning the environment&quot; do
     before do
         Puppet.settings.stubs(:value).with(:environments).returns(&quot;one,two&quot;)
         Puppet.settings.stubs(:value).with(:environment).returns(&quot;one&quot;)
@@ -90,7 +85,7 @@ describe Puppet::Node, &quot; when returning the environment&quot; do
     end
 end
 
-describe Puppet::Node, &quot; when merging facts&quot; do
+describe Puppet::Node, &quot;when merging facts&quot; do
     before do
         @node = Puppet::Node.new(&quot;testnode&quot;)
         Puppet::Node::Facts.stubs(:find).with(@node.name).returns(Puppet::Node::Facts.new(@node.name, &quot;one&quot; =&gt; &quot;c&quot;, &quot;two&quot; =&gt; &quot;b&quot;))
@@ -131,7 +126,7 @@ describe Puppet::Node, &quot; when merging facts&quot; do
     end
 end
 
-describe Puppet::Node, &quot; when indirecting&quot; do
+describe Puppet::Node, &quot;when indirecting&quot; do
     it &quot;should redirect to the indirection&quot; do
         @indirection = stub 'indirection', :name =&gt; :node
         Puppet::Node.stubs(:indirection).returns(@indirection)
@@ -152,75 +147,52 @@ describe Puppet::Node, &quot; when indirecting&quot; do
     end
 end
 
-describe Puppet::Node do
-    # LAK:NOTE This is used to keep track of when a given node has connected,
-    # so we can report on nodes that do not appear to connecting to the
-    # central server.
-    it &quot;should provide a method for noting that the node has connected&quot;
-end
-
-describe Puppet::Node, &quot; when searching for nodes&quot; do
+describe Puppet::Node, &quot;when generating the list of names to search through&quot; do
     before do
-        @searcher = Puppet::Node
-        @facts = Puppet::Node::Facts.new(&quot;foo&quot;, &quot;hostname&quot; =&gt; &quot;yay&quot;, &quot;domain&quot; =&gt; &quot;domain.com&quot;)
-        @node = Puppet::Node.new(&quot;foo&quot;)
-        Puppet::Node::Facts.stubs(:find).with(&quot;foo&quot;).returns(@facts)
+        @node = Puppet::Node.new(&quot;foo.domain.com&quot;)
+        @node.parameters = {&quot;hostname&quot; =&gt; &quot;yay&quot;, &quot;domain&quot; =&gt; &quot;domain.com&quot;}
     end
 
-    it &quot;should return the first node found using the generated list of names&quot; do
-        @searcher.expects(:find).with(&quot;foo&quot;).returns(nil)
-        @searcher.expects(:find).with(&quot;yay.domain.com&quot;).returns(@node)
-        @searcher.find_by_any_name(&quot;foo&quot;).should equal(@node)
+    it &quot;should return an array of names&quot; do
+        @node.names.should be_instance_of(Array)
     end
 
-    it &quot;should search for the node by its key first&quot; do
-        names = []
-        @searcher.expects(:find).with do |name|
-            names &lt;&lt; name
-            names == %w{foo}
-        end.returns(@node)
-        @searcher.find_by_any_name(&quot;foo&quot;).should equal(@node)
+    it &quot;should have the node's fqdn as the second name&quot; do
+        @node.names[1].should == &quot;yay.domain.com&quot;
     end
 
-    it &quot;should search for the rest of the names inversely by length&quot; do
-        names = []
-        @facts.values[&quot;fqdn&quot;] = &quot;longer.than.the.normal.fqdn.com&quot;
-        @searcher.stubs(:find).with do |name|
-            names &lt;&lt; name
-        end
-        @searcher.find_by_any_name(&quot;foo&quot;)
-        # Strip off the key
-        names.shift
-
-        # And the 'default'
-        names.pop
+    it &quot;should set the fqdn to the node's 'fqdn' fact if it is available&quot; do
+        @node.parameters[&quot;fqdn&quot;] = &quot;boo.domain.com&quot;
+        @node.names[1].should == &quot;boo.domain.com&quot;
+    end
 
-        length = 100
-        names.each do |name|
-            (name.length &lt; length).should be_true
-            length = name.length
-        end
+    it &quot;should set the fqdn to the node's hostname and domain if no fqdn is available&quot; do
+        @node.names[1].should == &quot;yay.domain.com&quot;
     end
 
-    it &quot;should attempt to find a default node if no names are found&quot; do
-        names = []
-        @searcher.stubs(:find).with do |name|
-            names &lt;&lt; name
-        end.returns(nil)
-        @searcher.find_by_any_name(&quot;foo&quot;)
-        names[-1].should == &quot;default&quot;
+    it &quot;should contain an entry for each name available by stripping a segment of the fqdn&quot; do
+        @node.parameters[&quot;fqdn&quot;] = &quot;foo.deep.sub.domain.com&quot;
+        @node.names[2].should == &quot;foo.deep.sub.domain&quot;
+        @node.names[3].should == &quot;foo.deep.sub&quot;
     end
 
-    it &quot;should flush the node cache using the :filetimeout parameter&quot; do
-        node2 = Puppet::Node.new(&quot;foo2&quot;)
-        Puppet[:filetimeout] = -1
-        # I couldn't get this to work with :expects
-        @searcher.stubs(:find).returns(@node, node2).then.raises(ArgumentError)
-        @searcher.find_by_any_name(&quot;foo&quot;).should equal(@node)
-        @searcher.find_by_any_name(&quot;foo&quot;).should equal(node2)
+    describe &quot;and :node_name is set to 'cert'&quot; do
+        before do
+            Puppet.settings.stubs(:value).with(:node_name).returns &quot;cert&quot;
+        end
+
+        it &quot;should use the passed-in key as the first value&quot; do
+            @node.names[0].should == &quot;foo.domain.com&quot;
+        end
     end
 
-    after do
-        Puppet.settings.clear
+    describe &quot;and :node_name is set to 'facter'&quot; do
+        before do
+            Puppet.settings.stubs(:value).with(:node_name).returns &quot;facter&quot;
+        end
+
+        it &quot;should use the node's 'hostname' fact as the first value&quot; do
+            @node.names[0].should == &quot;yay&quot;
+        end
     end
 end</diff>
      <filename>spec/unit/node.rb</filename>
    </modified>
    <modified>
      <diff>@@ -292,6 +292,26 @@ describe Puppet::Node::Catalog, &quot; when converting to a RAL catalog&quot; do
         @catalog.vertices.each { |v| v.catalog.object_id.should equal(@catalog.object_id) }
     end
 
+    it &quot;should convert parser resources to transobjects and set the catalog&quot; do
+        catalog = Puppet::Node::Catalog.new(&quot;mynode&quot;)
+
+        result = mock 'catalog'
+        result.stub_everything
+
+        Puppet::Node::Catalog.expects(:new).returns result
+
+        trans = mock 'trans'
+        resource = Puppet::Parser::Resource.new(:scope =&gt; mock(&quot;scope&quot;), :source =&gt; mock(&quot;source&quot;), :type =&gt; :file, :title =&gt; &quot;/eh&quot;)
+        resource.expects(:to_transobject).returns trans
+        trans.expects(:catalog=).with result
+
+        trans.stub_everything
+
+        catalog.add_resource(resource)
+
+        catalog.to_ral
+    end
+
     # This tests #931.
     it &quot;should not lose track of resources whose names vary&quot; do
         changer = Puppet::TransObject.new 'changer', 'test'</diff>
      <filename>spec/unit/node/catalog.rb</filename>
    </modified>
    <modified>
      <diff>@@ -204,6 +204,8 @@ describe Puppet::Parser::Collector, &quot;when collecting exported resources&quot; do
         @equery = &quot;test = true&quot;
         @vquery = proc { |r| true }
 
+        Puppet.settings.stubs(:value).with(:storeconfigs).returns true
+
         @collector = Puppet::Parser::Collector.new(@scope, @resource_type, @equery, @vquery, :exported)
     end
 
@@ -217,6 +219,11 @@ describe Puppet::Parser::Collector, &quot;when collecting exported resources&quot; do
         end
     end
 
+    it &quot;should just return false if :storeconfigs is not enabled&quot; do
+        Puppet.settings.expects(:value).with(:storeconfigs).returns false
+        @collector.evaluate.should be_false
+    end
+
     it &quot;should use initialize the Rails support if ActiveRecord is not connected&quot; do
         @compiler.stubs(:resources).returns([])
         ActiveRecord::Base.expects(:connected?).returns(false)
@@ -375,6 +382,8 @@ describe Puppet::Parser::Collector, &quot;when building its ActiveRecord query for co
         Puppet::Rails.stubs(:init)
         Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
         Puppet::Rails::Resource.stubs(:find).returns([])
+
+        Puppet.settings.stubs(:value).with(:storeconfigs).returns true
     end
 
     it &quot;should exclude all resources from the host if ActiveRecord contains information for this host&quot; do</diff>
      <filename>spec/unit/parser/collector.rb</filename>
    </modified>
    <modified>
      <diff>@@ -84,7 +84,6 @@ describe Puppet::Parser::Interpreter do
                 oldparser = mock('oldparser')
                 newparser = mock('newparser')
                 oldparser.expects(:reparse?).returns(true)
-                oldparser.expects(:clear)
 
                 @interp.expects(:create_parser).with(:myenv).returns(oldparser)
                 @interp.send(:parser, :myenv).should equal(oldparser)
@@ -92,36 +91,16 @@ describe Puppet::Parser::Interpreter do
                 @interp.send(:parser, :myenv).should equal(newparser)
             end
 
-            it &quot;should keep the old parser if a new parser cannot be created&quot; do
+            it &quot;should raise an exception if a new parser cannot be created&quot; do
                 # Get the first parser in the hash.
                 @interp.expects(:create_parser).with(:myenv).returns(@parser)
                 @interp.send(:parser, :myenv).should equal(@parser)
 
-                # Have it indicate something has changed
                 @parser.expects(:reparse?).returns(true)
 
-                # But fail to create a new parser
-                @interp.expects(:create_parser).with(:myenv).raises(ArgumentError)
+                @interp.expects(:create_parser).with(:myenv).raises(Puppet::Error, &quot;Could not parse&quot;)
 
-                # And make sure we still get the old valid parser
-                @interp.send(:parser, :myenv).should equal(@parser)
-            end
-
-            it &quot;should log syntax errors when using the old parser&quot; do
-                # Get the first parser in the hash.
-                @interp.stubs(:create_parser).with(:myenv).returns(@parser)
-                @interp.send(:parser, :myenv)
-
-                # Have it indicate something has changed
-                @parser.stubs(:reparse?).returns(true)
-
-                # But fail to create a new parser
-                @interp.stubs(:create_parser).with(:myenv).raises(ArgumentError)
-
-                Puppet.expects(:err)
-
-                # And make sure we still get the old valid parser
-                @interp.send(:parser, :myenv)
+                lambda { @interp.parser(:myenv) }.should raise_error(Puppet::Error) 
             end
         end
     end</diff>
      <filename>spec/unit/parser/interpreter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -29,8 +29,8 @@ describe Puppet::Provider::Confine do
         Puppet::Provider::Confine.test(:exists).should be_instance_of(Class)
     end
 
-    it &quot;should have a 'facter' test&quot; do
-        Puppet::Provider::Confine.test(:facter).should be_instance_of(Class)
+    it &quot;should have a 'variable' test&quot; do
+        Puppet::Provider::Confine.test(:variable).should be_instance_of(Class)
     end
 
     describe &quot;when testing all values&quot; do</diff>
      <filename>spec/unit/provider/confine.rb</filename>
    </modified>
    <modified>
      <diff>@@ -20,16 +20,16 @@ describe Puppet::Provider::ConfineCollection do
 
         describe &quot;and the test cannot be found&quot; do
             before do
-                @facter = mock 'facter_test'
+                @variable = mock 'variable_test'
 
                 Puppet::Provider::Confine.expects(:test).with(:foo).returns nil
-                Puppet::Provider::Confine.expects(:test).with(:facter).returns @facter
+                Puppet::Provider::Confine.expects(:test).with(:variable).returns @variable
             end
 
-            it &quot;should create a Facter test with the provided values and set the fact to the test name&quot; do
+            it &quot;should create a Facter test with the provided values and set the name to the test name&quot; do
                 confine = mock 'confine'
-                confine.expects(:fact=).with(:foo)
-                @facter.expects(:new).with(%w{my values}).returns confine
+                confine.expects(:name=).with(:foo)
+                @variable.expects(:new).with(%w{my values}).returns confine
                 Puppet::Provider::ConfineCollection.new.confine :foo =&gt; %w{my values}
             end
         end</diff>
      <filename>spec/unit/provider/confine_collection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -45,8 +45,8 @@ describe provider_class do
 
         describe &quot;with no gid specified&quot; do
             it &quot;should pick the first available GID after the largest existing GID&quot; do
-                low = {:name=&gt;[&quot;luke&quot;], :gid=&gt;[&quot;100&quot;]}
-                high = {:name=&gt;[&quot;testing&quot;], :gid=&gt;[&quot;140&quot;]}
+                low = {:name=&gt;[&quot;luke&quot;], :gid=&gt;[&quot;600&quot;]}
+                high = {:name=&gt;[&quot;testing&quot;], :gid=&gt;[&quot;640&quot;]}
                 provider_class.manager.expects(:search).returns([low, high])
 
                 resource = stub 'resource', :should =&gt; %w{whatever}
@@ -55,12 +55,26 @@ describe provider_class do
                 instance = provider_class.new(:name =&gt; &quot;luke&quot;, :ensure =&gt; :absent)
                 instance.stubs(:resource).returns resource
 
-                @connection.expects(:add).with { |dn, attrs| attrs[&quot;gidNumber&quot;] == [&quot;141&quot;] }
+                @connection.expects(:add).with { |dn, attrs| attrs[&quot;gidNumber&quot;] == [&quot;641&quot;] }
+
+                instance.create
+                instance.flush
+            end
+
+            it &quot;should pick '501' as its GID if no groups are found&quot; do
+                provider_class.manager.expects(:search).returns nil
+
+                resource = stub 'resource', :should =&gt; %w{whatever}
+                resource.stubs(:should).with(:gid).returns nil
+                resource.stubs(:should).with(:ensure).returns :present
+                instance = provider_class.new(:name =&gt; &quot;luke&quot;, :ensure =&gt; :absent)
+                instance.stubs(:resource).returns resource
+
+                @connection.expects(:add).with { |dn, attrs| attrs[&quot;gidNumber&quot;] == [&quot;501&quot;] }
 
                 instance.create
                 instance.flush
             end
         end
     end
-
 end</diff>
      <filename>spec/unit/provider/group/ldap.rb</filename>
    </modified>
    <modified>
      <diff>@@ -59,8 +59,8 @@ describe provider_class do
 
         describe &quot;with no uid specified&quot; do
             it &quot;should pick the first available UID after the largest existing UID&quot; do
-                low = {:name=&gt;[&quot;luke&quot;], :shell=&gt;:absent, :uid=&gt;[&quot;100&quot;], :home=&gt;[&quot;/h&quot;], :gid=&gt;[&quot;1000&quot;], :password=&gt;[&quot;blah&quot;], :comment=&gt;[&quot;l k&quot;]}
-                high = {:name=&gt;[&quot;testing&quot;], :shell=&gt;:absent, :uid=&gt;[&quot;140&quot;], :home=&gt;[&quot;/h&quot;], :gid=&gt;[&quot;1000&quot;], :password=&gt;[&quot;blah&quot;], :comment=&gt;[&quot;t u&quot;]}
+                low = {:name=&gt;[&quot;luke&quot;], :shell=&gt;:absent, :uid=&gt;[&quot;600&quot;], :home=&gt;[&quot;/h&quot;], :gid=&gt;[&quot;1000&quot;], :password=&gt;[&quot;blah&quot;], :comment=&gt;[&quot;l k&quot;]}
+                high = {:name=&gt;[&quot;testing&quot;], :shell=&gt;:absent, :uid=&gt;[&quot;640&quot;], :home=&gt;[&quot;/h&quot;], :gid=&gt;[&quot;1000&quot;], :password=&gt;[&quot;blah&quot;], :comment=&gt;[&quot;t u&quot;]}
                 provider_class.manager.expects(:search).returns([low, high])
 
                 resource = stub 'resource', :should =&gt; %w{whatever}
@@ -69,7 +69,22 @@ describe provider_class do
                 instance = provider_class.new(:name =&gt; &quot;luke&quot;, :ensure =&gt; :absent)
                 instance.stubs(:resource).returns resource
 
-                @connection.expects(:add).with { |dn, attrs| attrs[&quot;uidNumber&quot;] == [&quot;141&quot;] }
+                @connection.expects(:add).with { |dn, attrs| attrs[&quot;uidNumber&quot;] == [&quot;641&quot;] }
+
+                instance.create
+                instance.flush
+            end
+
+            it &quot;should pick 501 of no users exist&quot; do
+                provider_class.manager.expects(:search).returns nil
+
+                resource = stub 'resource', :should =&gt; %w{whatever}
+                resource.stubs(:should).with(:uid).returns nil
+                resource.stubs(:should).with(:ensure).returns :present
+                instance = provider_class.new(:name =&gt; &quot;luke&quot;, :ensure =&gt; :absent)
+                instance.stubs(:resource).returns resource
+
+                @connection.expects(:add).with { |dn, attrs| attrs[&quot;uidNumber&quot;] == [&quot;501&quot;] }
 
                 instance.create
                 instance.flush</diff>
      <filename>spec/unit/provider/user/ldap.rb</filename>
    </modified>
    <modified>
      <diff>@@ -34,6 +34,10 @@ describe Puppet::SSL::Certificate do
             @certificate.name.should == &quot;myname&quot;
         end
 
+        it &quot;should downcase its name&quot; do
+            @class.new(&quot;MyName&quot;).name.should == &quot;myname&quot;
+        end
+
         it &quot;should have a content attribute&quot; do
             @certificate.should respond_to(:content)
         end</diff>
      <filename>spec/unit/ssl/certificate.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,11 +6,19 @@ require 'puppet/ssl/certificate_authority'
 
 describe Puppet::SSL::CertificateAuthority do
     after do
-        # Clear out the var, yay unit tests.
-        Puppet::SSL::CertificateAuthority.instance_variable_set(&quot;@instance&quot;, nil)
+        Puppet::Util::Cacher.invalidate
         Puppet.settings.clearused
     end
 
+    def stub_ca_host
+        @key = mock 'key'
+        @key.stubs(:content).returns &quot;cakey&quot;
+        @cacert = mock 'certificate'
+        @cacert.stubs(:content).returns &quot;cacertificate&quot;
+
+        @host = stub 'ssl_host', :key =&gt; @key, :certificate =&gt; @cacert, :name =&gt; Puppet::SSL::Host.ca_name
+    end
+
     it &quot;should have a class method for returning a singleton instance&quot; do
         Puppet::SSL::CertificateAuthority.should respond_to(:instance)
     end
@@ -25,11 +33,6 @@ describe Puppet::SSL::CertificateAuthority do
                 Puppet::SSL::CertificateAuthority.stubs(:new).returns @ca
             end
 
-            after do
-                # Clear out the var, yay unit tests.
-                Puppet::SSL::CertificateAuthority.instance_variable_set(&quot;@instance&quot;, nil)
-            end
-
             it &quot;should return an instance&quot; do
                 Puppet::SSL::CertificateAuthority.instance.should equal(@ca)
             end
@@ -224,20 +227,16 @@ describe Puppet::SSL::CertificateAuthority do
 
             Puppet::SSL::CertificateAuthority.any_instance.stubs(:password?).returns true
 
-            # Set up the CA
-            @key = mock 'key'
-            @key.stubs(:content).returns &quot;cakey&quot;
-            Puppet::SSL::CertificateAuthority.any_instance.stubs(:key).returns @key
-            @cacert = mock 'certificate'
-            @cacert.stubs(:content).returns &quot;cacertificate&quot;
+            stub_ca_host
+
+            Puppet::SSL::Host.expects(:new).with(Puppet::SSL::Host.ca_name).returns @host
+
             @ca = Puppet::SSL::CertificateAuthority.new
 
-            @ca.host.stubs(:certificate).returns @cacert
-            @ca.host.stubs(:key).returns @key
-            
             @name = &quot;myhost&quot;
             @real_cert = stub 'realcert', :sign =&gt; nil
             @cert = stub 'certificate', :content =&gt; @real_cert
+
             Puppet::SSL::Certificate.stubs(:new).returns @cert
 
             @cert.stubs(:content=)
@@ -514,10 +513,9 @@ describe Puppet::SSL::CertificateAuthority do
 
             Puppet::SSL::CertificateAuthority.any_instance.stubs(:password?).returns true
 
-            # Set up the CA
-            @key = mock 'key'
-            @key.stubs(:content).returns &quot;cakey&quot;
-            @host = stub 'host', :key =&gt; @key
+            stub_ca_host
+
+            Puppet::SSL::Host.expects(:new).returns @host
             Puppet::SSL::CertificateAuthority.any_instance.stubs(:host).returns @host
 
             @cacert = mock 'certificate'</diff>
      <filename>spec/unit/ssl/certificate_authority.rb</filename>
    </modified>
    <modified>
      <diff>@@ -35,6 +35,10 @@ describe Puppet::SSL::CertificateRequest do
             @request.name.should == &quot;myname&quot;
         end
 
+        it &quot;should downcase its name&quot; do
+            @class.new(&quot;MyName&quot;).name.should == &quot;myname&quot;
+        end
+
         it &quot;should have a content attribute&quot; do
             @request.should respond_to(:content)
         end</diff>
      <filename>spec/unit/ssl/certificate_request.rb</filename>
    </modified>
    <modified>
      <diff>@@ -162,6 +162,15 @@ describe Puppet::SSL::Host do
             Puppet::SSL::Host.new.name.should == &quot;myname&quot;
         end
 
+        it &quot;should downcase a passed in name&quot; do
+            Puppet::SSL::Host.new(&quot;Host.Domain.Com&quot;).name.should == &quot;host.domain.com&quot;
+        end
+
+        it &quot;should downcase the certname if it's used&quot; do
+            Puppet.settings.expects(:value).with(:certname).returns &quot;Host.Domain.Com&quot;
+            Puppet::SSL::Host.new().name.should == &quot;host.domain.com&quot;
+        end
+
         it &quot;should indicate that it is a CA host if its name matches the ca_name constant&quot; do
             Puppet::SSL::Host.stubs(:ca_name).returns &quot;myca&quot;
             Puppet::SSL::Host.new(&quot;myca&quot;).should be_ca</diff>
      <filename>spec/unit/ssl/host.rb</filename>
    </modified>
    <modified>
      <diff>@@ -38,6 +38,10 @@ describe Puppet::SSL::Key do
             key.password_file.should == &quot;/ca/pass&quot;
         end
 
+        it &quot;should downcase its name&quot; do
+            @class.new(&quot;MyName&quot;).name.should == &quot;myname&quot;
+        end
+
         it &quot;should set its password file to the default password file if it is not the CA key&quot; do
             Puppet.settings.stubs(:value).returns &quot;whatever&quot;
             Puppet.settings.stubs(:value).with(:passfile).returns &quot;/normal/pass&quot;</diff>
      <filename>spec/unit/ssl/key.rb</filename>
    </modified>
    <modified>
      <diff>@@ -75,6 +75,4 @@ describe ssh_authorized_key do
     it &quot;should have a target property&quot; do
         @class.attrtype(:target).should == :property
     end
-
-    after { @class.clear }
 end</diff>
      <filename>spec/unit/type/ssh_authorized_key.rb</filename>
    </modified>
    <modified>
      <diff>@@ -85,6 +85,10 @@ describe Puppet::Util::Storage do
     end
 
     describe &quot;when loading from the state file&quot; do
+        before do
+            Puppet.settings.stubs(:use).returns(true)
+        end
+
         describe &quot;when the state file/directory does not exist&quot; do
             before(:each) do
                 transient = Tempfile.new('storage_test')
@@ -139,6 +143,7 @@ describe Puppet::Util::Storage do
             
             it &quot;should initialize with a clear internal state if the state file does not contain valid YAML&quot; do
                 @state_file.write(:booness)
+                @state_file.flush()
 
                 proc { Puppet::Util::Storage.load() }.should_not raise_error()
                 Puppet::Util::Storage.state().should == {}
@@ -146,7 +151,9 @@ describe Puppet::Util::Storage do
 
             it &quot;should raise an error if the state file does not contain valid YAML and cannot be renamed&quot; do
                 @state_file.write(:booness)
-                File.chmod(0000, @state_file.path())
+                @state_file.flush()
+                YAML.expects(:load).raises(Puppet::Error)
+                File.expects(:rename).raises(SystemCallError)
 
                 proc { Puppet::Util::Storage.load() }.should raise_error()
             end</diff>
      <filename>spec/unit/util/storage.rb</filename>
    </modified>
    <modified>
      <diff>@@ -302,7 +302,7 @@ module PuppetTest
         Puppet::Util::Storage.clear
         Puppet.clear
         Puppet.settings.clear
-        Puppet::Indirector::Indirection.clear_cache
+        Puppet::Util::Cacher.invalidate
 
         @memoryatend = Puppet::Util.memory
         diff = @memoryatend - @memoryatstart</diff>
      <filename>test/lib/puppettest.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,8 @@
 #!/usr/bin/env ruby
 
+require 'rake'
+require 'rake/testtask'
+
 module Rake
     class PuppetTestTask &lt; Rake::TestTask
         def rake_loader</diff>
      <filename>test/lib/rake/puppet_testtask.rb</filename>
    </modified>
    <modified>
      <diff>@@ -30,6 +30,7 @@ class TestClientCA &lt; Test::Unit::TestCase
 
     # Make sure the ca defaults to specific ports and names
     def test_ca_server
+        Puppet.settings.stubs(:value).returns &quot;eh&quot;
         Puppet.settings.expects(:value).with(:ca_server).returns(&quot;myca&quot;)
         Puppet.settings.expects(:value).with(:ca_port).returns(321)
         Puppet.settings.stubs(:value).with(:http_proxy_host).returns(nil)</diff>
      <filename>test/network/client/ca.rb</filename>
    </modified>
    <modified>
      <diff>@@ -454,17 +454,8 @@ end
 
         Puppet::Node::Facts.indirection.stubs(:save)
 
-        master = client = nil
-        assert_nothing_raised() {
-            master = Puppet::Network::Handler.master.new(
-                :Local =&gt; false
-            )
-        }
-        assert_nothing_raised() {
-            client = Puppet::Network::Client.master.new(
-                :Master =&gt; master
-            )
-        }
+        master = Puppet::Network::Handler.master.new( :Local =&gt; false)
+        client = Puppet::Network::Client.master.new( :Master =&gt; master)
 
         # Fake that it's local, so it creates the class file
         client.local = false
@@ -473,6 +464,7 @@ end
         client.expects(:setclasses).with do |array|
             array.length == 2 and array.include?(&quot;yaytest&quot;) and array.include?(&quot;bootest&quot;)
         end
+
         assert_nothing_raised {
             client.getconfig
         }</diff>
      <filename>test/network/client/master.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,69 +8,51 @@ require 'puppet/network/handler/master'
 class TestMaster &lt; Test::Unit::TestCase
     include PuppetTest::ServerTest
 
+    def setup
+        super
+        @master = Puppet::Network::Handler.master.new(:Manifest =&gt; tempfile)
+
+        @catalog = stub 'catalog', :extract =&gt; &quot;&quot;
+        Puppet::Node::Catalog.stubs(:find).returns(@catalog)
+    end
+
     def teardown
         super
-        Puppet::Indirector::Indirection.clear_cache
+        Puppet::Util::Cacher.invalidate
     end
 
     def test_freshness_is_always_now
-        master = Puppet::Network::Handler.master.new(
-            :Manifest =&gt; tempfile,
-            :UseNodes =&gt; true,
-            :Local =&gt; true
-        )
-
         now1 = mock 'now1'
         Time.expects(:now).returns(now1)
 
-        assert_equal(master.freshness, now1, &quot;Did not return current time as freshness&quot;)
+        assert_equal(@master.freshness, now1, &quot;Did not return current time as freshness&quot;)
     end
 
-    # Make sure we're correctly doing clientname manipulations.
-    # Testing to make sure we always get a hostname and IP address.
-    def test_clientname
-        # create our master
-        master = Puppet::Network::Handler.master.new(
-            :Manifest =&gt; tempfile,
-            :UseNodes =&gt; true,
-            :Local =&gt; true
-        )
-
-
-        # First check that 'cert' works
-        Puppet[:node_name] = &quot;cert&quot;
-
-        # Make sure we get the fact data back when nothing is set
-        facts = {
-            &quot;hostname&quot; =&gt; &quot;fact_hostname&quot;,
-            &quot;domain&quot; =&gt; &quot;fact_domain&quot;,
-            &quot;fqdn&quot; =&gt; &quot;fact_hostname.fact_domain&quot;,
-            &quot;ipaddress&quot; =&gt; &quot;fact_ip&quot;
-        }
-        certhostname = &quot;cert_hostname&quot;
-        certdomain = &quot;cert_domain&quot;
-        certname = certhostname + &quot;.&quot; + certdomain
-        certip = &quot;cert_ip&quot;
-
-        resname, resip = master.send(:clientname, nil, nil, facts)
-        assert_equal(facts[&quot;hostname&quot;], resname, &quot;Did not use fact hostname when no certname was present&quot;)
-        assert_equal(facts[&quot;ipaddress&quot;], resip, &quot;Did not use fact ip when no certname was present&quot;)
-        assert_equal(facts[&quot;domain&quot;], &quot;fact_domain&quot;, &quot;Did not use fact domain when no certname was present&quot;)
-        assert_equal(facts[&quot;fqdn&quot;], &quot;fact_hostname.fact_domain&quot;, &quot;Did not use fact fqdn when no certname was present&quot;)
-
-        # Now try it with the cert stuff present
-        resname, resip = master.send(:clientname, certname, certip, facts)
-        assert_equal(certname, resname, &quot;Did not use cert hostname when certname was present&quot;)
-        assert_equal(certip, resip, &quot;Did not use cert ip when certname was present&quot;)
-        assert_equal(facts[&quot;domain&quot;], certdomain, &quot;Did not use cert domain when certname was present&quot;)
-        assert_equal(facts[&quot;fqdn&quot;], certname, &quot;Did not use cert fqdn when certname was present&quot;)
-
-        # And reset the node_name stuff and make sure we use it.
-        Puppet[:node_name] = :facter
-        resname, resip = master.send(:clientname, certname, certip, facts)
-        assert_equal(facts[&quot;hostname&quot;], resname, &quot;Did not use fact hostname when nodename was set to facter&quot;)
-        assert_equal(facts[&quot;ipaddress&quot;], resip, &quot;Did not use fact ip when nodename was set to facter&quot;)
+    def test_hostname_is_used_if_client_is_missing
+        @master.expects(:decode_facts).returns(&quot;hostname&quot; =&gt; &quot;yay&quot;)
+        Puppet::Node::Facts.expects(:new).with { |name, facts| name == &quot;yay&quot; }.returns(stub('facts', :save =&gt; nil))
+
+        @master.getconfig(&quot;facts&quot;)
     end
-end
 
+    def test_facts_are_saved
+        facts = mock('facts')
+        Puppet::Node::Facts.expects(:new).returns(facts)
+        facts.expects(:save)
+
+        @master.stubs(:decode_facts)
 
+        @master.getconfig(&quot;facts&quot;, &quot;yaml&quot;, &quot;foo.com&quot;)
+    end
+
+    def test_catalog_is_used_for_compiling
+        facts = stub('facts', :save =&gt; nil)
+        Puppet::Node::Facts.stubs(:new).returns(facts)
+
+        @master.stubs(:decode_facts)
+
+        Puppet::Node::Catalog.expects(:find).with(&quot;foo.com&quot;).returns(@catalog)
+
+        @master.getconfig(&quot;facts&quot;, &quot;yaml&quot;, &quot;foo.com&quot;)
+    end
+end</diff>
      <filename>test/network/handler/master.rb</filename>
    </modified>
    <modified>
      <diff>@@ -72,11 +72,11 @@ class TestTransactions &lt; Test::Unit::TestCase
         path1 = tempfile()
         path2 = tempfile()
         objects = []
-        objects &lt;&lt; Puppet::Type.newfile(
+        objects &lt;&lt; Puppet::Type.type(:file).create(
             :path =&gt; path1,
             :content =&gt; &quot;yayness&quot;
         )
-        objects &lt;&lt; Puppet::Type.newfile(
+        objects &lt;&lt; Puppet::Type.type(:file).create(
             :path =&gt; path2,
             :content =&gt; &quot;booness&quot;
         )
@@ -155,7 +155,7 @@ class TestTransactions &lt; Test::Unit::TestCase
         path = tempfile()
         firstpath = tempfile()
         secondpath = tempfile()
-        file = Puppet::Type.newfile(:title =&gt; &quot;file&quot;, :path =&gt; path, :content =&gt; &quot;yayness&quot;)
+        file = Puppet::Type.type(:file).create(:title =&gt; &quot;file&quot;, :path =&gt; path, :content =&gt; &quot;yayness&quot;)
         first = Puppet::Type.newexec(:title =&gt; &quot;first&quot;,
                                      :command =&gt; &quot;/bin/echo first &gt; #{firstpath}&quot;,
                                      :subscribe =&gt; [:file, path],
@@ -712,6 +712,45 @@ class TestTransactions &lt; Test::Unit::TestCase
             &quot;Not all resources were evaluated or not in the right order&quot;)
     end
 
+    # We need to generate resources before we prefetch them, else generated
+    # resources that require prefetching don't work.
+    def test_generate_before_prefetch
+        config = mk_catalog()
+        trans = Puppet::Transaction.new(config)
+
+        generate = nil
+        prefetch = nil
+        trans.expects(:generate).with { |*args| generate = Time.now; true }
+        trans.expects(:prefetch).with { |*args| ! generate.nil? }
+        trans.prepare
+        return
+
+        resource = Puppet::Type.type(:file).create :ensure =&gt; :present, :path =&gt; tempfile()
+        other_resource = mock 'generated'
+        def resource.generate
+            [other_resource]
+        end
+
+
+        config = mk_catalog(yay, rah)
+        trans = Puppet::Transaction.new(config)
+        
+        assert_nothing_raised do
+            trans.generate
+        end
+        
+        %w{ya ra y r}.each do |name|
+            assert(trans.catalog.vertex?(Puppet::Type.type(:generator)[name]),
+                &quot;Generated %s was not a vertex&quot; % name)
+            assert($finished.include?(name), &quot;%s was not finished&quot; % name)
+        end
+        
+        # Now make sure that cleanup gets rid of those generated types.
+        assert_nothing_raised do
+            trans.cleanup
+        end
+    end
+
     def test_ignore_tags?
         config = Puppet::Node::Catalog.new
         config.host_config = true
@@ -872,7 +911,7 @@ class TestTransactions &lt; Test::Unit::TestCase
     end
     
     def test_set_target
-        file = Puppet::Type.newfile(:path =&gt; tempfile(), :content =&gt; &quot;yay&quot;)
+        file = Puppet::Type.type(:file).create(:path =&gt; tempfile(), :content =&gt; &quot;yay&quot;)
         exec1 = Puppet::Type.type(:exec).create :command =&gt; &quot;/bin/echo exec1&quot;
         exec2 = Puppet::Type.type(:exec).create :command =&gt; &quot;/bin/echo exec2&quot;
         trans = Puppet::Transaction.new(mk_catalog(file, exec1, exec2))
@@ -907,7 +946,7 @@ class TestTransactions &lt; Test::Unit::TestCase
             Puppet::Type.rmtype(:norefresh)
         end
 
-        file = Puppet::Type.newfile :path =&gt; tempfile(), :content =&gt; &quot;yay&quot;
+        file = Puppet::Type.type(:file).create :path =&gt; tempfile(), :content =&gt; &quot;yay&quot;
         one = klass.create :name =&gt; &quot;one&quot;, :subscribe =&gt; file
         
         assert_apply(file, one)
@@ -985,8 +1024,8 @@ class TestTransactions &lt; Test::Unit::TestCase
         # Now files
         d = tempfile()
         f = File.join(d, &quot;file&quot;)
-        file = Puppet::Type.newfile(:path =&gt; f, :content =&gt; &quot;yay&quot;)
-        dir = Puppet::Type.newfile(:path =&gt; d, :ensure =&gt; :directory, :require =&gt; file)
+        file = Puppet::Type.type(:file).create(:path =&gt; f, :content =&gt; &quot;yay&quot;)
+        dir = Puppet::Type.type(:file).create(:path =&gt; d, :ensure =&gt; :directory, :require =&gt; file)
         
         rels[dir] = file
         rels.each do |after, before|
@@ -1010,7 +1049,7 @@ class TestTransactions &lt; Test::Unit::TestCase
         path = tempfile
         epath = tempfile
         spath = tempfile
-        file = Puppet::Type.newfile(:path =&gt; path, :ensure =&gt; :file,
+        file = Puppet::Type.type(:file).create(:path =&gt; path, :ensure =&gt; :file,
             :title =&gt; &quot;file&quot;)
         exec = Puppet::Type.type(:exec).create(:command =&gt; &quot;touch %s&quot; % epath,
             :path =&gt; ENV[&quot;PATH&quot;], :subscribe =&gt; file, :refreshonly =&gt; true,
@@ -1048,7 +1087,7 @@ class TestTransactions &lt; Test::Unit::TestCase
         3.times do |i|
             path = tempfile
             paths &lt;&lt; path
-            file = Puppet::Type.newfile(:path =&gt; path, :ensure =&gt; :absent,
+            file = Puppet::Type.type(:file).create(:path =&gt; path, :ensure =&gt; :absent,
                 :backup =&gt; false, :title =&gt; &quot;file%s&quot; % i)
             File.open(path, &quot;w&quot;) { |f| f.puts &quot;&quot; }
             files &lt;&lt; file</diff>
      <filename>test/other/transactions.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/puppet/provider/confine/facter.rb</filename>
    </removed>
    <removed>
      <filename>spec/unit/provider/confine/facter.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>e3ffa70b9c2ca838ec4c9b62ecb60ba1848c2bfc</id>
    </parent>
    <parent>
      <id>49016bb29312bfeb6f41ce420159e6ffc477eebe</id>
    </parent>
  </parents>
  <author>
    <name>Blake Barnett</name>
    <email>shadoi@dre.gs</email>
  </author>
  <url>http://github.com/shadoi/puppet/commit/245fc2d76c82df46f8c64365e9cc2355572e5416</url>
  <id>245fc2d76c82df46f8c64365e9cc2355572e5416</id>
  <committed-date>2008-06-17T14:31:13-07:00</committed-date>
  <authored-date>2008-06-17T14:31:13-07:00</authored-date>
  <message>Merge branch 'master' of git://reductivelabs.com/puppet</message>
  <tree>2a76e5fb906dcb68d97e07f63b872a901b7f6a6c</tree>
  <committer>
    <name>Blake Barnett</name>
    <email>shadoi@dre.gs</email>
  </committer>
</commit>
