[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Matt Robinson matt at puppetlabs.com
Tue May 10 08:03:57 UTC 2011


The following commit has been merged in the experimental branch:
commit d4a468543f1f06d44efdb7e375284b0e65260caf
Merge: 6d9cae2e9ca6a56506f679db02ba9abb30a4df91 876d0503dd93329a73e7f335c10a47330d745293
Author: Matt Robinson <matt at puppetlabs.com>
Date:   Wed Feb 2 16:47:53 2011 -0800

    Merge branch '2.6.x' into next
    
    * 2.6.x: (46 commits)
      Augmentation of tests for prior commit
      Fix to fix for #5755 -- backref serialization issues in zaml
      Fixed #5564 - Added some more fqdn_rand documentation
      Fixed #4968 - Updated list of options turned on by --test in documentation
      (#5061) - allow special hostclass/define variables to be evaluated as defaults.
      (#6107) Fix an error when auditing a file with empty content
      Remove already initialized constant warning from file_spec.rb tests
      (#5566) Treat source only File checksums as syntax errors when used with content
      Rename variable used in File type validation to be more clear
      Remove invalid "timestamp" and "time", and add missing "ctime" File checksum types.
      Remove order dependency when specifying source and checksum on File type
      Bug #5755 -- ZAML generates extra newline in some hash backreferences.
      bug #5681 -- code fix to handle AIX mount output
      Bug #5681 -- parse AIX mount command output.
      Spec for #5681 to allow parsing of AIX mount output in mount provider
      Fixed #6091 - Changed POSIX path matching to allow multiple leading slashes
      Bug #6091 -- test leading double-slash in filenames are allowed.
      Fixed #6071 - Fixed typo and improved exec path error message
      Fixed #6061 - Allowed -1 as password min/max age
      Bug #6061 -- verify that negative {min,max}_password_age are accepted.
      ...
    
    Manually Resolved Conflicts:
    	lib/puppet/util/zaml.rb
    	spec/unit/util/zaml_spec.rb

diff --combined lib/puppet/defaults.rb
index e8b9846,764cbbe..e3b86bc
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@@ -2,8 -2,8 +2,8 @@@
  module Puppet
    setdefaults(:main,
      :confdir => [Puppet.run_mode.conf_dir, "The main Puppet configuration directory.  The default for this parameter is calculated based on the user.  If the process
-     is running as root or the user that `puppet master` is supposed to run as, it defaults to a system directory, but if it's running as any other user,
-     it defaults to being in `~`."],
+     is running as root or the user that Puppet is supposed to run as, it defaults to a system directory, but if it's running as any other user,
+     it defaults to being in the user's home directory."],
      :vardir => [Puppet.run_mode.var_dir, "Where Puppet stores dynamic and growing data.  The default for this parameter is calculated specially, like `confdir`_."],
      :name => [Puppet.application_name.to_s, "The name of the application, if we are running as one.  The
        default is essentially $0 without the path or `.rb`."],
@@@ -115,17 -115,7 +115,17 @@@
      :node_terminus => ["plain", "Where to find information about nodes."],
      :catalog_terminus => ["compiler", "Where to get node catalogs.  This is useful to change if, for instance,
        you'd like to pre-compile catalogs and store them in memcached or some other easily-accessed store."],
 -    :facts_terminus => [Puppet.application_name.to_s == "master" ? 'yaml' : 'facter', "The node facts terminus."],
 +    :facts_terminus => {
 +      :default => Puppet.application_name.to_s == "master" ? 'yaml' : 'facter',
 +      :desc => "The node facts terminus.",
 +      :hook => proc do |value|
 +        require 'puppet/node/facts'
 +        if value.to_s == "rest"
 +          Puppet::Node::Facts.indirection.cache_class = :yaml
 +        end
 +      end
 +    },
 +    :inventory_terminus => [ "$facts_terminus", "Should usually be the same as the facts terminus" ],
      :httplog => { :default => "$logdir/http.log",
        :owner => "root",
        :mode => 0640,
@@@ -152,7 -142,7 +152,7 @@@
            Puppet.settings[:storeconfigs] = true
  
            # But then we modify the configuration
 -          Puppet::Resource::Catalog.cache_class = :queue
 +          Puppet::Resource::Catalog.indirection.cache_class = :queue
          else
            raise "Cannot disable asynchronous storeconfigs in a running process"
          end
@@@ -588,28 -578,14 +588,28 @@@
        end
      },
      :report_server => ["$server",
 -      "The server to which to send transaction reports."
 +      "The server to send transaction reports to."
      ],
      :report_port => ["$masterport",
        "The port to communicate with the report_server."
      ],
 -    :report => [false,
 +    :inventory_server => ["$server",
 +      "The server to send facts to."
 +    ],
 +    :inventory_port => ["$masterport",
 +      "The port to communicate with the inventory_server."
 +    ],
 +    :report => [true,
        "Whether to send reports after every transaction."
      ],
 +    :lastrunfile =>  { :default => "$statedir/last_run_summary.yaml",
 +      :mode => 0660,
 +      :desc => "Where puppet agent stores the last run report summary in yaml format."
 +    },
 +    :lastrunreport =>  { :default => "$statedir/last_run_report.yaml",
 +      :mode => 0660,
 +      :desc => "Where puppet agent stores the last run report in yaml format."
 +    },
      :graph => [false, "Whether to create dot graph files for the different
        configuration graphs.  These dot files can be interpreted by tools
        like OmniGraffle or dot (which is part of ImageMagick)."],
@@@ -799,9 -775,9 +799,9 @@@
          if value
            require 'puppet/rails'
            raise "StoreConfigs not supported without ActiveRecord 2.1 or higher" unless Puppet.features.rails?
 -          Puppet::Resource::Catalog.cache_class = :active_record unless Puppet.settings[:async_storeconfigs]
 -          Puppet::Node::Facts.cache_class = :active_record
 -          Puppet::Node.cache_class = :active_record
 +          Puppet::Resource::Catalog.indirection.cache_class = :active_record unless Puppet.settings[:async_storeconfigs]
 +          Puppet::Node::Facts.indirection.cache_class = :active_record
 +          Puppet::Node.indirection.cache_class = :active_record
          end
        end
      }
diff --combined lib/puppet/provider/nameservice/directoryservice.rb
index 106d99e,b018803..2e34809
--- a/lib/puppet/provider/nameservice/directoryservice.rb
+++ b/lib/puppet/provider/nameservice/directoryservice.rb
@@@ -321,31 -321,6 +321,31 @@@ class DirectoryService < Puppet::Provid
      password_hash
    end
  
 +  # Unlike most other *nixes, OS X doesn't provide built in functionality
 +  # for automatically assigning uids and gids to accounts, so we set up these
 +  # methods for consumption by functionality like --mkusers
 +  # By default we restrict to a reasonably sane range for system accounts
 +  def self.next_system_id(id_type, min_id=20)
 +    dscl_args = ['.', '-list']
 +    if id_type == 'uid'
 +      dscl_args << '/Users' << 'uid'
 +    elsif id_type == 'gid'
 +      dscl_args << '/Groups' << 'gid'
 +    else
 +      fail("Invalid id_type #{id_type}. Only 'uid' and 'gid' supported")
 +    end
 +    dscl_out = dscl(dscl_args)
 +    # We're ok with throwing away negative uids here.
 +    ids = dscl_out.split.compact.collect { |l| l.to_i if l.match(/^\d+$/) }
 +    ids.compact!.sort! { |a,b| a.to_f <=> b.to_f }
 +    # We're just looking for an unused id in our sorted array.
 +    ids.each_index do |i|
 +      next_id = ids[i] + 1
 +      return next_id if ids[i+1] != next_id and next_id >= min_id
 +    end
 +  end
 +
 +
    def ensure=(ensure_value)
      super
      # We need to loop over all valid properties for the type we're
@@@ -447,14 -422,7 +447,14 @@@
      # Now we create all the standard properties
      Puppet::Type.type(@resource.class.name).validproperties.each do |property|
        next if property == :ensure
 -      if value = @resource.should(property) and value != ""
 +      value = @resource.should(property)
 +      if property == :gid and value.nil?
 +        value = self.class.next_system_id(id_type='gid')
 +      end
 +      if property == :uid and value.nil?
 +        value = self.class.next_system_id(id_type='uid')
 +      end
 +      if value != "" and not value.nil?
          if property == :members
            add_members(nil, value)
          else
@@@ -474,7 -442,7 +474,7 @@@
  
    def remove_unwanted_members(current_members, new_members)
      current_members.each do |member|
-       if not new_members.include?(member)
+       if not new_members.flatten.include?(member)
          cmd = [:dseditgroup, "-o", "edit", "-n", ".", "-d", member, @resource[:name]]
          begin
            execute(cmd)
@@@ -486,7 -454,7 +486,7 @@@
    end
  
    def add_members(current_members, new_members)
-     new_members.each do |new_member|
+     new_members.flatten.each do |new_member|
        if current_members.nil? or not current_members.include?(new_member)
          cmd = [:dseditgroup, "-o", "edit", "-n", ".", "-a", new_member, @resource[:name]]
          begin
diff --combined lib/puppet/provider/zone/solaris.rb
index a1df041,f46337b..194af50
--- a/lib/puppet/provider/zone/solaris.rb
+++ b/lib/puppet/provider/zone/solaris.rb
@@@ -40,7 -40,7 +40,7 @@@ Puppet::Type.type(:zone).provide(:solar
      # Then perform all of our configuration steps.  It's annoying
      # that we need this much internal info on the resource.
      @resource.send(:properties).each do |property|
-       str += property.configtext + "\n" if property.is_a? ZoneConfigProperty and ! property.insync?(properties[property.name])
+       str += property.configtext + "\n" if property.is_a? ZoneConfigProperty and ! property.safe_insync?(properties[property.name])
      end
  
      str += "commit\n"
@@@ -221,9 -221,6 +221,9 @@@
      if dir = config["inherit-pkg-dir"]
        result[:inherit] = dir.collect { |dirs| dirs[:dir] }
      end
 +    if datasets = config["dataset"]
 +      result[:dataset] = datasets.collect { |dataset| dataset[:name] }
 +    end
      result[:iptype] = config[:"ip-type"]
      if net = config["net"]
        result[:ip] = net.collect do |params|
diff --combined lib/puppet/resource/type.rb
index 7782484,34fddf1..b9cf699
--- a/lib/puppet/resource/type.rb
+++ b/lib/puppet/resource/type.rb
@@@ -13,8 -13,8 +13,8 @@@ class Puppet::Resource::Typ
  
    RESOURCE_SUPERTYPES = [:hostclass, :node, :definition]
  
 -  attr_accessor :file, :line, :doc, :code, :ruby_code, :parent, :resource_type_collection, :module_name
 -  attr_reader :type, :namespace, :arguments, :behaves_like
 +  attr_accessor :file, :line, :doc, :code, :ruby_code, :parent, :resource_type_collection
 +  attr_reader :type, :namespace, :arguments, :behaves_like, :module_name
  
    RESOURCE_SUPERTYPES.each do |t|
      define_method("#{t}?") { self.type == t }
@@@ -92,8 -92,6 +92,8 @@@
      end
  
      set_arguments(options[:arguments])
 +
 +    @module_name = options[:module_name]
    end
  
    # This is only used for node names, and really only when the node name
@@@ -145,18 -143,26 +145,26 @@@
    # classes and nodes.  No parameters are be supplied--if this is a
    # parameterized class, then all parameters take on their default
    # values.
-   def ensure_in_catalog(scope)
+   def ensure_in_catalog(scope, parameters=nil)
      type == :definition and raise ArgumentError, "Cannot create resources for defined resource types"
      resource_type = type == :hostclass ? :class : :node
  
      # Do nothing if the resource already exists; this makes sure we don't
      # get multiple copies of the class resource, which helps provide the
      # singleton nature of classes.
-     if resource = scope.catalog.resource(resource_type, name)
+     # we should not do this for classes with parameters
+     # if parameters are passed, we should still try to create the resource
+     # even if it exists so that we can fail
+     # this prevents us from being able to combine param classes with include
+     if resource = scope.catalog.resource(resource_type, name) and !parameters
        return resource
      end
- 
      resource = Puppet::Parser::Resource.new(resource_type, name, :scope => scope, :source => self)
+     if parameters
+       parameters.each do |k,v|
+         resource.set_parameter(k,v)
+       end
+     end
      instantiate_resource(scope, resource)
      scope.compiler.add_resource(scope, resource)
      resource
@@@ -224,6 -230,19 +232,19 @@@
        set[param] = true
      end
  
+     if @type == :hostclass
+       scope.setvar("title", resource.title.to_s.downcase) unless set.include? :title
+       scope.setvar("name",  resource.name.to_s.downcase ) unless set.include? :name
+     else
+       scope.setvar("title", resource.title              ) unless set.include? :title
+       scope.setvar("name",  resource.name               ) unless set.include? :name
+     end
+     scope.setvar("module_name", module_name) if module_name and ! set.include? :module_name
+ 
+     if caller_name = scope.parent_module_name and ! set.include?(:caller_module_name)
+       scope.setvar("caller_module_name", caller_name)
+     end
+     scope.class_set(self.name,scope) if hostclass? or node?
      # Verify that all required arguments are either present or
      # have been provided with defaults.
      arguments.each do |param, default|
@@@ -240,19 -259,6 +261,6 @@@
        resource[param] = value
      end
  
-     if @type == :hostclass
-       scope.setvar("title", resource.title.to_s.downcase) unless set.include? :title
-       scope.setvar("name",  resource.name.to_s.downcase ) unless set.include? :name
-     else
-       scope.setvar("title", resource.title              ) unless set.include? :title
-       scope.setvar("name",  resource.name               ) unless set.include? :name
-     end
-     scope.setvar("module_name", module_name) if module_name and ! set.include? :module_name
- 
-     if caller_name = scope.parent_module_name and ! set.include?(:caller_module_name)
-       scope.setvar("caller_module_name", caller_name)
-     end
-     scope.class_set(self.name,scope) if hostclass? or node?
    end
  
    # Create a new subscope in which to evaluate our code.
diff --combined lib/puppet/type/file.rb
index 457afd4,cbb51bb..963b9e5
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@@ -34,7 -34,7 +34,7 @@@ Puppet::Type.newtype(:file) d
  
      validate do |value|
        # accept various path syntaxes: lone slash, posix, win32, unc
-       unless (Puppet.features.posix? and (value =~ /^\/$/ or value =~ /^\/[^\/]/)) or (Puppet.features.microsoft_windows? and (value =~ /^.:\// or value =~ /^\/\/[^\/]+\/[^\/]+/))
+       unless (Puppet.features.posix? and value =~ /^\//) or (Puppet.features.microsoft_windows? and (value =~ /^.:\// or value =~ /^\/\/[^\/]+\/[^\/]+/))
          fail Puppet::Error, "File paths must be fully qualified, not '#{value}'"
        end
      end
@@@ -271,17 -271,24 +271,24 @@@
    end
  
    CREATORS = [:content, :source, :target]
+   SOURCE_ONLY_CHECKSUMS = [:none, :ctime, :mtime]
  
    validate do
-     count = 0
+     creator_count = 0
      CREATORS.each do |param|
-       count += 1 if self.should(param)
+       creator_count += 1 if self.should(param)
      end
-     count += 1 if @parameters.include?(:source)
-     self.fail "You cannot specify more than one of #{CREATORS.collect { |p| p.to_s}.join(", ")}" if count > 1
+     creator_count += 1 if @parameters.include?(:source)
+     self.fail "You cannot specify more than one of #{CREATORS.collect { |p| p.to_s}.join(", ")}" if creator_count > 1
  
      self.fail "You cannot specify a remote recursion without a source" if !self[:source] and self[:recurse] == :remote
  
+     self.fail "You cannot specify source when using checksum 'none'" if self[:checksum] == :none && !self[:source].nil?
+ 
+     SOURCE_ONLY_CHECKSUMS.each do |checksum_type|
+       self.fail "You cannot specify content when using checksum '#{checksum_type}'" if self[:checksum] == checksum_type && !self[:content].nil?
+     end
+ 
      self.warning "Possible error: recurselimit is set but not recurse, no recursion will happen" if !self[:recurse] and self[:recurselimit]
    end
  
@@@ -290,25 -297,8 +297,8 @@@
      super(path.gsub(/\/+/, '/').sub(/\/$/, ''))
    end
  
-   # List files, but only one level deep.
-   def self.instances(base = "/")
-     return [] unless FileTest.directory?(base)
- 
-     files = []
-     Dir.entries(base).reject { |e|
-       e == "." or e == ".."
-     }.each do |name|
-       path = File.join(base, name)
-       if obj = self[path]
-         obj[:audit] = :all
-         files << obj
-       else
-         files << self.new(
-           :name => path, :audit => :all
-         )
-       end
-     end
-     files
+   def self.instances(base = '/')
+     return self.new(:name => base, :recurse => true, :recurselimit => 1, :audit => :all).recurse_local.values
    end
  
    @depthfirst = false
@@@ -587,7 -577,7 +577,7 @@@
  
    def perform_recursion(path)
  
 -    Puppet::FileServing::Metadata.search(
 +    Puppet::FileServing::Metadata.indirection.search(
  
        path,
        :links => self[:links],
@@@ -779,7 -769,7 +769,7 @@@
        # Make sure we get a new stat objct
        expire
        currentvalue = thing.retrieve
-       thing.sync unless thing.insync?(currentvalue)
+       thing.sync unless thing.safe_insync?(currentvalue)
      end
    end
  end
diff --combined lib/puppet/type/file/source.rb
index 19dabbd,bc464e1..ac06a26
--- a/lib/puppet/type/file/source.rb
+++ b/lib/puppet/type/file/source.rb
@@@ -98,7 -98,7 +98,7 @@@ module Puppe
      cached_attr(:content) do
        raise Puppet::DevError, "No source for content was stored with the metadata" unless metadata.source
  
 -      unless tmp = Puppet::FileServing::Content.find(metadata.source)
 +      unless tmp = Puppet::FileServing::Content.indirection.find(metadata.source)
          fail "Could not find any content at %s" % metadata.source
        end
        tmp.content
@@@ -148,7 -148,7 +148,7 @@@
        result = nil
        value.each do |source|
          begin
 -          if data = Puppet::FileServing::Metadata.find(source)
 +          if data = Puppet::FileServing::Metadata.indirection.find(source)
              result = data
              result.source = source
              break
@@@ -169,7 -169,6 +169,6 @@@
        checks.delete(:checksum)
  
        resource[:audit] = checks
-       resource[:checksum] = :md5 unless resource.property(:checksum)
      end
  
      def local?
diff --combined lib/puppet/type/host.rb
index 867ef2a,2666e50..a770eda
--- a/lib/puppet/type/host.rb
+++ b/lib/puppet/type/host.rb
@@@ -1,5 -1,3 +1,5 @@@
 +require 'puppet/property/ordered_list'
 +
  module Puppet
    newtype(:host) do
      ensurable
@@@ -7,41 -5,68 +7,41 @@@
      newproperty(:ip) do
        desc "The host's IP address, IPv4 or IPv6."
  
 -    validate do |value|
 -      unless value =~ /((([0-9a-fA-F]+:){7}[0-9a-fA-F]+)|(([0-9a-fA-F]+:)*[0-9a-fA-F]+)?::(([0-9a-fA-F]+:)*[0-9a-fA-F]+)?)|((25[0-5]|2[0-4][\d]|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3})/
 -      raise Puppet::Error, "Invalid IP address"
 +      validate do |value|
 +        unless value =~ /^((([0-9a-fA-F]+:){7}[0-9a-fA-F]+)|(([0-9a-fA-F]+:)*[0-9a-fA-F]+)?::(([0-9a-fA-F]+:)*[0-9a-fA-F]+)?)|((25[0-5]|2[0-4][\d]|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3})$/
 +          raise Puppet::Error, "Invalid IP address"
 +        end
        end
  
      end
  
 -    newproperty(:host_aliases) do
 +    # for now we use OrderedList to indicate that the order does matter.
 +    newproperty(:host_aliases, :parent => Puppet::Property::OrderedList) do
        desc "Any aliases the host might have.  Multiple values must be
          specified as an array."
  
 -      def insync?(is)
 -        is == @should
 -      end
 -
 -      def is_to_s(currentvalue = @is)
 -        currentvalue = [currentvalue] unless currentvalue.is_a? Array
 -        currentvalue.join(" ")
 -      end
 -
 -      def retrieve
 -        is = super
 -        case is
 -        when String
 -          is = is.split(/\s*,\s*/)
 -        when Symbol
 -          is = [is]
 -        when Array
 -          # nothing
 -        else
 -          raise Puppet::DevError, "Invalid @is type #{is.class}"
 -        end
 -        is
 -      end
 -
 -      # We actually want to return the whole array here, not just the first
 -      # value.
 -      def should
 -        if defined?(@should)
 -          if @should == [:absent]
 -            return :absent
 -          else
 -            return @should
 -          end
 -        else
 -          return nil
 -        end
 +      def delimiter
 +        " "
        end
  
 -      def should_to_s(newvalue = @should)
 -        newvalue.join(" ")
 +      def inclusive?
 +        true
        end
  
        validate do |value|
          raise Puppet::Error, "Host aliases cannot include whitespace" if value =~ /\s/
 +        raise Puppet::Error, "Host alias cannot be an empty string. Use an empty array to delete all host_aliases " if value =~ /^\s*$/
        end
 +
 +    end
 +
 +    newproperty(:comment) do
 +      desc "A comment that will be attached to the line with a # character"
      end
  
      newproperty(:target) do
        desc "The file in which to store service information.  Only used by
-         those providers that write to disk."
+         those providers that write to disk. On most systems this defaults to `/etc/hosts`."
  
        defaultto { if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
          @resource.class.defaultprovider.default_target
diff --combined lib/puppet/type/mount.rb
index e8c6b32,da9a70b..915bb8e
--- a/lib/puppet/type/mount.rb
+++ b/lib/puppet/type/mount.rb
@@@ -89,7 -89,7 +89,7 @@@ module Puppe
            if prop.name == :ensure
              false
            else
-             ! prop.insync?(currentvalues[prop])
+             ! prop.safe_insync?(currentvalues[prop])
            end
          end.each { |prop| prop.sync }.length
          @resource.flush if oos > 0
@@@ -200,7 -200,7 +200,7 @@@
        newvalues(:true, :false)
        defaultto do
          case Facter.value(:operatingsystem)
-         when "FreeBSD", "Darwin"
+         when "FreeBSD", "Darwin", "AIX"
            false
          else
            true
@@@ -210,7 -210,7 +210,7 @@@
  
      def refresh
        # Only remount if we're supposed to be mounted.
 -      provider.remount if self.should(:fstype) != "swap" and provider.mounted?
 +      provider.remount if self.should(:fstype) != "swap" and self.should(:ensure) == :mounted
      end
  
      def value(name)
diff --combined lib/puppet/type/service.rb
index 786a504,0d09c3d..3ef0449
--- a/lib/puppet/type/service.rb
+++ b/lib/puppet/type/service.rb
@@@ -73,7 -73,7 +73,7 @@@ module Puppe
  
          if property = @resource.property(:enable)
            val = property.retrieve
-           property.sync unless property.insync?(val)
+           property.sync unless property.safe_insync?(val)
          end
  
          event
@@@ -100,8 -100,6 +100,8 @@@
          looked for in the process table."
  
        newvalues(:true, :false)
 +
 +      defaultto :true
      end
      newparam(:name) do
        desc "The name of the service to run.  This name is used to find
@@@ -146,10 -144,16 +146,16 @@@
          specified."
      end
      newparam(:status) do
-       desc "Specify a *status* command manually.  If left
-         unspecified, the status method will be determined
-         automatically, usually by looking for the service in the
-         process table."
+       desc "Specify a *status* command manually.  This command must
+         return 0 if the service is running and a nonzero value otherwise.
+         Ideally, these return codes should conform to
+         [the LSB's specification for init script status actions](http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html),
+         but puppet only considers the difference between 0 and nonzero
+         to be relevant.
+ 
+         If left unspecified, the status method will be determined
+         automatically, usually by looking for the service in the process
+         table."
      end
  
      newparam(:stop) do
diff --combined spec/unit/application/doc_spec.rb
index 0fd2c20,ed72363..f432184
--- a/spec/unit/application/doc_spec.rb
+++ b/spec/unit/application/doc_spec.rb
@@@ -1,6 -1,6 +1,6 @@@
  #!/usr/bin/env ruby
  
 -require File.dirname(__FILE__) + '/../../spec_helper'
 +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
  
  require 'puppet/application/doc'
  require 'puppet/util/reference'
@@@ -48,10 -48,10 +48,10 @@@ describe Puppet::Application::Doc d
        @doc.options[:mode].should == :text
      end
  
-     it "should init format to to_rest" do
+     it "should init format to to_markdown" do
        @doc.preinit
  
-       @doc.options[:format].should == :to_rest
+       @doc.options[:format].should == :to_markdown
      end
    end
  
diff --combined spec/unit/application_spec.rb
index 65e4821,c0f9733..65f0616
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@@ -1,6 -1,6 +1,6 @@@
  #!/usr/bin/env ruby
  
 -require File.dirname(__FILE__) + '/../spec_helper'
 +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
  
  require 'puppet/application'
  require 'puppet'
@@@ -16,6 -16,25 +16,25 @@@ describe Puppet::Application d
      Puppet.settings.stubs(:parse)
    end
  
+   describe "finding" do
+     before do
+       @klass = Puppet::Application
+       @klass.stubs(:puts)
+     end
+ 
+     it "should find classes in the namespace" do
+       @klass.find("Agent").should == @klass::Agent
+     end
+ 
+     it "should not find classes outside the namespace" do
+       lambda { @klass.find("String") }.should raise_error(SystemExit)
+     end
+ 
+     it "should exit if it can't find a class" do
+       lambda { @klass.find("ThisShallNeverEverEverExistAsdf") }.should raise_error(SystemExit)
+     end
+   end
+ 
    describe ".run_mode" do
      it "should default to user" do
        @appclass.run_mode.name.should == :user
diff --combined spec/unit/parser/compiler_spec.rb
index 3a7c0b2,687f2ec..18f9a93
--- a/spec/unit/parser/compiler_spec.rb
+++ b/spec/unit/parser/compiler_spec.rb
@@@ -1,6 -1,6 +1,6 @@@
  #!/usr/bin/env ruby
  
 -require File.dirname(__FILE__) + '/../../spec_helper'
 +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
  
  class CompilerTestResource
    attr_accessor :builtin, :virtual, :evaluated, :type, :title
@@@ -105,8 -105,15 +105,15 @@@ describe Puppet::Parser::Compiler d
        node.classes = %w{foo bar}
        compiler = Puppet::Parser::Compiler.new(node)
  
-       compiler.classlist.should include("foo")
-       compiler.classlist.should include("bar")
+       compiler.classlist.should =~ ['foo', 'bar']
+     end
+ 
+     it "should transform node class hashes into a class list" do
+       node = Puppet::Node.new("mynode")
+       node.classes = {'foo'=>{'one'=>'1'}, 'bar'=>{'two'=>'2'}}
+       compiler = Puppet::Parser::Compiler.new(node)
+ 
+       compiler.classlist.should =~ ['foo', 'bar']
      end
  
      it "should add a 'main' stage to the catalog" do
@@@ -185,6 -192,14 +192,14 @@@
        @compiler.class.publicize_methods(:evaluate_node_classes) { @compiler.evaluate_node_classes }
      end
  
+     it "should evaluate any parameterized classes named in the node" do
+       classes = {'foo'=>{'1'=>'one'}, 'bar'=>{'2'=>'two'}}
+       @node.stubs(:classes).returns(classes)
+       @compiler.expects(:evaluate_classes).with(classes, @compiler.topscope)
+       @compiler.compile
+     end
+ 
+ 
      it "should evaluate the main class if it exists" do
        compile_stub(:evaluate_main)
        main_class = @known_resource_types.add Puppet::Resource::Type.new(:hostclass, "")
@@@ -532,7 -547,7 +547,7 @@@
  
        @compiler.add_collection(coll)
  
-       lambda { @compiler.compile }.should raise_error(Puppet::ParseError)
+       lambda { @compiler.compile }.should raise_error Puppet::ParseError, 'Failed to realize virtual resources something'
      end
  
      it "should fail when there are unevaluated resource collections that refer to multiple specific resources" do
@@@ -541,7 -556,7 +556,7 @@@
  
        @compiler.add_collection(coll)
  
-       lambda { @compiler.compile }.should raise_error(Puppet::ParseError)
+       lambda { @compiler.compile }.should raise_error Puppet::ParseError, 'Failed to realize virtual resources one, two'
      end
    end
  
@@@ -566,6 -581,14 +581,14 @@@
        @scope.expects(:find_hostclass).with("notfound").returns(nil)
        @compiler.evaluate_classes(%w{notfound}, @scope)
      end
+     # I wish it would fail
+     it "should log when it can't find class" do
+       klasses = {'foo'=>nil}
+       @node.classes = klasses
+       @compiler.topscope.stubs(:find_hostclass).with('foo').returns(nil)
+       Puppet.expects(:info).with('Could not find class foo for testnode')
+       @compiler.compile
+     end
    end
  
    describe "when evaluating found classes" do
@@@ -586,6 -609,68 +609,68 @@@
        @compiler.evaluate_classes(%w{myclass}, @scope)
      end
  
+     it "should ensure each node class hash is in catalog and have appropriate parameters" do
+       klasses = {'foo'=>{'1'=>'one'}, 'bar::foo'=>{'2'=>'two'}, 'bar'=>{'1'=> [1,2,3], '2'=>{'foo'=>'bar'}}}
+       @node.classes = klasses
+       ast_obj = Puppet::Parser::AST::String.new(:value => 'foo')
+       klasses.each do |name, params|
+         klass = Puppet::Resource::Type.new(:hostclass, name, :arguments => {'1' => ast_obj, '2' => ast_obj})
+         @compiler.topscope.known_resource_types.add klass
+       end
+       catalog = @compiler.compile
+       catalog.classes.should =~ ['foo', 'bar::foo', 'settings', 'bar']
+ 
+       r1 = catalog.resources.detect {|r| r.title == 'Foo' }
+       r1.to_hash.should == {:'1' => 'one', :'2' => 'foo'}
+       r1.tags. should =~ ['class', 'foo']
+ 
+       r2 = catalog.resources.detect {|r| r.title == 'Bar::Foo' }
+       r2.to_hash.should == {:'1' => 'foo', :'2' => 'two'}
+       r2.tags.should =~ ['bar::foo', 'class', 'bar', 'foo']
+ 
+       r2 = catalog.resources.detect {|r| r.title == 'Bar' }
+       r2.to_hash.should == {:'1' => [1,2,3], :'2' => {'foo'=>'bar'}}
+       r2.tags.should =~ ['class', 'bar']
+     end
+ 
+     it "should ensure each node class is in catalog and has appropriate tags" do
+       klasses = ['bar::foo']
+       @node.classes = klasses
+       ast_obj = Puppet::Parser::AST::String.new(:value => 'foo')
+       klasses.each do |name|
+         klass = Puppet::Resource::Type.new(:hostclass, name, :arguments => {'1' => ast_obj, '2' => ast_obj})
+         @compiler.topscope.known_resource_types.add klass
+       end
+       catalog = @compiler.compile
+ 
+       r2 = catalog.resources.detect {|r| r.title == 'Bar::Foo' }
+       r2.tags.should =~ ['bar::foo', 'class', 'bar', 'foo']
+     end
+ 
+     it "should fail if required parameters are missing" do
+       klass = {'foo'=>{'1'=>'one'}}
+       @node.classes = klass
+       klass = Puppet::Resource::Type.new(:hostclass, 'foo', :arguments => {'1' => nil, '2' => nil})
+       @compiler.topscope.known_resource_types.add klass
+       lambda { @compiler.compile }.should raise_error Puppet::ParseError, "Must pass 2 to Class[Foo]"
+     end
+ 
+     it "should fail if invalid parameters are passed" do
+       klass = {'foo'=>{'3'=>'one'}}
+       @node.classes = klass
+       klass = Puppet::Resource::Type.new(:hostclass, 'foo', :arguments => {'1' => nil, '2' => nil})
+       @compiler.topscope.known_resource_types.add klass
+       lambda { @compiler.compile }.should raise_error Puppet::ParseError, "Invalid parameter 3"
+     end
+ 
+     it "should ensure class is in catalog without params" do
+       @node.classes = klasses = {'foo'=>nil}
+       foo = Puppet::Resource::Type.new(:hostclass, 'foo')
+       @compiler.topscope.known_resource_types.add foo
+       catalog = @compiler.compile
+       catalog.classes.should include 'foo'
+     end
+ 
      it "should not evaluate the resources created for found classes unless asked" do
        @compiler.catalog.stubs(:tag)
  
@@@ -759,7 -844,7 +844,7 @@@
      it "should fail if the compile is finished and resource overrides have not been applied" do
        @compiler.add_override(@override)
  
-       lambda { @compiler.compile }.should raise_error(Puppet::ParseError)
+       lambda { @compiler.compile }.should raise_error Puppet::ParseError, 'Could not find resource(s) File[/foo] for overriding'
      end
    end
  end
diff --combined spec/unit/provider/mount_spec.rb
index 9ce03f6,f567a4a..2562955
--- a/spec/unit/provider/mount_spec.rb
+++ b/spec/unit/provider/mount_spec.rb
@@@ -1,6 -1,6 +1,6 @@@
  #!/usr/bin/env ruby
  
 -require File.dirname(__FILE__) + '/../../spec_helper'
 +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
  
  require 'puppet/provider/mount'
  
@@@ -120,6 -120,14 +120,14 @@@ describe Puppet::Provider::Mount d
        @mounter.should be_mounted
      end
  
+     it "should match mounted devices if the operating system is AIX" do
+       Facter.stubs(:value).with("operatingsystem").returns("AIX")
+       mount_data = File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'unit', 'provider', 'mount', 'mount-output.aix.txt'))
+       @mounter.expects(:mountcmd).returns(mount_data)
+ 
+       @mounter.should be_mounted
+     end
+ 
      it "should match ' on <name>' if the operating system is not Darwin, Solaris, or HP-UX" do
        Facter.stubs(:value).with("operatingsystem").returns("Debian")
        @mounter.expects(:mountcmd).returns("/dev/dsk/whatever on / and stuff\n/dev/other/disk on /var and stuff")
diff --combined spec/unit/resource/type_spec.rb
index a22dc35,87b4ab4..e9c2035
--- a/spec/unit/resource/type_spec.rb
+++ b/spec/unit/resource/type_spec.rb
@@@ -1,6 -1,6 +1,6 @@@
  #!/usr/bin/env ruby
  
 -require File.dirname(__FILE__) + '/../../spec_helper'
 +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
  
  require 'puppet/resource/type'
  
@@@ -261,6 -261,28 +261,28 @@@ describe Puppet::Resource::Type d
        @type = Puppet::Resource::Type.new(:hostclass, "foo")
      end
  
+     ['module_name', 'name', 'title'].each do |variable|
+       it "should allow #{variable} to be evaluated as param default" do
 -        @type.module_name = "bar"
++        @type.instance_eval { @module_name = "bar" }
+         var = Puppet::Parser::AST::Variable.new({'value' => variable})
+         @type.set_arguments :foo => var
+         @type.set_resource_parameters(@resource, @scope)
+         @scope.lookupvar('foo').should == 'bar'
+       end
+     end
+ 
+     # this test is to clarify a crazy edge case
+     # if you specify these special names as params, the resource
+     # will override the special variables
+     it "resource should override defaults" do
+       @type.set_arguments :name => nil
+       @resource[:name] = 'foobar'
+       var = Puppet::Parser::AST::Variable.new({'value' => 'name'})
+       @type.set_arguments :foo => var
+       @type.set_resource_parameters(@resource, @scope)
+       @scope.lookupvar('foo').should == 'foobar'
+     end
+ 
      it "should set each of the resource's parameters as variables in the scope" do
        @type.set_arguments :foo => nil, :boo => nil
        @resource[:foo] = "bar"
@@@ -322,7 -344,7 +344,7 @@@
      end
  
      it "should set its module name in the scope if available" do
 -      @type.module_name = "mymod"
 +      @type.instance_eval { @module_name = "mymod" }
  
        @type.set_resource_parameters(@resource, @scope)
  
@@@ -496,7 -518,7 +518,7 @@@
  
        it "should evaluate the parent's resource" do
          @type.parent_type(@scope)
-         
+ 
          @type.evaluate_code(@resource)
  
          @scope.class_scope(@parent_type).should_not be_nil
@@@ -504,7 -526,7 +526,7 @@@
  
        it "should not evaluate the parent's resource if it has already been evaluated" do
          @parent_resource.evaluate
-         
+ 
          @type.parent_type(@scope)
  
          @parent_resource.expects(:evaluate).never
@@@ -531,7 -553,8 +553,7 @@@
          @compiler.add_resource @scope, @parent_resource
  
          @type.resource_type_collection = @scope.known_resource_types
 -        @type.resource_type_collection.stubs(:node).with("parent").returns(@parent_type)
 -        @type.resource_type_collection.stubs(:node).with("Parent").returns(@parent_type)
 +        @type.resource_type_collection.add(@parent_type)
        end
  
        it "should evaluate the parent's resource" do
@@@ -544,7 -567,7 +566,7 @@@
  
        it "should not evaluate the parent's resource if it has already been evaluated" do
          @parent_resource.evaluate
-         
+ 
          @type.parent_type(@scope)
  
          @parent_resource.expects(:evaluate).never
@@@ -574,7 -597,7 +596,7 @@@
        @code = Puppet::Resource::TypeCollection.new("env")
        @code.add @top
        @code.add @middle
-       
+ 
        @node.environment.stubs(:known_resource_types).returns(@code)
      end
  
@@@ -600,12 -623,36 +622,36 @@@
        @compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
      end
  
+     it "should add specified parameters to the resource" do
+       @top.ensure_in_catalog(@scope, {'one'=>'1', 'two'=>'2'})
+       @compiler.catalog.resource(:class, "top")['one'].should == '1'
+       @compiler.catalog.resource(:class, "top")['two'].should == '2'
+     end
+ 
+     it "should not require params for a param class" do
+       @top.ensure_in_catalog(@scope, {})
+       @compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
+     end
+ 
      it "should evaluate the parent class if one exists" do
        @middle.ensure_in_catalog(@scope)
  
        @compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
      end
  
+     it "should evaluate the parent class if one exists" do
+       @middle.ensure_in_catalog(@scope, {})
+ 
+       @compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
+     end
+ 
+     it "should fail if you try to create duplicate class resources" do
+       othertop = Puppet::Parser::Resource.new(:class, 'top',:source => @source, :scope => @scope )
+       # add the same class resource to the catalog
+       @compiler.catalog.add_resource(othertop)
+       lambda { @top.ensure_in_catalog(@scope, {}) }.should raise_error(Puppet::Resource::Catalog::DuplicateResourceError)
+     end
+ 
      it "should fail to evaluate if a parent class is defined but cannot be found" do
        othertop = Puppet::Resource::Type.new :hostclass, "something", :parent => "yay"
        @code.add othertop
diff --combined spec/unit/resource_spec.rb
index 32b03ad,ff31b24..8b7bfc3
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@@ -1,6 -1,6 +1,6 @@@
  #!/usr/bin/env ruby
  
 -require File.dirname(__FILE__) + '/../spec_helper'
 +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
  require 'puppet/resource'
  
  describe Puppet::Resource do
@@@ -98,6 -98,14 +98,14 @@@
      lambda { Puppet::Resource.new("foo") }.should raise_error(ArgumentError)
    end
  
+   it 'should fail if strict is set and type does not exist' do
+     lambda { Puppet::Resource.new('foo', 'title', {:strict=>true}) }.should raise_error(ArgumentError, 'Invalid resource type foo') 
+   end
+ 
+   it 'should fail if strict is set and class does not exist' do
+     lambda { Puppet::Resource.new('Class', 'foo', {:strict=>true}) }.should raise_error(ArgumentError, 'Could not find declared class foo') 
+   end
+ 
    it "should fail if the title is a hash and the type is not a valid resource reference string" do
      lambda { Puppet::Resource.new({:type => "foo", :title => "bar"}) }.should raise_error(ArgumentError,
        'Puppet::Resource.new does not take a hash as the first argument. Did you mean ("foo", "bar") ?'
diff --combined spec/unit/type/file_spec.rb
index 31d3d6b,90f3daf..539782f
--- a/spec/unit/type/file_spec.rb
+++ b/spec/unit/type/file_spec.rb
@@@ -1,6 -1,6 +1,6 @@@
  #!/usr/bin/env ruby
  
 -require File.dirname(__FILE__) + '/../../spec_helper'
 +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
  
  describe Puppet::Type.type(:file) do
    before do
@@@ -194,6 -194,23 +194,23 @@@
          file = Puppet::Type::File.new(:path => "/")
          file[:path].should == "/"
        end
+ 
+       it "should accept a double-slash at the start of the path" do
+         expect {
+           file = Puppet::Type::File.new(:path => "//tmp/xxx")
+           # REVISIT: This should be wrong, later.  See the next test.
+           # --daniel 2011-01-31
+           file[:path].should == '/tmp/xxx'
+         }.should_not raise_error
+       end
+ 
+       # REVISIT: This is pending, because I don't want to try and audit the
+       # entire codebase to make sure we get this right.  POSIX treats two (and
+       # exactly two) '/' characters at the start of the path specially.
+       #
+       # See sections 3.2 and 4.11, which allow DomainOS to be all special like
+       # and still have the POSIX branding and all. --daniel 2011-01-31
+       it "should preserve the double-slash at the start of the path"
      end
  
      describe "on Microsoft Windows systems" do
@@@ -508,47 -525,47 +525,47 @@@
  
    describe "when executing a recursive search" do
      it "should use Metadata to do its recursion" do
 -      Puppet::FileServing::Metadata.expects(:search)
 +      Puppet::FileServing::Metadata.indirection.expects(:search)
        @file.perform_recursion(@file[:path])
      end
  
      it "should use the provided path as the key to the search" do
 -      Puppet::FileServing::Metadata.expects(:search).with { |key, options| key == "/foo" }
 +      Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| key == "/foo" }
        @file.perform_recursion("/foo")
      end
  
      it "should return the results of the metadata search" do
 -      Puppet::FileServing::Metadata.expects(:search).returns "foobar"
 +      Puppet::FileServing::Metadata.indirection.expects(:search).returns "foobar"
        @file.perform_recursion(@file[:path]).should == "foobar"
      end
  
      it "should pass its recursion value to the search" do
        @file[:recurse] = true
 -      Puppet::FileServing::Metadata.expects(:search).with { |key, options| options[:recurse] == true }
 +      Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| options[:recurse] == true }
        @file.perform_recursion(@file[:path])
      end
  
      it "should pass true if recursion is remote" do
        @file[:recurse] = :remote
 -      Puppet::FileServing::Metadata.expects(:search).with { |key, options| options[:recurse] == true }
 +      Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| options[:recurse] == true }
        @file.perform_recursion(@file[:path])
      end
  
      it "should pass its recursion limit value to the search" do
        @file[:recurselimit] = 10
 -      Puppet::FileServing::Metadata.expects(:search).with { |key, options| options[:recurselimit] == 10 }
 +      Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| options[:recurselimit] == 10 }
        @file.perform_recursion(@file[:path])
      end
  
      it "should configure the search to ignore or manage links" do
        @file[:links] = :manage
 -      Puppet::FileServing::Metadata.expects(:search).with { |key, options| options[:links] == :manage }
 +      Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| options[:links] == :manage }
        @file.perform_recursion(@file[:path])
      end
  
      it "should pass its 'ignore' setting to the search if it has one" do
        @file[:ignore] = %w{.svn CVS}
 -      Puppet::FileServing::Metadata.expects(:search).with { |key, options| options[:ignore] == %w{.svn CVS} }
 +      Puppet::FileServing::Metadata.indirection.expects(:search).with { |key, options| options[:ignore] == %w{.svn CVS} }
        @file.perform_recursion(@file[:path])
      end
    end
@@@ -595,7 -612,7 +612,7 @@@
  
      it "should set checksum_type to none if this file checksum is none" do
        @file[:checksum] = :none
 -      Puppet::FileServing::Metadata.expects(:search).with { |path,params| params[:checksum_type] == :none }.returns [@metadata]
 +      Puppet::FileServing::Metadata.indirection.expects(:search).with { |path,params| params[:checksum_type] == :none }.returns [@metadata]
        @file.expects(:newchild).with("my/file").returns "fiebar"
        @file.recurse_local
      end
@@@ -806,6 -823,73 +823,73 @@@
      end
    end
  
+   describe "when specifying both source, and content properties" do
+     before do
+       @file[:source]  = '/one'
+       @file[:content] = 'file contents'
+     end
+ 
+     it "should raise an exception" do
+       lambda {@file.validate }.should raise_error(/You cannot specify more than one of/)
+     end
+   end
+ 
+   describe "when using source" do
+     before do
+       @file[:source]   = '/one'
+     end
+     Puppet::Type::File::ParameterChecksum.value_collection.values.reject {|v| v == :none}.each do |checksum_type|
+       describe "with checksum '#{checksum_type}'" do
+         before do
+           @file[:checksum] = checksum_type
+         end
+ 
+         it 'should validate' do
+ 
+           lambda { @file.validate }.should_not raise_error
+         end
+       end
+     end
+ 
+     describe "with checksum 'none'" do
+       before do
+         @file[:checksum] = :none
+       end
+ 
+       it 'should raise an exception when validating' do
+         lambda { @file.validate }.should raise_error(/You cannot specify source when using checksum 'none'/)
+       end
+     end
+   end
+ 
+   describe "when using content" do
+     before do
+       @file[:content] = 'file contents'
+     end
+ 
+     (Puppet::Type::File::ParameterChecksum.value_collection.values - SOURCE_ONLY_CHECKSUMS).each do |checksum_type|
+       describe "with checksum '#{checksum_type}'" do
+         before do
+           @file[:checksum] = checksum_type
+         end
+ 
+         it 'should validate' do
+           lambda { @file.validate }.should_not raise_error
+         end
+       end
+     end
+ 
+     SOURCE_ONLY_CHECKSUMS.each do |checksum_type|
+       describe "with checksum '#{checksum_type}'" do
+         it 'should raise an exception when validating' do
+           @file[:checksum] = checksum_type
+ 
+           lambda { @file.validate }.should raise_error(/You cannot specify content when using checksum '#{checksum_type}'/)
+         end
+       end
+     end
+   end
+ 
    describe "when returning resources with :eval_generate" do
      before do
        @graph = stub 'graph', :add_edge => nil
@@@ -1065,4 -1149,45 +1149,45 @@@
      end
    end
  
+   describe "when auditing" do
+     it "should not fail if creating a new file if group is not set" do
+       File.exists?(@path).should == false
+       file = Puppet::Type::File.new(:name => @path, :audit => "all", :content => "content")
+       catalog = Puppet::Resource::Catalog.new
+       catalog.add_resource(file)
+ 
+       Puppet::Util::Storage.stubs(:store) # to prevent the catalog from trying to write state.yaml
+       transaction = catalog.apply
+ 
+       transaction.report.resource_statuses["File[#{@path}]"].failed.should == false
+       File.exists?(@path).should == true
+     end
+ 
+     it "should not log errors if creating a new file with ensure present and no content" do
+       File.exists?(@path).should == false
+       file = Puppet::Type::File.new(:name => @path, :audit => "content", :ensure => "present")
+       catalog = Puppet::Resource::Catalog.new
+       catalog.add_resource(file)
+ 
+       Puppet::Util::Storage.stubs(:store) # to prevent the catalog from trying to write state.yaml
+ 
+       catalog.apply
+       @logs.reject {|l| l.level == :notice }.should be_empty
+     end
+   end
+ 
+   describe "when specifying both source and checksum" do
+     it 'should use the specified checksum when source is first' do
+       @file[:source] = '/foo'
+       @file[:checksum] = :md5lite
+ 
+       @file[:checksum].should be :md5lite
+     end
+     it 'should use the specified checksum when source is last' do
+       @file[:checksum] = :md5lite
+       @file[:source] = '/foo'
+ 
+       @file[:checksum].should be :md5lite
+     end
+   end
  end
diff --combined spec/unit/type/mount_spec.rb
index 934c6f4,0d74042..3df8de9
--- a/spec/unit/type/mount_spec.rb
+++ b/spec/unit/type/mount_spec.rb
@@@ -1,6 -1,6 +1,6 @@@
  #!/usr/bin/env ruby
  
 -require File.dirname(__FILE__) + '/../../spec_helper'
 +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
  
  describe Puppet::Type.type(:mount) do
    it "should have a :refreshable feature that requires the :remount method" do
@@@ -184,64 -184,42 +184,64 @@@ describe Puppet::Type.type(:mount)::Ens
  
      it "should be insync if it is mounted and should be defined" do
        @ensure.should = :defined
-       @ensure.insync?(:mounted).should == true
+       @ensure.safe_insync?(:mounted).should == true
      end
  
      it "should be insync if it is unmounted and should be defined" do
        @ensure.should = :defined
-       @ensure.insync?(:unmounted).should == true
+       @ensure.safe_insync?(:unmounted).should == true
      end
  
      it "should be insync if it is mounted and should be present" do
        @ensure.should = :present
-       @ensure.insync?(:mounted).should == true
+       @ensure.safe_insync?(:mounted).should == true
      end
  
      it "should be insync if it is unmounted and should be present" do
        @ensure.should = :present
-       @ensure.insync?(:unmounted).should == true
+       @ensure.safe_insync?(:unmounted).should == true
      end
    end
  
 -  describe Puppet::Type.type(:mount), "when responding to events" do
 +  describe Puppet::Type.type(:mount), "when responding to refresh" do
  
 -    it "should remount if it is currently mounted" do
 -      @provider.expects(:mounted?).returns(true)
 +    it "should remount if it is supposed to be mounted" do
 +      @mount[:ensure] = "mounted"
        @provider.expects(:remount)
  
        @mount.refresh
      end
  
 -    it "should not remount if it is not currently mounted" do
 -      @provider.expects(:mounted?).returns(false)
 +    it "should not remount if it is supposed to be present" do
 +      @mount[:ensure] = "present"
 +      @provider.expects(:remount).never
 +
 +      @mount.refresh
 +    end
 +
 +    it "should not remount if it is supposed to be absent" do
 +      @mount[:ensure] = "absent"
 +      @provider.expects(:remount).never
 +
 +      @mount.refresh
 +    end
 +
 +    it "should not remount if it is supposed to be defined" do
 +      @mount[:ensure] = "defined"
 +      @provider.expects(:remount).never
 +
 +      @mount.refresh
 +    end
 +
 +    it "should not remount if it is supposed to be unmounted" do
 +      @mount[:ensure] = "unmounted"
        @provider.expects(:remount).never
  
        @mount.refresh
      end
  
      it "should not remount swap filesystems" do
 +      @mount[:ensure] = "mounted"
        @mount[:fstype] = "swap"
        @provider.expects(:remount).never
  
diff --combined spec/unit/type/ssh_authorized_key_spec.rb
index 08c1eb2,666616c..287fca3
--- a/spec/unit/type/ssh_authorized_key_spec.rb
+++ b/spec/unit/type/ssh_authorized_key_spec.rb
@@@ -1,6 -1,6 +1,6 @@@
  #!/usr/bin/env ruby
  
 -require File.dirname(__FILE__) + '/../../spec_helper'
 +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
  
  ssh_authorized_key = Puppet::Type.type(:ssh_authorized_key)
  
@@@ -134,7 -134,7 +134,7 @@@ describe ssh_authorized_key d
      it "should not raise spurious change events" do
        resource = @class.new(:name => "Test", :user => "root")
        target = File.expand_path("~root/.ssh/authorized_keys")
-       resource.property(:target).insync?(target).should == true
+       resource.property(:target).safe_insync?(target).should == true
      end
    end
  
diff --combined spec/unit/type/user_spec.rb
index b834f20,2971344..117c90f
--- a/spec/unit/type/user_spec.rb
+++ b/spec/unit/type/user_spec.rb
@@@ -1,6 -1,6 +1,6 @@@
  #!/usr/bin/env ruby
  
 -require File.dirname(__FILE__) + '/../../spec_helper'
 +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
  
  user = Puppet::Type.type(:user)
  
@@@ -201,21 -201,21 +201,21 @@@ describe user d
        it "should return true if no 'should' values are set" do
          @gid = user.attrclass(:gid).new(:resource => @resource)
  
-         @gid.must be_insync(500)
+         @gid.must be_safe_insync(500)
        end
  
        it "should return true if any of the specified groups are equal to the current integer" do
          Puppet::Util.expects(:gid).with("foo").returns 300
          Puppet::Util.expects(:gid).with("bar").returns 500
  
-         @gid.must be_insync(500)
+         @gid.must be_safe_insync(500)
        end
  
        it "should return false if none of the specified groups are equal to the current integer" do
          Puppet::Util.expects(:gid).with("foo").returns 300
          Puppet::Util.expects(:gid).with("bar").returns 500
  
-         @gid.should_not be_insync(700)
+         @gid.should_not be_safe_insync(700)
        end
      end
  
@@@ -245,6 -245,34 +245,34 @@@
      end
    end
  
+   describe "when managing minimum password age" do
+     before do
+       @age = user.attrclass(:password_min_age).new(:resource => @resource)
+     end
+ 
+     it "should accept a negative minimum age" do
+       expect { @age.should = -1 }.should_not raise_error
+     end
+ 
+     it "should fail with an empty minimum age" do
+       expect { @age.should = '' }.should raise_error(Puppet::Error)
+     end
+   end
+ 
+   describe "when managing maximum password age" do
+     before do
+       @age = user.attrclass(:password_max_age).new(:resource => @resource)
+     end
+ 
+     it "should accept a negative maximum age" do
+       expect { @age.should = -1 }.should_not raise_error
+     end
+ 
+     it "should fail with an empty maximum age" do
+       expect { @age.should = '' }.should raise_error(Puppet::Error)
+     end
+   end
+ 
    describe "when managing passwords" do
      before do
        @password = user.attrclass(:password).new(:resource => @resource, :should => "mypass")

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list