diff options
author | Nick Lewis <nick@puppetlabs.com> | 2011-08-24 15:42:03 -0700 |
---|---|---|
committer | Nick Lewis <nick@puppetlabs.com> | 2011-08-24 15:42:03 -0700 |
commit | da4a2def42639817c4522fc0162bd691956998da (patch) | |
tree | 3cb423a7d2a7a803a922b710c661d675d11bf131 | |
parent | 0d51dc9be0bc1c785d749b8b352a1e43b1b6e9c6 (diff) | |
parent | 630ec36089e2224fba99b76d76eaf904af13e4d6 (diff) | |
download | puppet-da4a2def42639817c4522fc0162bd691956998da.tar.gz puppet-da4a2def42639817c4522fc0162bd691956998da.tar.xz puppet-da4a2def42639817c4522fc0162bd691956998da.zip |
Merge branch '2.7.x'
Conflicts:
lib/puppet/feature/base.rb
lib/puppet/file_serving/configuration.rb
spec/unit/indirector/ssl_file_spec.rb
spec/unit/parser/functions/extlookup_spec.rb
spec/unit/resource/catalog_spec.rb
test/language/ast/variable.rb
104 files changed, 225 insertions, 420 deletions
diff --git a/lib/puppet/feature/base.rb b/lib/puppet/feature/base.rb index b1988278e..cecc1b9ad 100644 --- a/lib/puppet/feature/base.rb +++ b/lib/puppet/feature/base.rb @@ -1,10 +1,35 @@ -# Created by Luke Kanies on 2006-04-30. -# Copyright (c) 2006. All rights reserved. - require 'puppet/util/feature' # Add the simple features, all in one file. +# Order is important as some features depend on others + +# We have a syslog implementation +Puppet.features.add(:syslog, :libs => ["syslog"]) + +# We can use POSIX user functions +Puppet.features.add(:posix) do + require 'etc' + Etc.getpwuid(0) != nil && Puppet.features.syslog? +end + +# We can use Microsoft Windows functions +Puppet.features.add(:microsoft_windows) do + begin + require 'sys/admin' + require 'win32/process' + require 'win32/dir' + require 'win32/service' + require 'win32ole' + require 'win32/api' + true + rescue LoadError => err + warn "Cannot run on Microsoft Windows without the sys-admin, win32-process, win32-dir & win32-service gems: #{err}" unless Puppet.features.posix? + end +end + +raise Puppet::Error,"Cannot determine basic system flavour" unless Puppet.features.posix? or Puppet.features.microsoft_windows? + # We've got LDAP available. Puppet.features.add(:ldap, :libs => ["ldap"]) @@ -33,32 +58,6 @@ Puppet.features.add(:rrd, :libs => ["RRD"]) # We have OpenSSL Puppet.features.add(:openssl, :libs => ["openssl"]) -# We have a syslog implementation -Puppet.features.add(:syslog, :libs => ["syslog"]) - -# We can use POSIX user functions -Puppet.features.add(:posix) do - require 'etc' - Etc.getpwuid(0) != nil && Puppet.features.syslog? -end - -# We can use Microsoft Windows functions -Puppet.features.add(:microsoft_windows) do - begin - require 'sys/admin' - require 'win32/process' - require 'win32/dir' - require 'win32/service' - require 'win32ole' - require 'win32/api' - true - rescue LoadError => err - warn "Cannot run on Microsoft Windows without the sys-admin, win32-process, win32-dir & win32-service gems: #{err}" unless Puppet.features.posix? - end -end - -raise Puppet::Error,"Cannot determine basic system flavour" unless Puppet.features.posix? or Puppet.features.microsoft_windows? - # We have CouchDB Puppet.features.add(:couchdb, :libs => ["couchrest"]) diff --git a/lib/puppet/feature/rails.rb b/lib/puppet/feature/rails.rb index 74ed09aa6..fe5cb0f8a 100644 --- a/lib/puppet/feature/rails.rb +++ b/lib/puppet/feature/rails.rb @@ -1,6 +1,3 @@ -# Created by Luke Kanies on 2006-11-07. -# Copyright (c) 2006. All rights reserved. - require 'puppet/util/feature' Puppet.features.rubygems? diff --git a/lib/puppet/feature/rubygems.rb b/lib/puppet/feature/rubygems.rb index 639524ffe..7cfbbc6d3 100644 --- a/lib/puppet/feature/rubygems.rb +++ b/lib/puppet/feature/rubygems.rb @@ -1,6 +1,3 @@ -# Created by Luke Kanies on 2006-11-07. -# Copyright (c) 2006. All rights reserved. - require 'puppet/util/feature' Puppet.features.add(:rubygems, :libs => "rubygems") diff --git a/lib/puppet/file_serving.rb b/lib/puppet/file_serving.rb index e7e2b898e..0adbac9cf 100644 --- a/lib/puppet/file_serving.rb +++ b/lib/puppet/file_serving.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-16. -# Copyright (c) 2007. All rights reserved. - # Just a stub class. class Puppet::FileServing # :nodoc: end diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb index 706f67af9..e936b5e75 100644 --- a/lib/puppet/file_serving/base.rb +++ b/lib/puppet/file_serving/base.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-22. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving' # The base class for Content and Metadata; provides common diff --git a/lib/puppet/file_serving/configuration.rb b/lib/puppet/file_serving/configuration.rb index d88d57cb0..02bca1bea 100644 --- a/lib/puppet/file_serving/configuration.rb +++ b/lib/puppet/file_serving/configuration.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-16. -# Copyright (c) 2007. All rights reserved. - require 'monitor' require 'puppet' require 'puppet/file_serving' diff --git a/lib/puppet/file_serving/content.rb b/lib/puppet/file_serving/content.rb index 9cfae7ded..25361c668 100644 --- a/lib/puppet/file_serving/content.rb +++ b/lib/puppet/file_serving/content.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-16. -# Copyright (c) 2007. All rights reserved. - require 'puppet/indirector' require 'puppet/file_serving' require 'puppet/file_serving/base' diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb index b4f1457df..8bc5e256d 100644 --- a/lib/puppet/file_serving/fileset.rb +++ b/lib/puppet/file_serving/fileset.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-22. -# Copyright (c) 2007. All rights reserved. - require 'find' require 'puppet/file_serving' require 'puppet/file_serving/metadata' diff --git a/lib/puppet/file_serving/indirection_hooks.rb b/lib/puppet/file_serving/indirection_hooks.rb index 2a0dc1792..bdcc8865e 100644 --- a/lib/puppet/file_serving/indirection_hooks.rb +++ b/lib/puppet/file_serving/indirection_hooks.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'uri' require 'puppet/file_serving' diff --git a/lib/puppet/file_serving/metadata.rb b/lib/puppet/file_serving/metadata.rb index 6656b124a..382ac9c96 100644 --- a/lib/puppet/file_serving/metadata.rb +++ b/lib/puppet/file_serving/metadata.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-16. -# Copyright (c) 2007. All rights reserved. - require 'puppet' require 'puppet/indirector' require 'puppet/file_serving' diff --git a/lib/puppet/file_serving/mount.rb b/lib/puppet/file_serving/mount.rb index 79290ab81..da7102fd8 100644 --- a/lib/puppet/file_serving/mount.rb +++ b/lib/puppet/file_serving/mount.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-16. -# Copyright (c) 2007. All rights reserved. - require 'puppet/network/authstore' require 'puppet/util/logging' require 'puppet/file_serving' diff --git a/lib/puppet/file_serving/terminus_helper.rb b/lib/puppet/file_serving/terminus_helper.rb index 4da285258..b36ec55f8 100644 --- a/lib/puppet/file_serving/terminus_helper.rb +++ b/lib/puppet/file_serving/terminus_helper.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-22. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving' require 'puppet/file_serving/fileset' diff --git a/lib/puppet/indirector/direct_file_server.rb b/lib/puppet/indirector/direct_file_server.rb index 80c84eab5..62234e360 100644 --- a/lib/puppet/indirector/direct_file_server.rb +++ b/lib/puppet/indirector/direct_file_server.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-24. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/terminus_helper' require 'puppet/indirector/terminus' diff --git a/lib/puppet/indirector/file_content/file.rb b/lib/puppet/indirector/file_content/file.rb index 75fc9981c..0bb7106d5 100644 --- a/lib/puppet/indirector/file_content/file.rb +++ b/lib/puppet/indirector/file_content/file.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-16. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/content' require 'puppet/indirector/file_content' require 'puppet/indirector/direct_file_server' diff --git a/lib/puppet/indirector/file_content/file_server.rb b/lib/puppet/indirector/file_content/file_server.rb index 21cfe7324..741c70458 100644 --- a/lib/puppet/indirector/file_content/file_server.rb +++ b/lib/puppet/indirector/file_content/file_server.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/content' require 'puppet/indirector/file_content' require 'puppet/indirector/file_server' diff --git a/lib/puppet/indirector/file_content/rest.rb b/lib/puppet/indirector/file_content/rest.rb index 2fd39b7e5..59975d3ec 100644 --- a/lib/puppet/indirector/file_content/rest.rb +++ b/lib/puppet/indirector/file_content/rest.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/content' require 'puppet/indirector/file_content' require 'puppet/indirector/rest' diff --git a/lib/puppet/indirector/file_metadata/file.rb b/lib/puppet/indirector/file_metadata/file.rb index 4d6b0b335..9d8f839b3 100644 --- a/lib/puppet/indirector/file_metadata/file.rb +++ b/lib/puppet/indirector/file_metadata/file.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-16. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/metadata' require 'puppet/indirector/file_metadata' require 'puppet/indirector/direct_file_server' diff --git a/lib/puppet/indirector/file_metadata/file_server.rb b/lib/puppet/indirector/file_metadata/file_server.rb index cef81f0a5..d3622990a 100644 --- a/lib/puppet/indirector/file_metadata/file_server.rb +++ b/lib/puppet/indirector/file_metadata/file_server.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/metadata' require 'puppet/indirector/file_metadata' require 'puppet/indirector/file_server' diff --git a/lib/puppet/indirector/file_metadata/rest.rb b/lib/puppet/indirector/file_metadata/rest.rb index 023edb8ff..31de2698b 100644 --- a/lib/puppet/indirector/file_metadata/rest.rb +++ b/lib/puppet/indirector/file_metadata/rest.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/metadata' require 'puppet/indirector/file_metadata' require 'puppet/indirector/rest' diff --git a/lib/puppet/indirector/file_server.rb b/lib/puppet/indirector/file_server.rb index d6a8ab872..9516a404c 100644 --- a/lib/puppet/indirector/file_server.rb +++ b/lib/puppet/indirector/file_server.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-19. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/configuration' require 'puppet/file_serving/fileset' require 'puppet/file_serving/terminus_helper' diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb index 06cd80a1e..a7bce69e2 100644 --- a/lib/puppet/parser/compiler.rb +++ b/lib/puppet/parser/compiler.rb @@ -1,6 +1,3 @@ -# Created by Luke A. Kanies on 2007-08-13. -# Copyright (c) 2007. All rights reserved. - require 'puppet/node' require 'puppet/resource/catalog' require 'puppet/util/errors' diff --git a/lib/puppet/parser/functions/create_resources.rb b/lib/puppet/parser/functions/create_resources.rb index 3b8bb3543..646761957 100644 --- a/lib/puppet/parser/functions/create_resources.rb +++ b/lib/puppet/parser/functions/create_resources.rb @@ -1,12 +1,24 @@ -Puppet::Parser::Functions::newfunction(:create_resources, :doc => ' -Converts a hash into a set of resources and adds them to the catalog. -Takes two parameters: - create_resource($type, $resources) - Creates resources of type $type from the $resources hash. Assumes that - hash is in the following form: - {title=>{parameters}} - This is currently tested for defined resources, classes, as well as native types -') do |args| +Puppet::Parser::Functions::newfunction(:create_resources, :doc => <<-'ENDHEREDOC') do |args| + Converts a hash into a set of resources and adds them to the catalog. + + This function takes two arguments: a resource type, and a hash describing + a set of resources. The hash should be in the form `{title => {parameters} }`: + + # A hash of user resources: + $myusers = { + 'nick' => { uid => '1330', + group => allstaff, + groups => ['developers', 'operations', 'release'], } + 'dan' => { uid => '1308', + group => allstaff, + groups => ['developers', 'prosvc', 'release'], } + } + + create_resource(user, $myusers) + + This function can be used to create defined resources and classes, as well + as native resources. + ENDHEREDOC raise ArgumentError, ("create_resources(): wrong number of arguments (#{args.length}; must be 2)") if args.length != 2 #raise ArgumentError, 'requires resource type and param hash' if args.size < 2 # figure out what kind of resource we are @@ -19,7 +31,7 @@ Takes two parameters: type_of_resource = :type elsif resource = find_definition(type_name.downcase) type_of_resource = :define - else + else raise ArgumentError, "could not create resource of unknown type #{type_name}" end end diff --git a/lib/puppet/provider/mount.rb b/lib/puppet/provider/mount.rb index 65296eed2..e2aba8076 100644 --- a/lib/puppet/provider/mount.rb +++ b/lib/puppet/provider/mount.rb @@ -1,6 +1,3 @@ -# Created by Luke Kanies on 2006-11-12. -# Copyright (c) 2006. All rights reserved. - require 'puppet' # A module just to store the mount/unmount methods. Individual providers diff --git a/lib/puppet/provider/naginator.rb b/lib/puppet/provider/naginator.rb index 17cc24086..c84f75c98 100644 --- a/lib/puppet/provider/naginator.rb +++ b/lib/puppet/provider/naginator.rb @@ -1,6 +1,3 @@ -# Created by Luke Kanies on 2007-11-27. -# Copyright (c) 2007. All rights reserved. - require 'puppet' require 'puppet/provider/parsedfile' require 'puppet/external/nagios' diff --git a/lib/puppet/provider/package.rb b/lib/puppet/provider/package.rb index 2f5f67547..f5bfa1216 100644 --- a/lib/puppet/provider/package.rb +++ b/lib/puppet/provider/package.rb @@ -1,6 +1,3 @@ -# Created by Luke A. Kanies on 2007-06-05. -# Copyright (c) 2007. All rights reserved. - class Puppet::Provider::Package < Puppet::Provider # Prefetch our package list, yo. def self.prefetch(packages) diff --git a/lib/puppet/relationship.rb b/lib/puppet/relationship.rb index 08d7d042b..2ffcd298f 100644..100755 --- a/lib/puppet/relationship.rb +++ b/lib/puppet/relationship.rb @@ -1,7 +1,4 @@ #!/usr/bin/env ruby -# -# Created by Luke A. Kanies on 2006-11-24. -# Copyright (c) 2006. All rights reserved. # subscriptions are permanent associations determining how different # objects react to an event diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index fc4926581..d3c66bc02 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -89,16 +89,18 @@ Puppet::Type.newtype(:file) do Puppet automatically creates a local filebucket named `puppet` and defaults to backing up there. To use a server-based filebucket, - you must specify one in your configuration + you must specify one in your configuration. filebucket { main: - server => puppet + server => puppet, + path => false, + # The path => false line works around a known issue with the filebucket type. } The `puppet master` daemon creates a filebucket by default, so you can usually back up to your main server with this configuration. Once you've described the bucket in your - configuration, you can use it in any file + configuration, you can use it in any file's backup attribute: file { \"/my/file\": source => \"/path/in/nfs/or/something\", @@ -107,12 +109,12 @@ Puppet::Type.newtype(:file) do This will back the file up to the central server. - At this point, the benefits of using a filebucket are that you do not - have backup files lying around on each of your machines, a given - version of a file is only backed up once, and you can restore - any given file manually, no matter how old. Eventually, - transactional support will be able to automatically restore - filebucketed files. + At this point, the benefits of using a central filebucket are that you + do not have backup files lying around on each of your machines, a given + version of a file is only backed up once, you can restore any given file + manually (no matter how old), and you can use Puppet Dashboard to view + file contents. Eventually, transactional support will be able to + automatically restore filebucketed files. " defaultto "puppet" diff --git a/lib/puppet/type/filebucket.rb b/lib/puppet/type/filebucket.rb index 7fd2ef46b..59174161b 100755 --- a/lib/puppet/type/filebucket.rb +++ b/lib/puppet/type/filebucket.rb @@ -11,15 +11,20 @@ module Puppet it can be specified as the value of *backup* in a **file** object. Currently, filebuckets are only useful for manual retrieval of - accidentally removed files (e.g., you look in the log for the md5 sum and retrieve the file with that sum from the filebucket), but - when transactions are fully supported filebuckets will be used to - undo transactions. + accidentally removed files (e.g., you look in the log for the md5 sum + and retrieve the file with that sum from the filebucket), but when + transactions are fully supported filebuckets will be used to undo + transactions. You will normally want to define a single filebucket for your whole network and then use that as the default backup location: # Define the bucket - filebucket { main: server => puppet } + filebucket { 'main': + server => puppet, + path => false, + # Due to a known issue, path must be set to false for remote filebuckets. + } # Specify it as the default target File { backup => main } @@ -36,7 +41,10 @@ module Puppet desc "The server providing the remote filebucket. If this is not specified then *path* is checked. If it is set, then the bucket is local. Otherwise the puppetmaster server specified - in the config or at the commandline is used." + in the config or at the commandline is used. + + Due to a known issue, you currently must set the `path` attribute to + false if you wish to specify a `server` attribute." defaultto { Puppet[:server] } end diff --git a/lib/puppet/util/feature.rb b/lib/puppet/util/feature.rb index 2f704104a..5a7fbf773 100644 --- a/lib/puppet/util/feature.rb +++ b/lib/puppet/util/feature.rb @@ -1,6 +1,3 @@ -# Created by Luke Kanies on 2006-11-07. -# Copyright (c) 2006. All rights reserved. - class Puppet::Util::Feature attr_reader :path diff --git a/lib/puppet/util/graph.rb b/lib/puppet/util/graph.rb index 9598d281e..58ca1ab4d 100644 --- a/lib/puppet/util/graph.rb +++ b/lib/puppet/util/graph.rb @@ -1,6 +1,3 @@ -# Created by Luke Kanies on 2006-11-16. -# Copyright (c) 2006. All rights reserved. - require 'puppet' require 'puppet/simple_graph' diff --git a/lib/puppet/util/ldap.rb b/lib/puppet/util/ldap.rb index 33f01f789..71d6a178c 100644 --- a/lib/puppet/util/ldap.rb +++ b/lib/puppet/util/ldap.rb @@ -1,5 +1,2 @@ -# -# Created by Luke Kanies on 2008-3-23. -# Copyright (c) 2008. All rights reserved. module Puppet::Util::Ldap end diff --git a/lib/puppet/util/ldap/connection.rb b/lib/puppet/util/ldap/connection.rb index 03240eae9..ee39c08c9 100644 --- a/lib/puppet/util/ldap/connection.rb +++ b/lib/puppet/util/ldap/connection.rb @@ -1,6 +1,3 @@ -# -# Created by Luke Kanies on 2008-3-23. -# Copyright (c) 2008. All rights reserved. require 'puppet/util/ldap' class Puppet::Util::Ldap::Connection diff --git a/lib/puppet/util/ldap/generator.rb b/lib/puppet/util/ldap/generator.rb index 2aaa9c370..608d72974 100644 --- a/lib/puppet/util/ldap/generator.rb +++ b/lib/puppet/util/ldap/generator.rb @@ -1,6 +1,3 @@ -# -# Created by Luke Kanies on 2008-3-28. -# Copyright (c) 2008. All rights reserved. require 'puppet/util/ldap' class Puppet::Util::Ldap::Generator diff --git a/lib/puppet/util/log_paths.rb b/lib/puppet/util/log_paths.rb index 2fefd4505..c15acb663 100644 --- a/lib/puppet/util/log_paths.rb +++ b/lib/puppet/util/log_paths.rb @@ -1,6 +1,3 @@ -# Created by Luke Kanies on 2007-07-04. -# Copyright (c) 2007. All rights reserved. - module Puppet::Util::LogPaths # return the full path to us, for logging and rollback # some classes (e.g., FileTypeRecords) will have to override this diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index caaf61b7b..3039a7b0a 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -780,6 +780,7 @@ if @config.include?(:run_mode) # Create the transportable objects for users and groups. def add_user_resources(catalog, sections) return unless Puppet.features.root? + return if Puppet.features.microsoft_windows? return unless self[:mkusers] @config.each do |name, setting| diff --git a/lib/puppet/util/settings/file_setting.rb b/lib/puppet/util/settings/file_setting.rb index 0fa65d846..f02a0c547 100644 --- a/lib/puppet/util/settings/file_setting.rb +++ b/lib/puppet/util/settings/file_setting.rb @@ -93,7 +93,8 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting if Puppet[:manage_internal_file_permissions] resource[:mode] = self.mode if self.mode - if Puppet.features.root? + # REMIND fails on Windows because chown/chgrp functionality not supported yet + if Puppet.features.root? and !Puppet.features.microsoft_windows? resource[:owner] = self.owner if self.owner resource[:group] = self.group if self.group end diff --git a/lib/puppet/util/suidmanager.rb b/lib/puppet/util/suidmanager.rb index 697bce111..d2772002e 100644 --- a/lib/puppet/util/suidmanager.rb +++ b/lib/puppet/util/suidmanager.rb @@ -37,7 +37,20 @@ module Puppet::Util::SUIDManager module_function :groups= def self.root? - Process.uid == 0 + return Process.uid == 0 unless Puppet.features.microsoft_windows? + + require 'sys/admin' + require 'win32/security' + + # if Vista or later, check for unrestricted process token + begin + return Win32::Security.elevated_security? + rescue Win32::Security::Error => e + raise e unless e.to_s =~ /Incorrect function/i + end + + group = Sys::Admin.get_group("Administrators", :sid => Win32::Security::SID::BuiltinAdministrators) + group and group.members.index(Sys::Admin.get_login) != nil end # Runs block setting uid and gid if provided then restoring original ids diff --git a/spec/integration/file_serving/content_spec.rb b/spec/integration/file_serving/content_spec.rb index e82b726fe..e2efecfa4 100755 --- a/spec/integration/file_serving/content_spec.rb +++ b/spec/integration/file_serving/content_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/file_serving/content' diff --git a/spec/integration/file_serving/metadata_spec.rb b/spec/integration/file_serving/metadata_spec.rb index 8b4d53d6b..d9aaa37f5 100755 --- a/spec/integration/file_serving/metadata_spec.rb +++ b/spec/integration/file_serving/metadata_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/file_serving/metadata' diff --git a/spec/integration/indirector/direct_file_server_spec.rb b/spec/integration/indirector/direct_file_server_spec.rb index 68ed00740..79afe7569 100755 --- a/spec/integration/indirector/direct_file_server_spec.rb +++ b/spec/integration/indirector/direct_file_server_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-19. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/file_content/file' diff --git a/spec/integration/indirector/file_content/file_server_spec.rb b/spec/integration/indirector/file_content/file_server_spec.rb index 86b75006a..3be32754f 100755 --- a/spec/integration/indirector/file_content/file_server_spec.rb +++ b/spec/integration/indirector/file_content/file_server_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/file_content/file_server' diff --git a/spec/integration/indirector/file_metadata/file_server_spec.rb b/spec/integration/indirector/file_metadata/file_server_spec.rb index 5259837fc..2e7c54b70 100755 --- a/spec/integration/indirector/file_metadata/file_server_spec.rb +++ b/spec/integration/indirector/file_metadata/file_server_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/file_metadata/file_server' diff --git a/spec/integration/node/facts_spec.rb b/spec/integration/node/facts_spec.rb index 4ec4bc821..78bdabce1 100755 --- a/spec/integration/node/facts_spec.rb +++ b/spec/integration/node/facts_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-4-8. -# Copyright (c) 2008. All rights reserved. - require 'spec_helper' describe Puppet::Node::Facts do diff --git a/spec/integration/node_spec.rb b/spec/integration/node_spec.rb index b81a1fdc3..5abb880a3 100755 --- a/spec/integration/node_spec.rb +++ b/spec/integration/node_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-9-23. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/node' diff --git a/spec/integration/reports_spec.rb b/spec/integration/reports_spec.rb index d5a08d28a..17662c810 100755 --- a/spec/integration/reports_spec.rb +++ b/spec/integration/reports_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-12. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/reports' diff --git a/spec/integration/resource/catalog_spec.rb b/spec/integration/resource/catalog_spec.rb index ae15ee453..df310b184 100755 --- a/spec/integration/resource/catalog_spec.rb +++ b/spec/integration/resource/catalog_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-4-8. -# Copyright (c) 2008. All rights reserved. - require 'spec_helper' describe Puppet::Resource::Catalog do diff --git a/spec/integration/ssl/certificate_authority_spec.rb b/spec/integration/ssl/certificate_authority_spec.rb index dc8af6a7b..a4792449e 100755 --- a/spec/integration/ssl/certificate_authority_spec.rb +++ b/spec/integration/ssl/certificate_authority_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-4-17. -# Copyright (c) 2008. All rights reserved. - require 'spec_helper' require 'puppet/ssl/certificate_authority' diff --git a/spec/integration/ssl/certificate_request_spec.rb b/spec/integration/ssl/certificate_request_spec.rb index 6c1c8b964..bcfcd2b43 100755 --- a/spec/integration/ssl/certificate_request_spec.rb +++ b/spec/integration/ssl/certificate_request_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-4-17. -# Copyright (c) 2008. All rights reserved. - require 'spec_helper' require 'puppet/ssl/certificate_request' diff --git a/spec/integration/ssl/certificate_revocation_list_spec.rb b/spec/integration/ssl/certificate_revocation_list_spec.rb index d140fd950..5912e4b98 100755 --- a/spec/integration/ssl/certificate_revocation_list_spec.rb +++ b/spec/integration/ssl/certificate_revocation_list_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-5-5. -# Copyright (c) 2008. All rights reserved. - require 'spec_helper' require 'puppet/ssl/certificate_revocation_list' diff --git a/spec/integration/ssl/host_spec.rb b/spec/integration/ssl/host_spec.rb index 94e245554..55484ad1d 100755 --- a/spec/integration/ssl/host_spec.rb +++ b/spec/integration/ssl/host_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-4-17. -# Copyright (c) 2008. All rights reserved. - require 'spec_helper' require 'puppet/ssl/host' diff --git a/spec/integration/transaction/report_spec.rb b/spec/integration/transaction/report_spec.rb index 315c0c099..8c581cc04 100755 --- a/spec/integration/transaction/report_spec.rb +++ b/spec/integration/transaction/report_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-4-8. -# Copyright (c) 2008. All rights reserved. - require 'spec_helper' describe Puppet::Transaction::Report do diff --git a/spec/shared_behaviours/file_server_terminus.rb b/spec/shared_behaviours/file_server_terminus.rb index 88ed47ebb..33037e551 100755 --- a/spec/shared_behaviours/file_server_terminus.rb +++ b/spec/shared_behaviours/file_server_terminus.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - shared_examples_for "Puppet::Indirector::FileServerTerminus" do # This only works if the shared behaviour is included before # the 'before' block in the including context. diff --git a/spec/shared_behaviours/file_serving.rb b/spec/shared_behaviours/file_serving.rb index 3afab5b59..f5a59f5cd 100755 --- a/spec/shared_behaviours/file_serving.rb +++ b/spec/shared_behaviours/file_serving.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - shared_examples_for "Puppet::FileServing::Files" do it "should use the rest terminus when the 'puppet' URI scheme is used and a host name is present" do uri = "puppet://myhost/fakemod/my/file" diff --git a/spec/shared_behaviours/memory_terminus.rb b/spec/shared_behaviours/memory_terminus.rb index f9325a969..0d9017100 100755 --- a/spec/shared_behaviours/memory_terminus.rb +++ b/spec/shared_behaviours/memory_terminus.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2008-4-8. -# Copyright (c) 2008. All rights reserved. - shared_examples_for "A Memory Terminus" do it "should find no instances by default" do @searcher.find(@request).should be_nil diff --git a/spec/unit/agent_spec.rb b/spec/unit/agent_spec.rb index bfa44f61c..d955868a0 100755 --- a/spec/unit/agent_spec.rb +++ b/spec/unit/agent_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-11-12. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/agent' diff --git a/spec/unit/configurer_spec.rb b/spec/unit/configurer_spec.rb index 588f1659b..c20c89e03 100755 --- a/spec/unit/configurer_spec.rb +++ b/spec/unit/configurer_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-11-12. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/configurer' diff --git a/spec/unit/file_serving/indirection_hooks_spec.rb b/spec/unit/file_serving/indirection_hooks_spec.rb index 4890505ab..526c49e0f 100755 --- a/spec/unit/file_serving/indirection_hooks_spec.rb +++ b/spec/unit/file_serving/indirection_hooks_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/file_serving/indirection_hooks' diff --git a/spec/unit/file_serving/terminus_helper_spec.rb b/spec/unit/file_serving/terminus_helper_spec.rb index 7efe3fb98..9fd27d9dc 100755 --- a/spec/unit/file_serving/terminus_helper_spec.rb +++ b/spec/unit/file_serving/terminus_helper_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-22. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/file_serving/terminus_helper' diff --git a/spec/unit/indirector/catalog/compiler_spec.rb b/spec/unit/indirector/catalog/compiler_spec.rb index cd84031e5..ea0e98e80 100755 --- a/spec/unit/indirector/catalog/compiler_spec.rb +++ b/spec/unit/indirector/catalog/compiler_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-9-23. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/catalog/compiler' diff --git a/spec/unit/indirector/certificate/ca_spec.rb b/spec/unit/indirector/certificate/ca_spec.rb index 277d2209d..25bd4dcbf 100755 --- a/spec/unit/indirector/certificate/ca_spec.rb +++ b/spec/unit/indirector/certificate/ca_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-7. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/certificate/ca' diff --git a/spec/unit/indirector/certificate/file_spec.rb b/spec/unit/indirector/certificate/file_spec.rb index f398e1115..67b83589e 100755 --- a/spec/unit/indirector/certificate/file_spec.rb +++ b/spec/unit/indirector/certificate/file_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-7. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/certificate/file' diff --git a/spec/unit/indirector/certificate_request/ca_spec.rb b/spec/unit/indirector/certificate_request/ca_spec.rb index 36628df9d..9c74f09d1 100755 --- a/spec/unit/indirector/certificate_request/ca_spec.rb +++ b/spec/unit/indirector/certificate_request/ca_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-7. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/ssl/host' diff --git a/spec/unit/indirector/certificate_request/file_spec.rb b/spec/unit/indirector/certificate_request/file_spec.rb index 69dc5eb9c..654cd23f8 100755 --- a/spec/unit/indirector/certificate_request/file_spec.rb +++ b/spec/unit/indirector/certificate_request/file_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-7. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/certificate_request/file' diff --git a/spec/unit/indirector/certificate_revocation_list/ca_spec.rb b/spec/unit/indirector/certificate_revocation_list/ca_spec.rb index d76373b97..005b5aa1d 100755 --- a/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +++ b/spec/unit/indirector/certificate_revocation_list/ca_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-7. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/certificate_revocation_list/ca' diff --git a/spec/unit/indirector/certificate_revocation_list/file_spec.rb b/spec/unit/indirector/certificate_revocation_list/file_spec.rb index f4b8c36d3..380290079 100755 --- a/spec/unit/indirector/certificate_revocation_list/file_spec.rb +++ b/spec/unit/indirector/certificate_revocation_list/file_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-7. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/certificate_revocation_list/file' diff --git a/spec/unit/indirector/direct_file_server_spec.rb b/spec/unit/indirector/direct_file_server_spec.rb index abd7172b7..87380438a 100755 --- a/spec/unit/indirector/direct_file_server_spec.rb +++ b/spec/unit/indirector/direct_file_server_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-24. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/direct_file_server' diff --git a/spec/unit/indirector/facts/facter_spec.rb b/spec/unit/indirector/facts/facter_spec.rb index 9f5a0249b..3b1574e52 100755 --- a/spec/unit/indirector/facts/facter_spec.rb +++ b/spec/unit/indirector/facts/facter_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-9-23. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/facts/facter' diff --git a/spec/unit/indirector/file_content/file_server_spec.rb b/spec/unit/indirector/file_content/file_server_spec.rb index 99a535dc3..6b09216d7 100755 --- a/spec/unit/indirector/file_content/file_server_spec.rb +++ b/spec/unit/indirector/file_content/file_server_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/file_content/file_server' diff --git a/spec/unit/indirector/file_content/file_spec.rb b/spec/unit/indirector/file_content/file_spec.rb index b629981c5..d1c6dc738 100755 --- a/spec/unit/indirector/file_content/file_spec.rb +++ b/spec/unit/indirector/file_content/file_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/file_content/file' diff --git a/spec/unit/indirector/file_metadata/file_server_spec.rb b/spec/unit/indirector/file_metadata/file_server_spec.rb index e16829035..14177d702 100755 --- a/spec/unit/indirector/file_metadata/file_server_spec.rb +++ b/spec/unit/indirector/file_metadata/file_server_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/file_metadata/file_server' diff --git a/spec/unit/indirector/file_metadata/file_spec.rb b/spec/unit/indirector/file_metadata/file_spec.rb index 28a974290..9df53384b 100755 --- a/spec/unit/indirector/file_metadata/file_spec.rb +++ b/spec/unit/indirector/file_metadata/file_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/file_metadata/file' diff --git a/spec/unit/indirector/file_server_spec.rb b/spec/unit/indirector/file_server_spec.rb index 96fe101d5..8f7a5d1b3 100755 --- a/spec/unit/indirector/file_server_spec.rb +++ b/spec/unit/indirector/file_server_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-10-19. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/file_server' diff --git a/spec/unit/indirector/key/ca_spec.rb b/spec/unit/indirector/key/ca_spec.rb index ba3d1aae2..990adc975 100755 --- a/spec/unit/indirector/key/ca_spec.rb +++ b/spec/unit/indirector/key/ca_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-7. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/key/ca' diff --git a/spec/unit/indirector/key/file_spec.rb b/spec/unit/indirector/key/file_spec.rb index bf9b293d8..f9abb958f 100755 --- a/spec/unit/indirector/key/file_spec.rb +++ b/spec/unit/indirector/key/file_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-7. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/key/file' diff --git a/spec/unit/indirector/report/processor_spec.rb b/spec/unit/indirector/report/processor_spec.rb index c64cc7eff..6184cb9b5 100755 --- a/spec/unit/indirector/report/processor_spec.rb +++ b/spec/unit/indirector/report/processor_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-9-23. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/report/processor' diff --git a/spec/unit/indirector/ssl_file_spec.rb b/spec/unit/indirector/ssl_file_spec.rb index 1a837f646..8ee19c8c8 100755 --- a/spec/unit/indirector/ssl_file_spec.rb +++ b/spec/unit/indirector/ssl_file_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-10. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/indirector/ssl_file' @@ -23,7 +19,7 @@ describe Puppet::Indirector::SslFile do @setting = :certdir @file_class.store_in @setting - @path = make_absolute("/tmp/my_directory") + @path = make_absolute("/thisdoesntexist/my_directory") Puppet[:noop] = false Puppet[@setting] = @path Puppet[:trace] = false @@ -47,7 +43,9 @@ describe Puppet::Indirector::SslFile do it "should fail if no store directory or file location has been set" do @file_class.store_in nil @file_class.store_at nil - lambda { @file_class.new }.should raise_error(Puppet::DevError) + FileTest.expects(:exists?).with(File.dirname(@path)).at_least(0).returns(true) + Dir.stubs(:mkdir).with(@path) + lambda { @file_class.new }.should raise_error(Puppet::DevError, /No file or directory setting provided/) end describe "when managing ssl files" do diff --git a/spec/unit/network/http/mongrel_spec.rb b/spec/unit/network/http/mongrel_spec.rb index 6776fad61..9e7e9c485 100755 --- a/spec/unit/network/http/mongrel_spec.rb +++ b/spec/unit/network/http/mongrel_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Rick Bradley on 2007-10-15. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/network/http' diff --git a/spec/unit/network/http/webrick_spec.rb b/spec/unit/network/http/webrick_spec.rb index 8504b02e3..f84e78e24 100755 --- a/spec/unit/network/http/webrick_spec.rb +++ b/spec/unit/network/http/webrick_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Rick Bradley on 2007-10-15. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/network/handler' require 'puppet/network/http' diff --git a/spec/unit/network/http_pool_spec.rb b/spec/unit/network/http_pool_spec.rb index 1961f3029..c86f7a660 100755 --- a/spec/unit/network/http_pool_spec.rb +++ b/spec/unit/network/http_pool_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-11-26. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/network/http_pool' diff --git a/spec/unit/network/http_spec.rb b/spec/unit/network/http_spec.rb index 550c15bf7..3f807a50b 100755 --- a/spec/unit/network/http_spec.rb +++ b/spec/unit/network/http_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Rick Bradley on 2007-10-03. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/network/http' diff --git a/spec/unit/network/server_spec.rb b/spec/unit/network/server_spec.rb index 912275a20..b38e82b93 100755 --- a/spec/unit/network/server_spec.rb +++ b/spec/unit/network/server_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Rick Bradley on 2007-10-03. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/network/server' require 'puppet/network/handler' diff --git a/spec/unit/provider/group/ldap_spec.rb b/spec/unit/provider/group/ldap_spec.rb index 947007f10..28a57e0ee 100755 --- a/spec/unit/provider/group/ldap_spec.rb +++ b/spec/unit/provider/group/ldap_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-10. -# Copyright (c) 2006. All rights reserved. - require 'spec_helper' provider_class = Puppet::Type.type(:group).provider(:ldap) diff --git a/spec/unit/provider/ldap_spec.rb b/spec/unit/provider/ldap_spec.rb index 012a22b99..913e81fb9 100755 --- a/spec/unit/provider/ldap_spec.rb +++ b/spec/unit/provider/ldap_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-21. -# Copyright (c) 2006. All rights reserved. - require 'spec_helper' require 'puppet/provider/ldap' diff --git a/spec/unit/provider/mount/parsed_spec.rb b/spec/unit/provider/mount/parsed_spec.rb index fdee2efab..c86525707 100755 --- a/spec/unit/provider/mount/parsed_spec.rb +++ b/spec/unit/provider/mount/parsed_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-9-12. -# Copyright (c) 2006. All rights reserved. - require 'spec_helper' require 'shared_behaviours/all_parsedfile_providers' diff --git a/spec/unit/provider/user/ldap_spec.rb b/spec/unit/provider/user/ldap_spec.rb index 065b3b423..8888d85ed 100755 --- a/spec/unit/provider/user/ldap_spec.rb +++ b/spec/unit/provider/user/ldap_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-10. -# Copyright (c) 2006. All rights reserved. - require 'spec_helper' provider_class = Puppet::Type.type(:user).provider(:ldap) diff --git a/spec/unit/relationship_spec.rb b/spec/unit/relationship_spec.rb index a7e787b46..1a748beff 100755 --- a/spec/unit/relationship_spec.rb +++ b/spec/unit/relationship_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-11-1. -# Copyright (c) 2006. All rights reserved. - require 'spec_helper' require 'puppet/relationship' diff --git a/spec/unit/simple_graph_spec.rb b/spec/unit/simple_graph_spec.rb index 17e382fcc..8a39c782c 100755 --- a/spec/unit/simple_graph_spec.rb +++ b/spec/unit/simple_graph_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-11-1. -# Copyright (c) 2006. All rights reserved. - require 'spec_helper' require 'puppet/simple_graph' diff --git a/spec/unit/util/checksums_spec.rb b/spec/unit/util/checksums_spec.rb index 146544201..f8800b512 100755 --- a/spec/unit/util/checksums_spec.rb +++ b/spec/unit/util/checksums_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-9-22. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/util/checksums' diff --git a/spec/unit/util/constant_inflector_spec.rb b/spec/unit/util/constant_inflector_spec.rb index cf2e8f892..88c1d9aa3 100755 --- a/spec/unit/util/constant_inflector_spec.rb +++ b/spec/unit/util/constant_inflector_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-02-12. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/util/constant_inflector' diff --git a/spec/unit/util/ldap/connection_spec.rb b/spec/unit/util/ldap/connection_spec.rb index f97c72d77..f02ea10cb 100755 --- a/spec/unit/util/ldap/connection_spec.rb +++ b/spec/unit/util/ldap/connection_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-19. -# Copyright (c) 2006. All rights reserved. - require 'spec_helper' require 'puppet/util/ldap/connection' diff --git a/spec/unit/util/ldap/generator_spec.rb b/spec/unit/util/ldap/generator_spec.rb index b3e664d6b..51285e233 100755 --- a/spec/unit/util/ldap/generator_spec.rb +++ b/spec/unit/util/ldap/generator_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-28. -# Copyright (c) 2008. All rights reserved. - require 'spec_helper' require 'puppet/util/ldap/generator' diff --git a/spec/unit/util/ldap/manager_spec.rb b/spec/unit/util/ldap/manager_spec.rb index 5cce626b5..16c6b0601 100755 --- a/spec/unit/util/ldap/manager_spec.rb +++ b/spec/unit/util/ldap/manager_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-3-19. -# Copyright (c) 2006. All rights reserved. - require 'spec_helper' require 'puppet/util/ldap/manager' diff --git a/spec/unit/util/nagios_maker_spec.rb b/spec/unit/util/nagios_maker_spec.rb index b61f4fe9d..9cd038ff3 100755 --- a/spec/unit/util/nagios_maker_spec.rb +++ b/spec/unit/util/nagios_maker_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2007-11-18. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/util/nagios_maker' diff --git a/spec/unit/util/settings/file_setting_spec.rb b/spec/unit/util/settings/file_setting_spec.rb index 01d891f08..6344cf1b5 100755 --- a/spec/unit/util/settings/file_setting_spec.rb +++ b/spec/unit/util/settings/file_setting_spec.rb @@ -189,6 +189,8 @@ describe Puppet::Util::Settings::FileSetting do it "should set the owner if running as root and the owner is provided" do Puppet.features.expects(:root?).returns true + Puppet.features.stubs(:microsoft_windows?).returns false + @file.stubs(:owner).returns "foo" @file.to_resource[:owner].should == "foo" end @@ -203,6 +205,8 @@ describe Puppet::Util::Settings::FileSetting do it "should set the group if running as root and the group is provided" do Puppet.features.expects(:root?).returns true + Puppet.features.stubs(:microsoft_windows?).returns false + @file.stubs(:group).returns "foo" @file.to_resource[:group].should == "foo" end @@ -218,16 +222,34 @@ describe Puppet::Util::Settings::FileSetting do it "should not set owner if not running as root" do Puppet.features.expects(:root?).returns false + Puppet.features.stubs(:microsoft_windows?).returns false @file.stubs(:owner).returns "foo" @file.to_resource[:owner].should be_nil end it "should not set group if not running as root" do Puppet.features.expects(:root?).returns false + Puppet.features.stubs(:microsoft_windows?).returns false @file.stubs(:group).returns "foo" @file.to_resource[:group].should be_nil end + describe "on Microsoft Windows systems" do + before :each do + Puppet.features.stubs(:microsoft_windows?).returns true + end + + it "should not set owner" do + @file.stubs(:owner).returns "foo" + @file.to_resource[:owner].should be_nil + end + + it "should not set group" do + @file.stubs(:group).returns "foo" + @file.to_resource[:group].should be_nil + end + end + it "should set :ensure to the file type" do @file.expects(:type).returns :directory @file.to_resource[:ensure].should == :directory diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb index 76f229c0f..69c117f28 100755 --- a/spec/unit/util/settings_spec.rb +++ b/spec/unit/util/settings_spec.rb @@ -720,9 +720,28 @@ describe Puppet::Util::Settings do @settings.to_catalog end + describe "on Microsoft Windows" do + before :each do + Puppet.features.stubs(:root?).returns true + Puppet.features.stubs(:microsoft_windows?).returns true + + @settings.setdefaults :foo, :mkusers => [true, "e"], :user => ["suser", "doc"], :group => ["sgroup", "doc"] + @settings.setdefaults :other, :otherdir => {:default => "/otherdir", :desc => "a", :owner => "service", :group => "service"} + + @catalog = @settings.to_catalog + end + + it "it should not add users and groups to the catalog" do + @catalog.resource(:user, "suser").should be_nil + @catalog.resource(:group, "sgroup").should be_nil + end + end + describe "when adding users and groups to the catalog" do before do Puppet.features.stubs(:root?).returns true + Puppet.features.stubs(:microsoft_windows?).returns false + @settings.setdefaults :foo, :mkusers => [true, "e"], :user => ["suser", "doc"], :group => ["sgroup", "doc"] @settings.setdefaults :other, :otherdir => {:default => "/otherdir", :desc => "a", :owner => "service", :group => "service"} diff --git a/spec/unit/util/suidmanager_spec.rb b/spec/unit/util/suidmanager_spec.rb index abfe3f723..474d0b2a2 100755 --- a/spec/unit/util/suidmanager_spec.rb +++ b/spec/unit/util/suidmanager_spec.rb @@ -66,6 +66,14 @@ describe Puppet::Util::SUIDManager do xids.should be_empty end + + it "should not get or set euid/egid on Windows" do + Puppet.features.stubs(:microsoft_windows?).returns true + + Puppet::Util::SUIDManager.asuser(user[:uid], user[:gid]) {} + + xids.should be_empty + end end describe "#change_group" do @@ -195,6 +203,15 @@ describe Puppet::Util::SUIDManager do xids.should be_empty end + + it "should not get or set euid/egid on Windows" do + Puppet.features.stubs(:microsoft_windows?).returns true + Kernel.expects(:system).with('blah') + + Puppet::Util::SUIDManager.system('blah', user[:uid], user[:gid]) + + xids.should be_empty + end end describe "with #run_and_capture" do @@ -210,4 +227,76 @@ describe Puppet::Util::SUIDManager do end end end + + describe "#root?" do + describe "on POSIX systems" do + before :each do + Puppet.features.stubs(:posix?).returns(true) + Puppet.features.stubs(:microsoft_windows?).returns(false) + end + + it "should be root if uid is 0" do + Process.stubs(:uid).returns(0) + + Puppet::Util::SUIDManager.should be_root + end + + it "should not be root if uid is not 0" do + Process.stubs(:uid).returns(1) + + Puppet::Util::SUIDManager.should_not be_root + end + end + + describe "on Microsoft Windows", :if => Puppet.features.microsoft_windows? do + describe "2003 without UAC" do + it "should be root if user is a member of the Administrators group" do + Win32::Security.stubs(:elevated_security?).raises(Win32::Security::Error, "Incorrect function.") + Sys::Admin.stubs(:get_login).returns("Administrator") + Sys::Group.stubs(:members).returns(%w[Administrator]) + + Puppet::Util::SUIDManager.should be_root + end + + it "should not be root if the process is running as Guest" do + Win32::Security.stubs(:elevated_security?).raises(Win32::Security::Error, "Incorrect function.") + Sys::Admin.stubs(:get_login).returns("Guest") + Sys::Group.stubs(:members).returns([]) + + Puppet::Util::SUIDManager.should_not be_root + end + + it "should raise an exception if the process fails to open the process token" do + Win32::Security.stubs(:elevated_security?).raises(Win32::Security::Error, "Access denied.") + Sys::Admin.stubs(:get_login).returns("Administrator") + Sys::Group.expects(:members).never + + lambda { Puppet::Util::SUIDManager.should raise_error(Win32::Security::Error, /Access denied./) } + end + end + + describe "2008 with UAC" do + it "should be root if user is running with elevated privileges" do + Win32::Security.stubs(:elevated_security?).returns(true) + Sys::Admin.expects(:get_login).never + + Puppet::Util::SUIDManager.should be_root + end + + it "should not be root if user is not running with elevated privileges" do + Win32::Security.stubs(:elevated_security?).returns(false) + Sys::Admin.expects(:get_login).never + + Puppet::Util::SUIDManager.should_not be_root + end + + it "should raise an exception if the process fails to open the process token" do + Win32::Security.stubs(:elevated_security?).raises(Win32::Security::Error, "Access denied.") + Sys::Admin.expects(:get_login).never + + lambda { Puppet::Util::SUIDManager.should raise_error(Win32::Security::Error, /Access denied./) } + end + end + end + end end diff --git a/spec/unit/util/tagging_spec.rb b/spec/unit/util/tagging_spec.rb index 018871bef..1e5abdadd 100755 --- a/spec/unit/util/tagging_spec.rb +++ b/spec/unit/util/tagging_spec.rb @@ -1,8 +1,4 @@ #!/usr/bin/env rspec -# -# Created by Luke Kanies on 2008-01-19. -# Copyright (c) 2007. All rights reserved. - require 'spec_helper' require 'puppet/util/tagging' diff --git a/test/lib/puppettest/support/resources.rb b/test/lib/puppettest/support/resources.rb index 2b922bb1e..d5bf98f91 100755 --- a/test/lib/puppettest/support/resources.rb +++ b/test/lib/puppettest/support/resources.rb @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -# -# Created by Luke A. Kanies on 2006-11-29. -# Copyright (c) 2006. All rights reserved. - module PuppetTest::Support::Resources def tree_resource(name) Puppet::Type.type(:file).new :title => name, :path => "/tmp/#{name}", :mode => 0755 diff --git a/test/lib/puppettest/testcase.rb b/test/lib/puppettest/testcase.rb index b1b22e524..0ec98846c 100644..100755 --- a/test/lib/puppettest/testcase.rb +++ b/test/lib/puppettest/testcase.rb @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -# -# Created by Luke A. Kanies on 2007-03-05. -# Copyright (c) 2007. All rights reserved. - require 'puppettest' require 'puppettest/runnable_test' require 'test/unit' diff --git a/test/ral/manager/attributes.rb b/test/ral/manager/attributes.rb index 030f38c50..8b0b8df95 100755 --- a/test/ral/manager/attributes.rb +++ b/test/ral/manager/attributes.rb @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -# -# Created by Luke A. Kanies on 2007-02-05. -# Copyright (c) 2007. All rights reserved. - require File.expand_path(File.dirname(__FILE__) + '/../../lib/puppettest') require 'puppettest' diff --git a/test/ral/manager/instances.rb b/test/ral/manager/instances.rb index f1731ac64..f59f43da1 100755 --- a/test/ral/manager/instances.rb +++ b/test/ral/manager/instances.rb @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -# -# Created by Luke A. Kanies on 2007-06-10. -# Copyright (c) 2007. All rights reserved. - require File.expand_path(File.dirname(__FILE__) + '/../../lib/puppettest') require 'puppettest' diff --git a/test/ral/manager/manager.rb b/test/ral/manager/manager.rb index 9c9449a45..e42c6c293 100755 --- a/test/ral/manager/manager.rb +++ b/test/ral/manager/manager.rb @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -# -# Created by Luke A. Kanies on 2006-11-29. -# Copyright (c) 2006. All rights reserved. - require File.expand_path(File.dirname(__FILE__) + '/../../lib/puppettest') require 'puppettest' diff --git a/test/ral/providers/service/base.rb b/test/ral/providers/service/base.rb index 112246b12..1b5a63e7d 100755 --- a/test/ral/providers/service/base.rb +++ b/test/ral/providers/service/base.rb @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -# -# Created by Luke A. Kanies on 2007-01-28. -# Copyright (c) 2007. All rights reserved. - require File.expand_path(File.dirname(__FILE__) + '/../../../lib/puppettest') require 'puppettest' diff --git a/test/ral/type/resources.rb b/test/ral/type/resources.rb index fcfeebe10..21604ba8e 100755 --- a/test/ral/type/resources.rb +++ b/test/ral/type/resources.rb @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -# -# Created by Luke Kanies on 2006-12-12. -# Copyright (c) 2006. All rights reserved. - require File.expand_path(File.dirname(__FILE__) + '/../../lib/puppettest') require 'puppettest' |