puppet 3.7.0-x86-mingw32 → 3.7.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b499bf329edff2d3a45bddcd5d8e15f3933c8450
4
- data.tar.gz: a6679453c13c2dfd024808235297609f7d8097fa
3
+ metadata.gz: 11643b2ba3ae867dcc1536ffbbfc18e74e0dc53f
4
+ data.tar.gz: 47c0c75fdc99552959a4da7363cb6f8ba9622eb7
5
5
  SHA512:
6
- metadata.gz: fd36a58224669735636d56d21b7329665460096bfda7f9c7925413e18a45fb61167f45e732d347421e47cbb06fb7b1cc4e6c6b1b0c1973be084dff46016e6793
7
- data.tar.gz: 221c149508d7fcc256898a268106c2f7def9e5595a2b485df90707031da17b58a849b1e61819c2b7b426a7a2ca9004e24f5a36dc2f364aa0aa7eeff3cdd3fb25
6
+ metadata.gz: 7b36af820295fc984993d8ef86377cd7658dcf80f0f639e28050954ebc89bc3a86caf78785f5c3fefcdc46e74e99a25656c8698f77b0d818317cf75c18208867
7
+ data.tar.gz: 08c59bc5181ec364fbf5187436347a8b9f849c1e2ae59b328333ed68cc3e99f440a05f653b2fe5cb5caf773205e92239340335174c61569485f846c17e5c1fad
data/Gemfile CHANGED
@@ -23,7 +23,9 @@ platforms :ruby do
23
23
  #gem 'ruby-augeas', :group => :development
24
24
  end
25
25
 
26
- gem "puppet", :path => File.dirname(__FILE__), :require => false
26
+ if !ENV['PUPPET_LOADED']
27
+ gem "puppet", :path => File.dirname(__FILE__), :require => false
28
+ end
27
29
  gem "facter", *location_for(ENV['FACTER_LOCATION'] || ['> 1.6', '< 3'])
28
30
  gem "hiera", *location_for(ENV['HIERA_LOCATION'] || '~> 1.0')
29
31
  gem "rake", "10.1.1", :require => false
@@ -1056,13 +1056,6 @@ EOT
1056
1056
 
1057
1057
  In either case, the path can point to a single file or to a directory of
1058
1058
  manifests to be evaluated in alphabetical order.",
1059
- :hook => proc do |value|
1060
- uninterpolated_value = self.value(true)
1061
- if uninterpolated_value =~ /\$environment/ || value =~ /\$environment/ then
1062
- raise(Puppet::Settings::ValidationError,
1063
- "You cannot interpolate '$environment' within the 'default_manifest' setting.")
1064
- end
1065
- end
1066
1059
  },
1067
1060
  :disable_per_environment_manifest => {
1068
1061
  :default => false,
@@ -46,7 +46,7 @@ module Puppet::ModuleTool
46
46
  tmpdirpath = Pathname.new tmpdir
47
47
 
48
48
  symlinks.each do |s|
49
- Puppet.warning "Symlinks in modules are unsupported. Please investigate symlink #{s.relative_path_from tmpdirpath}->#{s.realpath.relative_path_from tmpdirpath}."
49
+ Puppet.warning "Symlinks in modules are unsupported. Please investigate symlink #{s.relative_path_from tmpdirpath}->#{Puppet::FileSystem.readlink(s)}."
50
50
  end
51
51
  end
52
52
 
@@ -46,7 +46,11 @@ module Puppet::Network::HTTP::Compression
46
46
  end
47
47
 
48
48
  def add_accept_encoding(headers={})
49
- headers['accept-encoding'] = 'gzip; q=1.0, deflate; q=1.0; identity' if Puppet.settings[:http_compression]
49
+ if Puppet.settings[:http_compression]
50
+ headers['accept-encoding'] = 'gzip; q=1.0, deflate; q=1.0; identity'
51
+ else
52
+ headers['accept-encoding'] = 'identity'
53
+ end
50
54
  headers
51
55
  end
52
56
 
@@ -75,7 +75,7 @@ module Puppet::Pops::Loader::LoaderPaths
75
75
  end
76
76
 
77
77
  class FunctionPath4x < RubySmartPath
78
- FUNCTION_PATH_4X = File.join('lib', 'puppet', 'functions')
78
+ FUNCTION_PATH_4X = File.join('puppet', 'functions')
79
79
 
80
80
  def relative_path
81
81
  FUNCTION_PATH_4X
@@ -20,6 +20,28 @@
20
20
  # @api private
21
21
  #
22
22
  module Puppet::Pops::Loader::ModuleLoaders
23
+ def self.system_loader_from(parent_loader, loaders)
24
+ # Puppet system may be installed in a fixed location via RPM, installed as a Gem, via source etc.
25
+ # The only way to find this across the different ways puppet can be installed is
26
+ # to search up the path from this source file's __FILE__ location until it finds the base of
27
+ # puppet.
28
+ #
29
+ puppet_lib = File.join(File.dirname(__FILE__), '../../..')
30
+ Puppet::Pops::Loader::ModuleLoaders::FileBased.new(parent_loader,
31
+ loaders,
32
+ nil,
33
+ puppet_lib,
34
+ 'puppet_system')
35
+ end
36
+
37
+ def self.module_loader_from(parent_loader, loaders, module_name, module_path)
38
+ Puppet::Pops::Loader::ModuleLoaders::FileBased.new(parent_loader,
39
+ loaders,
40
+ module_name,
41
+ File.join(module_path, 'lib'),
42
+ module_name)
43
+ end
44
+
23
45
  class AbstractPathBasedModuleLoader < Puppet::Pops::Loader::BaseLoader
24
46
 
25
47
  # The name of the module, or nil, if this is a global "component"
@@ -47,11 +69,6 @@ module Puppet::Pops::Loader::ModuleLoaders
47
69
  def initialize(parent_loader, loaders, module_name, path, loader_name)
48
70
  super parent_loader, loader_name
49
71
 
50
- # Irrespective of the path referencing a directory or file, the path must exist.
51
- unless Puppet::FileSystem.exist?(path)
52
- raise ArgumentError, "The given path '#{path}' does not exist!"
53
- end
54
-
55
72
  @module_name = module_name
56
73
  @path = path
57
74
  @smart_paths = Puppet::Pops::Loader::LoaderPaths::SmartPaths.new(self)
@@ -178,9 +195,6 @@ module Puppet::Pops::Loader::ModuleLoaders
178
195
  #
179
196
  def initialize(parent_loader, loaders, module_name, path, loader_name)
180
197
  super
181
- unless Puppet::FileSystem.directory?(path)
182
- raise ArgumentError, "The given module root path '#{path}' is not a directory (required for file system based module path entry)"
183
- end
184
198
  @path_index = Set.new()
185
199
  end
186
200
 
@@ -64,16 +64,7 @@ class Puppet::Pops::Loaders
64
64
  private
65
65
 
66
66
  def create_puppet_system_loader()
67
- module_name = nil
68
- loader_name = 'puppet_system'
69
-
70
- # Puppet system may be installed in a fixed location via RPM, installed as a Gem, via source etc.
71
- # The only way to find this across the different ways puppet can be installed is
72
- # to search up the path from this source file's __FILE__ location until it finds the parent of
73
- # lib/puppet... e.g.. dirname(__FILE__)/../../.. (i.e. <somewhere>/lib/puppet/pops/loaders.rb).
74
- #
75
- puppet_lib = File.join(File.dirname(__FILE__), '../../..')
76
- Puppet::Pops::Loader::ModuleLoaders::FileBased.new(static_loader, self, module_name, puppet_lib, loader_name)
67
+ Puppet::Pops::Loader::ModuleLoaders.system_loader_from(static_loader, self)
77
68
  end
78
69
 
79
70
  def create_environment_loader(environment)
@@ -121,7 +112,7 @@ class Puppet::Pops::Loaders
121
112
  # Create data about this module
122
113
  md = LoaderModuleData.new(puppet_module)
123
114
  mr[puppet_module.name] = md
124
- md.public_loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(parent_loader, self, md.name, md.path, md.name)
115
+ md.public_loader = Puppet::Pops::Loader::ModuleLoaders.module_loader_from(parent_loader, self, md.name, md.path)
125
116
  end
126
117
  # NOTE: Do not resolve all modules here - this is wasteful if only a subset of modules / functions are used
127
118
  # The resolution is triggered by asking for a module's private loader, since this means there is interest
@@ -21,21 +21,21 @@ Puppet::Type.type(:service).provide :windows, :parent => :service do
21
21
  def enable
22
22
  w32ss = Win32::Service.configure( 'service_name' => @resource[:name], 'start_type' => Win32::Service::SERVICE_AUTO_START )
23
23
  raise Puppet::Error.new("Win32 service enable of #{@resource[:name]} failed" ) if( w32ss.nil? )
24
- rescue Win32::Service::Error => detail
24
+ rescue => detail
25
25
  raise Puppet::Error.new("Cannot enable #{@resource[:name]}, error was: #{detail}", detail )
26
26
  end
27
27
 
28
28
  def disable
29
29
  w32ss = Win32::Service.configure( 'service_name' => @resource[:name], 'start_type' => Win32::Service::SERVICE_DISABLED )
30
30
  raise Puppet::Error.new("Win32 service disable of #{@resource[:name]} failed" ) if( w32ss.nil? )
31
- rescue Win32::Service::Error => detail
31
+ rescue => detail
32
32
  raise Puppet::Error.new("Cannot disable #{@resource[:name]}, error was: #{detail}", detail )
33
33
  end
34
34
 
35
35
  def manual_start
36
36
  w32ss = Win32::Service.configure( 'service_name' => @resource[:name], 'start_type' => Win32::Service::SERVICE_DEMAND_START )
37
37
  raise Puppet::Error.new("Win32 service manual enable of #{@resource[:name]} failed" ) if( w32ss.nil? )
38
- rescue Win32::Service::Error => detail
38
+ rescue => detail
39
39
  raise Puppet::Error.new("Cannot enable #{@resource[:name]} for manual start, error was: #{detail}", detail )
40
40
  end
41
41
 
@@ -55,7 +55,7 @@ Puppet::Type.type(:service).provide :windows, :parent => :service do
55
55
  else
56
56
  raise Puppet::Error.new("Unknown start type: #{w32ss.start_type}")
57
57
  end
58
- rescue Win32::Service::Error => detail
58
+ rescue => detail
59
59
  raise Puppet::Error.new("Cannot get start type for #{@resource[:name]}, error was: #{detail}", detail )
60
60
  end
61
61
 
@@ -95,7 +95,7 @@ Puppet::Type.type(:service).provide :windows, :parent => :service do
95
95
  end
96
96
  debug("Service #{@resource[:name]} is #{w32ss.current_state}")
97
97
  return state
98
- rescue Win32::Service::Error => detail
98
+ rescue => detail
99
99
  raise Puppet::Error.new("Cannot get status of #{@resource[:name]}, error was: #{detail}", detail )
100
100
  end
101
101
 
@@ -551,10 +551,12 @@ class Puppet::Resource
551
551
  end
552
552
 
553
553
  def extract_type_and_title(argtype, argtitle)
554
- if (argtitle || argtype) =~ /^([^\[\]]+)\[(.+)\]$/m then [ $1, $2 ]
555
- elsif argtitle then [ argtype, argtitle ]
556
- elsif argtype.is_a?(Puppet::Type) then [ argtype.class.name, argtype.title ]
557
- elsif argtype.is_a?(Hash) then
554
+ if (argtype.nil? || argtype == :component || argtype == :whit) &&
555
+ argtitle =~ /^([^\[\]]+)\[(.+)\]$/m then [ $1, $2 ]
556
+ elsif argtitle.nil? && argtype =~ /^([^\[\]]+)\[(.+)\]$/m then [ $1, $2 ]
557
+ elsif argtitle then [ argtype, argtitle ]
558
+ elsif argtype.is_a?(Puppet::Type) then [ argtype.class.name, argtype.title ]
559
+ elsif argtype.is_a?(Hash) then
558
560
  raise ArgumentError, "Puppet::Resource.new does not take a hash as the first argument. "+
559
561
  "Did you mean (#{(argtype[:type] || argtype["type"]).inspect}, #{(argtype[:title] || argtype["title"]).inspect }) ?"
560
562
  else raise ArgumentError, "No title provided and #{argtype.inspect} is not a valid resource reference"
@@ -887,8 +887,8 @@ class Puppet::Settings
887
887
  sections = nil if sections.empty?
888
888
 
889
889
  catalog = Puppet::Resource::Catalog.new("Settings", Puppet::Node::Environment::NONE)
890
-
891
890
  @config.keys.find_all { |key| @config[key].is_a?(FileSetting) }.each do |key|
891
+ next if (key == :manifestdir && should_skip_manifestdir?())
892
892
  file = @config[key]
893
893
  next unless (sections.nil? or sections.include?(file.section))
894
894
  next unless resource = file.to_resource
@@ -905,6 +905,13 @@ class Puppet::Settings
905
905
  catalog
906
906
  end
907
907
 
908
+ def should_skip_manifestdir?()
909
+ setting = @config[:environmentpath]
910
+ !(setting.nil? || setting.value.nil? || setting.value.empty?)
911
+ end
912
+
913
+ private :should_skip_manifestdir?
914
+
908
915
  # Convert our list of config settings into a configuration file.
909
916
  def to_config
910
917
  str = %{The configuration file for #{Puppet.run_mode.name}. Note that this file
@@ -1130,11 +1137,13 @@ Generated on #{Time.now}.
1130
1137
  configured_environment = self[:environment]
1131
1138
  if configured_environment == "production" && envdir && Puppet::FileSystem.exist?(envdir)
1132
1139
  configured_environment_path = File.join(envdir, configured_environment)
1133
- catalog.add_resource(
1134
- Puppet::Resource.new(:file,
1135
- configured_environment_path,
1136
- :parameters => { :ensure => 'directory' })
1137
- )
1140
+ if !Puppet::FileSystem.symlink?(configured_environment_path)
1141
+ catalog.add_resource(
1142
+ Puppet::Resource.new(:file,
1143
+ configured_environment_path,
1144
+ :parameters => { :ensure => 'directory' })
1145
+ )
1146
+ end
1138
1147
  end
1139
1148
  end
1140
1149
 
@@ -1232,6 +1241,7 @@ Generated on #{Time.now}.
1232
1241
  # @api public
1233
1242
  class ChainedValues
1234
1243
  ENVIRONMENT_SETTING = "environment".freeze
1244
+ ENVIRONMENT_INTERPOLATION_ALLOWED = ['config_version'].freeze
1235
1245
 
1236
1246
  # @see Puppet::Settings.values
1237
1247
  # @api private
@@ -1280,7 +1290,7 @@ Generated on #{Time.now}.
1280
1290
  else
1281
1291
  # Convert it if necessary
1282
1292
  begin
1283
- val = convert(val)
1293
+ val = convert(val, name)
1284
1294
  rescue InterpolationError => err
1285
1295
  # This happens because we don't have access to the param name when the
1286
1296
  # exception is originally raised, but we want it in the message
@@ -1296,27 +1306,45 @@ Generated on #{Time.now}.
1296
1306
 
1297
1307
  private
1298
1308
 
1299
- def convert(value)
1309
+ def convert(value, setting_name)
1300
1310
  case value
1301
1311
  when nil
1302
1312
  nil
1303
1313
  when String
1304
- value.gsub(/\$(\w+)|\$\{(\w+)\}/) do |value|
1314
+ failed_environment_interpolation = false
1315
+ interpolated_value = value.gsub(/\$(\w+)|\$\{(\w+)\}/) do |expression|
1305
1316
  varname = $2 || $1
1306
- if varname == ENVIRONMENT_SETTING && @environment
1307
- @environment
1308
- elsif varname == "run_mode"
1309
- @mode
1310
- elsif !(pval = interpolate(varname.to_sym)).nil?
1311
- pval
1317
+ interpolated_expression =
1318
+ if varname != ENVIRONMENT_SETTING || ok_to_interpolate_environment(setting_name)
1319
+ if varname == ENVIRONMENT_SETTING && @environment
1320
+ @environment
1321
+ elsif varname == "run_mode"
1322
+ @mode
1323
+ elsif !(pval = interpolate(varname.to_sym)).nil?
1324
+ pval
1325
+ else
1326
+ raise InterpolationError, "Could not find value for #{expression}"
1327
+ end
1312
1328
  else
1313
- raise InterpolationError, "Could not find value for #{value}"
1329
+ failed_environment_interpolation = true
1330
+ expression
1314
1331
  end
1332
+ interpolated_expression
1315
1333
  end
1334
+ if failed_environment_interpolation
1335
+ Puppet.warning("You cannot interpolate $environment within '#{setting_name}' when using directory environments. Its value will remain #{interpolated_value}.")
1336
+ end
1337
+ interpolated_value
1316
1338
  else
1317
1339
  value
1318
1340
  end
1319
1341
  end
1342
+
1343
+ def ok_to_interpolate_environment(setting_name)
1344
+ return true if Puppet.settings.value(:environmentpath, nil, true).empty?
1345
+
1346
+ ENVIRONMENT_INTERPOLATION_ALLOWED.include?(setting_name.to_s)
1347
+ end
1320
1348
  end
1321
1349
 
1322
1350
  class Values
@@ -11,6 +11,8 @@ class Puppet::SSL::Validator::DefaultValidator #< class Puppet::SSL::Validator
11
11
  attr_reader :verify_errors
12
12
  attr_reader :ssl_configuration
13
13
 
14
+ FIVE_MINUTES_AS_SECONDS = 5 * 60
15
+
14
16
  # Creates a new DefaultValidator, optionally with an SSL Configuration and SSL Host.
15
17
  #
16
18
  # @param ssl_configuration [Puppet::SSL::Configuration] (a default configuration) ssl_configuration the SSL configuration to use
@@ -52,7 +54,7 @@ class Puppet::SSL::Validator::DefaultValidator #< class Puppet::SSL::Validator
52
54
  # SSL_VERIFY_PEER flag is set. It must be supplied by the application and
53
55
  # receives two arguments: preverify_ok indicates, whether the verification of
54
56
  # the certificate in question was passed (preverify_ok=1) or not
55
- # (preverify_ok=0). x509_ctx is a pointer to the complete context used for
57
+ # (preverify_ok=0). x509_store_ctx is a pointer to the complete context used for
56
58
  # the certificate chain verification.
57
59
  #
58
60
  # See {Puppet::Network::HTTP::Connection} for more information and where this
@@ -60,28 +62,47 @@ class Puppet::SSL::Validator::DefaultValidator #< class Puppet::SSL::Validator
60
62
  #
61
63
  # @param [Boolean] preverify_ok indicates whether the verification of the
62
64
  # certificate in question was passed (preverify_ok=true)
63
- # @param [OpenSSL::SSL::SSLContext] ssl_context holds the SSLContext for the
64
- # chain being verified.
65
+ # @param [OpenSSL::X509::StoreContext] store_context holds the X509 store context
66
+ # for the chain being verified.
65
67
  #
66
68
  # @return [Boolean] false if the peer is invalid, true otherwise.
67
69
  #
68
70
  # @api private
69
71
  #
70
- def call(preverify_ok, ssl_context)
71
- # We must make a copy since the scope of the ssl_context will be lost
72
+ def call(preverify_ok, store_context)
73
+ # We must make a copy since the scope of the store_context will be lost
72
74
  # across invocations of this method.
73
- current_cert = ssl_context.current_cert
74
- @peer_certs << Puppet::SSL::Certificate.from_instance(current_cert)
75
-
76
75
  if preverify_ok
76
+ current_cert = store_context.current_cert
77
+ @peer_certs << Puppet::SSL::Certificate.from_instance(current_cert)
78
+
77
79
  # If we've copied all of the certs in the chain out of the SSL library
78
- if @peer_certs.length == ssl_context.chain.length
80
+ if @peer_certs.length == store_context.chain.length
79
81
  # (#20027) The peer cert must be issued by a specific authority
80
82
  preverify_ok = valid_peer?
81
83
  end
82
84
  else
83
- if ssl_context.error_string
84
- @verify_errors << "#{ssl_context.error_string} for #{current_cert.subject}"
85
+ error = store_context.error || 0
86
+ error_string = store_context.error_string || "OpenSSL error #{error}"
87
+
88
+ case error
89
+ when OpenSSL::X509::V_ERR_CRL_NOT_YET_VALID
90
+ # current_crl can be nil
91
+ # https://github.com/ruby/ruby/blob/ruby_1_9_3/ext/openssl/ossl_x509store.c#L501-L510
92
+ crl = store_context.current_crl
93
+ if crl
94
+ if crl.last_update && crl.last_update < Time.now + FIVE_MINUTES_AS_SECONDS
95
+ Puppet.debug("Ignoring CRL not yet valid, current time #{Time.now.utc}, CRL last updated #{crl.last_update.utc}")
96
+ preverify_ok = true
97
+ else
98
+ @verify_errors << "#{error_string} for #{crl.issuer}"
99
+ end
100
+ else
101
+ @verify_errors << error_string
102
+ end
103
+ else
104
+ current_cert = store_context.current_cert
105
+ @verify_errors << "#{error_string} for #{current_cert.subject}"
85
106
  end
86
107
  end
87
108
  preverify_ok
@@ -105,6 +105,7 @@ class Puppet::Transaction
105
105
  overly_deferred_resource_handler = lambda do |resource|
106
106
  # We don't automatically assign unsuitable providers, so if there
107
107
  # is one, it must have been selected by the user.
108
+ return if missing_tags?(resource)
108
109
  if resource.provider
109
110
  resource.err "Provider #{resource.provider.class.name} is not functional on this host"
110
111
  else
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
  module Puppet
10
- PUPPETVERSION = '3.7.0'
10
+ PUPPETVERSION = '3.7.1'
11
11
 
12
12
  ##
13
13
  # version is a public API method intended to always provide a fast and
@@ -10,12 +10,6 @@ describe "Puppet defaults" do
10
10
  it "returns ./manifests by default" do
11
11
  expect(Puppet[:default_manifest]).to eq('./manifests')
12
12
  end
13
-
14
- it "errors when $environment is part of the value" do
15
- expect {
16
- Puppet[:default_manifest] = '/$environment/manifest.pp'
17
- }.to raise_error Puppet::Settings::ValidationError, /cannot interpolate.*\$environment/
18
- end
19
13
  end
20
14
 
21
15
  describe "when disable_per_environment_manifest is set" do
@@ -2,7 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  module EnvironmentsDefaultManifestsSpec
4
4
  describe "default manifests" do
5
- FS = Puppet::FileSystem
6
5
 
7
6
  shared_examples_for "puppet with default_manifest settings" do
8
7
  let(:confdir) { Puppet[:confdir] }
@@ -113,16 +112,6 @@ describe "default manifests" do
113
112
  )
114
113
  end
115
114
 
116
- it "raises an exception if default_manifest has $environment in it" do
117
- File.open(File.join(confdir, "puppet.conf"), "w") do |f|
118
- f.puts(<<-EOF)
119
- environmentpath=#{environmentpath}
120
- default_manifest=/foo/$environment
121
- EOF
122
- end
123
-
124
- expect { Puppet.initialize_settings }.to raise_error(Puppet::Settings::ValidationError, /cannot interpolate.*\$environment.*in.*default_manifest/)
125
- end
126
115
  end
127
116
 
128
117
  context "with disable_per_environment_manifest true" do
@@ -0,0 +1,165 @@
1
+ require 'pp'
2
+ require 'spec_helper'
3
+
4
+ module SettingsInterpolationSpec
5
+ describe "interpolating $environment" do
6
+ let(:confdir) { Puppet[:confdir] }
7
+ let(:cmdline_args) { ['--confdir', confdir, '--vardir', Puppet[:vardir], '--hiera_config', Puppet[:hiera_config]] }
8
+
9
+ before(:each) do
10
+ FileUtils.mkdir_p(confdir)
11
+ end
12
+
13
+ shared_examples_for "a setting that does not interpolate $environment" do
14
+
15
+ before(:each) do
16
+ set_puppet_conf(confdir, <<-EOF)
17
+ environmentpath=$confdir/environments
18
+ #{setting}=#{value}
19
+ EOF
20
+ end
21
+
22
+ it "does not interpolate $environment" do
23
+ Puppet.initialize_settings(cmdline_args)
24
+ expect(Puppet[:environmentpath]).to eq("#{confdir}/environments")
25
+ expect(Puppet[setting.intern]).to eq(expected)
26
+ end
27
+
28
+ it "displays the interpolated value in the warning" do
29
+ Puppet.initialize_settings(cmdline_args)
30
+ Puppet[setting.intern]
31
+ expect(@logs).to have_matching_log(/cannot interpolate \$environment within '#{setting}'.*Its value will remain #{Regexp.escape(expected)}/)
32
+ end
33
+ end
34
+
35
+ context "when environmentpath is set" do
36
+
37
+ describe "config_version" do
38
+ it "interpolates $environment" do
39
+ envname = 'testing'
40
+ setting = 'config_version'
41
+ value = '/some/script $environment'
42
+ expected = "#{File.expand_path('/some/script')} testing"
43
+
44
+ set_puppet_conf(confdir, <<-EOF)
45
+ environmentpath=$confdir/environments
46
+ environment=#{envname}
47
+ EOF
48
+
49
+ set_environment_conf("#{confdir}/environments", envname, <<-EOF)
50
+ #{setting}=#{value}
51
+ EOF
52
+
53
+ Puppet.initialize_settings(cmdline_args)
54
+ expect(Puppet[:environmentpath]).to eq("#{confdir}/environments")
55
+ environment = Puppet.lookup(:environments).get(envname)
56
+ expect(environment.config_version).to eq(expected)
57
+ expect(@logs).to be_empty
58
+ end
59
+ end
60
+
61
+ describe "basemodulepath" do
62
+ let(:setting) { "basemodulepath" }
63
+ let(:value) { "$confdir/environments/$environment/modules:$confdir/environments/$environment/other_modules" }
64
+ let(:expected) { "#{confdir}/environments/$environment/modules:#{confdir}/environments/$environment/other_modules" }
65
+
66
+ it_behaves_like "a setting that does not interpolate $environment"
67
+
68
+ it "logs a single warning for multiple instaces of $environment in the setting" do
69
+ set_puppet_conf(confdir, <<-EOF)
70
+ environmentpath=$confdir/environments
71
+ #{setting}=#{value}
72
+ EOF
73
+
74
+ Puppet.initialize_settings(cmdline_args)
75
+ expect(@logs.map(&:to_s).grep(/cannot interpolate \$environment within '#{setting}'/).count).to eq(1)
76
+ end
77
+ end
78
+
79
+ describe "environment" do
80
+ let(:setting) { "environment" }
81
+ let(:value) { "whatareyouthinking$environment" }
82
+ let(:expected) { value }
83
+
84
+ it_behaves_like "a setting that does not interpolate $environment"
85
+ end
86
+
87
+ describe "the default_manifest" do
88
+ let(:setting) { "default_manifest" }
89
+ let(:value) { "$confdir/manifests/$environment" }
90
+ let(:expected) { "#{confdir}/manifests/$environment" }
91
+
92
+ it_behaves_like "a setting that does not interpolate $environment"
93
+ end
94
+
95
+ it "does not interpolate $environment and logs a warning when interpolating environmentpath" do
96
+ setting = 'environmentpath'
97
+ value = "$confdir/environments/$environment"
98
+ expected = "#{confdir}/environments/$environment"
99
+
100
+ set_puppet_conf(confdir, <<-EOF)
101
+ #{setting}=#{value}
102
+ EOF
103
+
104
+ Puppet.initialize_settings(cmdline_args)
105
+ expect(Puppet[setting.intern]).to eq(expected)
106
+ expect(@logs).to have_matching_log(/cannot interpolate \$environment within '#{setting}'/)
107
+ end
108
+ end
109
+
110
+ def assert_does_interpolate_environment(setting, value, expected_interpolation)
111
+ set_puppet_conf(confdir, <<-EOF)
112
+ #{setting}=#{value}
113
+ EOF
114
+
115
+ Puppet.initialize_settings(cmdline_args)
116
+ expect(Puppet[:environmentpath]).to be_empty
117
+ expect(Puppet[setting.intern]).to eq(expected_interpolation)
118
+ expect(@logs).to_not have_matching_log(/cannot interpolate \$environment within '#{setting}'/)
119
+ end
120
+
121
+ context "when environmentpath is not set" do
122
+ it "does interpolate $environment in config_version" do
123
+ value = "/some/script $environment"
124
+ expect = "/some/script production"
125
+ assert_does_interpolate_environment("config_version", value, expect)
126
+ end
127
+
128
+ it "does interpolate $environment in basemodulepath" do
129
+ value = "$confdir/environments/$environment/modules:$confdir/environments/$environment/other_modules"
130
+ expected = "#{confdir}/environments/production/modules:#{confdir}/environments/production/other_modules"
131
+ assert_does_interpolate_environment("basemodulepath", value, expected)
132
+ end
133
+
134
+ it "does interpolate $environment in default_manifest, which is fine, because this setting isn't used" do
135
+ value = "$confdir/manifests/$environment"
136
+ expected = "#{confdir}/manifests/production"
137
+
138
+ assert_does_interpolate_environment("default_manifest", value, expected)
139
+ end
140
+
141
+ it "raises something" do
142
+ value = expected = "whatareyouthinking$environment"
143
+ expect {
144
+ assert_does_interpolate_environment("environment", value, expected)
145
+ }.to raise_error(SystemStackError, /stack level too deep/)
146
+ end
147
+ end
148
+
149
+ def set_puppet_conf(confdir, settings)
150
+ write_file(File.join(confdir, "puppet.conf"), settings)
151
+ end
152
+
153
+ def set_environment_conf(environmentpath, environment, settings)
154
+ envdir = File.join(environmentpath, environment)
155
+ FileUtils.mkdir_p(envdir)
156
+ write_file(File.join(envdir, 'environment.conf'), settings)
157
+ end
158
+
159
+ def write_file(file, contents)
160
+ File.open(file, "w") do |f|
161
+ f.puts(contents)
162
+ end
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,48 @@
1
+ #! /usr/bin/env ruby
2
+ require 'spec_helper'
3
+
4
+ describe Puppet::Type.type(:service).provider(:windows), '(integration)',
5
+ :if => Puppet.features.microsoft_windows? do
6
+
7
+ require 'puppet/util/windows'
8
+
9
+ before :each do
10
+ Puppet::Type.type(:service).stubs(:defaultprovider).returns described_class
11
+ end
12
+
13
+ context 'should fail querying services that do not exist' do
14
+ let(:service) do
15
+ Puppet::Type.type(:service).new(:name => 'foobarservice1234')
16
+ end
17
+
18
+ it "with a Puppet::Error when querying enabled?" do
19
+ expect { service.provider.enabled? }.to raise_error(Puppet::Error)
20
+ end
21
+
22
+ it "with a Puppet::Error when querying status" do
23
+ expect { service.provider.status }.to raise_error(Puppet::Error)
24
+ end
25
+ end
26
+
27
+ context 'should return valid values when querying a service that does exist' do
28
+ let(:service) do
29
+ Puppet::Type.type(:service).new(:name => 'lmhosts')
30
+ end
31
+
32
+ it "with a valid boolean when asked if enabled" do
33
+ expect([:true, :false]).to include(service.provider.enabled?)
34
+ end
35
+
36
+ it "with a valid status when asked about status" do
37
+ expect([
38
+ :running,
39
+ :'continue pending',
40
+ :'pause pending',
41
+ :paused,
42
+ :running,
43
+ :'start pending',
44
+ :'stop pending',
45
+ :stopped]).to include(service.provider.status)
46
+ end
47
+ end
48
+ end
@@ -447,7 +447,7 @@ describe "Puppet::Util::Windows::Security", :if => Puppet.features.microsoft_win
447
447
  describe "when the sid refers to a deleted trustee" do
448
448
  it "should retrieve the user sid" do
449
449
  sid = nil
450
- user = Puppet::Util::Windows::ADSI::User.create("delete_me_user")
450
+ user = Puppet::Util::Windows::ADSI::User.create("puppet#{rand(10000)}")
451
451
  user.commit
452
452
  begin
453
453
  sid = Puppet::Util::Windows::ADSI::User.new(user.name).sid.to_s
@@ -463,7 +463,7 @@ describe "Puppet::Util::Windows::Security", :if => Puppet.features.microsoft_win
463
463
 
464
464
  it "should retrieve the group sid" do
465
465
  sid = nil
466
- group = Puppet::Util::Windows::ADSI::Group.create("delete_me_group")
466
+ group = Puppet::Util::Windows::ADSI::Group.create("puppet#{rand(10000)}")
467
467
  group.commit
468
468
  begin
469
469
  sid = Puppet::Util::Windows::ADSI::Group.new(group.name).sid.to_s
@@ -21,6 +21,11 @@ RSpec::Matchers.define :have_matching_element do |expected|
21
21
  end
22
22
  end
23
23
 
24
+ RSpec::Matchers.define :have_matching_log do |expected|
25
+ match do |actual|
26
+ actual.map(&:to_s).any? { |item| item =~ expected }
27
+ end
28
+ end
24
29
 
25
30
  RSpec::Matchers.define :exit_with do |expected|
26
31
  actual = nil
@@ -1,4 +1,3 @@
1
-
2
1
  require 'spec_helper'
3
2
 
4
3
  describe "the epp function" do
@@ -61,9 +61,9 @@ describe "http compression" do
61
61
  headers['accept-encoding'].should =~ /identity/
62
62
  end
63
63
 
64
- it "should not add Accept-Encoding header if http compression is not available" do
64
+ it "should add an Accept-Encoding 'identity' header if http compression is disabled" do
65
65
  Puppet[:http_compression] = false
66
- @uncompressor.add_accept_encoding({}).should == {}
66
+ @uncompressor.add_accept_encoding({}).should == {'accept-encoding' => 'identity'}
67
67
  end
68
68
 
69
69
  describe "when uncompressing response body" do
@@ -16,10 +16,10 @@ describe 'dependency loader' do
16
16
  'foo.rb' => 'Puppet::Functions.create_function("foo") { def foo; end; }'
17
17
  }}}}})
18
18
 
19
- module_loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(static_loader, loaders, 'testmodule', module_dir, 'test1')
20
- dep_loader = Puppet::Pops::Loader::DependencyLoader.new(static_loader, 'test-dep', [module_loader])
19
+ loader = loader_for('testmodule', module_dir)
20
+
21
21
  expect do
22
- dep_loader.load_typed(typed_name(:function, 'testmodule::foo')).value
22
+ loader.load_typed(typed_name(:function, 'testmodule::foo')).value
23
23
  end.to raise_error(ArgumentError, /produced mis-matched name, expected 'testmodule::foo', got foo/)
24
24
  end
25
25
 
@@ -28,10 +28,10 @@ describe 'dependency loader' do
28
28
  'lib' => { 'puppet' => { 'functions' => { 'testmodule' => {
29
29
  'foo.rb' => 'Puppet::Functions.create_function("testmodule::foo") { def foo; end; }'
30
30
  }}}}})
31
- module_loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(static_loader, loaders, 'testmodule', module_dir, 'test1')
32
- dep_loader = Puppet::Pops::Loader::DependencyLoader.new(static_loader, 'test-dep', [module_loader])
33
31
 
34
- function = dep_loader.load_typed(typed_name(:function, 'testmodule::foo')).value
32
+ loader = loader_for('testmodule', module_dir)
33
+
34
+ function = loader.load_typed(typed_name(:function, 'testmodule::foo')).value
35
35
 
36
36
  expect(function.class.name).to eq('testmodule::foo')
37
37
  expect(function.is_a?(Puppet::Functions::Function)).to eq(true)
@@ -42,19 +42,24 @@ describe 'dependency loader' do
42
42
  'lib' => { 'puppet' => { 'functions' => { 'testmodule' => {
43
43
  'foo.rb' => 'Puppet::Functions.create_function("testmodule::foo") { def foo; end; }'
44
44
  }}}}})
45
- module_loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(static_loader, loaders, 'testmodule', module_dir, 'test1')
46
- dep_loader = Puppet::Pops::Loader::DependencyLoader.new(static_loader, 'test-dep', [module_loader])
47
45
 
48
- function = dep_loader.load_typed(typed_name(:function, 'testmodule::foo')).value
46
+ loader = loader_for('testmodule', module_dir)
47
+
48
+ function = loader.load_typed(typed_name(:function, 'testmodule::foo')).value
49
49
  expect(function.class.name).to eq('testmodule::foo')
50
50
  expect(function.is_a?(Puppet::Functions::Function)).to eq(true)
51
51
 
52
- function = dep_loader.load_typed(typed_name(:function, 'testmodule::foo')).value
52
+ function = loader.load_typed(typed_name(:function, 'testmodule::foo')).value
53
53
  expect(function.class.name).to eq('testmodule::foo')
54
54
  expect(function.is_a?(Puppet::Functions::Function)).to eq(true)
55
55
  end
56
56
  end
57
57
 
58
+ def loader_for(name, dir)
59
+ module_loader = Puppet::Pops::Loader::ModuleLoaders.module_loader_from(static_loader, loaders, name, dir)
60
+ Puppet::Pops::Loader::DependencyLoader.new(static_loader, 'test-dep', [module_loader])
61
+ end
62
+
58
63
  def typed_name(type, name)
59
64
  Puppet::Pops::Loader::Loader::TypedName.new(type, name)
60
65
  end
@@ -9,47 +9,35 @@ describe 'loader paths' do
9
9
  let(:static_loader) { Puppet::Pops::Loader::StaticLoader.new() }
10
10
  let(:unused_loaders) { nil }
11
11
 
12
- describe 'the relative_path_for_types method' do
13
- it 'produces paths to load in precendence order' do
14
- module_dir = dir_containing('testmodule', {
15
- 'functions' => {},
16
- 'lib' => {
17
- 'puppet' => {
18
- 'functions' => {},
19
- }}})
20
- module_loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(static_loader, unused_loaders, 'testmodule', module_dir, 'test1')
21
-
22
- effective_paths = Puppet::Pops::Loader::LoaderPaths.relative_paths_for_type(:function, module_loader)
23
-
24
- expect(effective_paths.collect(&:generic_path)).to eq([
25
- File.join(module_dir, 'lib', 'puppet', 'functions')
26
- ])
27
- end
28
-
29
- it 'module loader has smart-paths that prunes unavailable paths' do
30
- module_dir = dir_containing('testmodule', {'lib' => {'puppet' => {'functions' => {'foo.rb' => 'Puppet::Functions.create_function("testmodule::foo") { def foo; end; }' }}}})
31
- module_loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(static_loader, unused_loaders, 'testmodule', module_dir, 'test1')
32
-
33
- effective_paths = module_loader.smart_paths.effective_paths(:function)
34
-
35
- expect(effective_paths.size).to be_eql(1)
36
- expect(effective_paths[0].generic_path).to be_eql(File.join(module_dir, 'lib', 'puppet', 'functions'))
37
- end
38
-
39
- it 'all function smart-paths produces entries if they exist' do
40
- module_dir = dir_containing('testmodule', {
41
- 'lib' => {
42
- 'puppet' => {
43
- 'functions' => {'foo4x.rb' => 'ignored in this test'},
44
- }}})
45
- module_loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(static_loader, unused_loaders, 'testmodule', module_dir, 'test1')
46
-
47
- effective_paths = module_loader.smart_paths.effective_paths(:function)
48
-
49
- expect(effective_paths.size).to eq(1)
50
- expect(module_loader.path_index.size).to eq(1)
51
- path_index = module_loader.path_index
52
- expect(path_index).to include(File.join(module_dir, 'lib', 'puppet', 'functions', 'foo4x.rb'))
53
- end
12
+ it 'module loader has smart-paths that prunes unavailable paths' do
13
+ module_dir = dir_containing('testmodule', {'lib' => {'puppet' => {'functions' =>
14
+ {'foo.rb' =>
15
+ 'Puppet::Functions.create_function("testmodule::foo") {
16
+ def foo; end;
17
+ }'
18
+ }
19
+ }}})
20
+ module_loader = Puppet::Pops::Loader::ModuleLoaders.module_loader_from(static_loader, unused_loaders, 'testmodule', module_dir)
21
+
22
+ effective_paths = module_loader.smart_paths.effective_paths(:function)
23
+
24
+ expect(effective_paths.size).to be_eql(1)
25
+ expect(effective_paths[0].generic_path).to be_eql(File.join(module_dir, 'lib', 'puppet', 'functions'))
26
+ end
27
+
28
+ it 'all function smart-paths produces entries if they exist' do
29
+ module_dir = dir_containing('testmodule', {
30
+ 'lib' => {
31
+ 'puppet' => {
32
+ 'functions' => {'foo4x.rb' => 'ignored in this test'},
33
+ }}})
34
+ module_loader = Puppet::Pops::Loader::ModuleLoaders.module_loader_from(static_loader, unused_loaders, 'testmodule', module_dir)
35
+
36
+ effective_paths = module_loader.smart_paths.effective_paths(:function)
37
+
38
+ expect(effective_paths.size).to eq(1)
39
+ expect(module_loader.path_index.size).to eq(1)
40
+ path_index = module_loader.path_index
41
+ expect(path_index).to include(File.join(module_dir, 'lib', 'puppet', 'functions', 'foo4x.rb'))
54
42
  end
55
43
  end
@@ -26,7 +26,7 @@ describe 'FileBased module loader' do
26
26
  }
27
27
  })
28
28
 
29
- module_loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(static_loader, loaders, 'testmodule', module_dir, 'test1')
29
+ module_loader = Puppet::Pops::Loader::ModuleLoaders.module_loader_from(static_loader, loaders, 'testmodule', module_dir)
30
30
  function = module_loader.load_typed(typed_name(:function, 'foo4x')).value
31
31
 
32
32
  expect(function.class.name).to eq('foo4x')
@@ -51,7 +51,7 @@ describe 'FileBased module loader' do
51
51
  }
52
52
  }})
53
53
 
54
- module_loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(static_loader, loaders, 'testmodule', module_dir, 'test1')
54
+ module_loader = Puppet::Pops::Loader::ModuleLoaders.module_loader_from(static_loader, loaders, 'testmodule', module_dir)
55
55
  function = module_loader.load_typed(typed_name(:function, 'testmodule::foo4x')).value
56
56
  expect(function.class.name).to eq('testmodule::foo4x')
57
57
  expect(function.is_a?(Puppet::Functions::Function)).to eq(true)
@@ -68,7 +68,7 @@ describe 'FileBased module loader' do
68
68
  end
69
69
  CODE
70
70
  }}}}})
71
- module_loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(static_loader, loaders, 'testmodule', module_dir, 'test1')
71
+ module_loader = Puppet::Pops::Loader::ModuleLoaders.module_loader_from(static_loader, loaders, 'testmodule', module_dir)
72
72
 
73
73
  module_dir2 = dir_containing('testmodule2', {
74
74
  'lib' => { 'puppet' => { 'functions' => { 'testmodule2' => {
@@ -51,6 +51,14 @@ describe Puppet::Type.type(:service).provider(:windows), :if => Puppet.features.
51
51
  }.to raise_error(Puppet::Error, /Cannot start #{name}, error was: The service name is invalid./)
52
52
  end
53
53
 
54
+ it "raises an error if the service doesn't exist" do
55
+ Win32::Service.expects(:config_info).with(name).raises(SystemCallError, 'OpenService')
56
+
57
+ expect {
58
+ provider.start
59
+ }.to raise_error(Puppet::Error, /Cannot get start type for #{name}/)
60
+ end
61
+
54
62
  describe "when the service is disabled" do
55
63
  before :each do
56
64
  config.start_type = Win32::Service.get_start_type(Win32::Service::SERVICE_DISABLED)
@@ -112,6 +120,14 @@ describe Puppet::Type.type(:service).provider(:windows), :if => Puppet.features.
112
120
  provider.status.should == :running
113
121
  end
114
122
  end
123
+
124
+ it "raises an error if the service doesn't exist" do
125
+ Win32::Service.expects(:status).with(name).raises(SystemCallError, 'OpenService')
126
+
127
+ expect {
128
+ provider.status
129
+ }.to raise_error(Puppet::Error, /Cannot get status of #{name}/)
130
+ end
115
131
  end
116
132
 
117
133
  describe "#restart" do
@@ -146,6 +162,14 @@ describe Puppet::Type.type(:service).provider(:windows), :if => Puppet.features.
146
162
  provider.enabled?.should == :false
147
163
  end
148
164
 
165
+ it "raises an error if the service doesn't exist" do
166
+ Win32::Service.expects(:config_info).with(name).raises(SystemCallError, 'OpenService')
167
+
168
+ expect {
169
+ provider.enabled?
170
+ }.to raise_error(Puppet::Error, /Cannot get start type for #{name}/)
171
+ end
172
+
149
173
  # We need to guard this section explicitly since rspec will always
150
174
  # construct all examples, even if it isn't going to run them.
151
175
  if Puppet.features.microsoft_windows?
@@ -165,6 +189,14 @@ describe Puppet::Type.type(:service).provider(:windows), :if => Puppet.features.
165
189
  Win32::Service.expects(:configure).with('service_name' => name, 'start_type' => Win32::Service::SERVICE_AUTO_START).returns(Win32::Service)
166
190
  provider.enable
167
191
  end
192
+
193
+ it "raises an error if the service doesn't exist" do
194
+ Win32::Service.expects(:configure).with(has_entry('service_name' => name)).raises(SystemCallError, 'OpenService')
195
+
196
+ expect {
197
+ provider.enable
198
+ }.to raise_error(Puppet::Error, /Cannot enable #{name}/)
199
+ end
168
200
  end
169
201
 
170
202
  describe "#disable" do
@@ -172,6 +204,14 @@ describe Puppet::Type.type(:service).provider(:windows), :if => Puppet.features.
172
204
  Win32::Service.expects(:configure).with('service_name' => name, 'start_type' => Win32::Service::SERVICE_DISABLED).returns(Win32::Service)
173
205
  provider.disable
174
206
  end
207
+
208
+ it "raises an error if the service doesn't exist" do
209
+ Win32::Service.expects(:configure).with(has_entry('service_name' => name)).raises(SystemCallError, 'OpenService')
210
+
211
+ expect {
212
+ provider.disable
213
+ }.to raise_error(Puppet::Error, /Cannot disable #{name}/)
214
+ end
175
215
  end
176
216
 
177
217
  describe "#manual_start" do
@@ -179,5 +219,13 @@ describe Puppet::Type.type(:service).provider(:windows), :if => Puppet.features.
179
219
  Win32::Service.expects(:configure).with('service_name' => name, 'start_type' => Win32::Service::SERVICE_DEMAND_START).returns(Win32::Service)
180
220
  provider.manual_start
181
221
  end
222
+
223
+ it "raises an error if the service doesn't exist" do
224
+ Win32::Service.expects(:configure).with(has_entry('service_name' => name)).raises(SystemCallError, 'OpenService')
225
+
226
+ expect {
227
+ provider.manual_start
228
+ }.to raise_error(Puppet::Error, /Cannot enable #{name}/)
229
+ end
182
230
  end
183
231
  end
@@ -85,6 +85,12 @@ describe Puppet::Resource do
85
85
  ref.title.should =="baz"
86
86
  end
87
87
 
88
+ it "should not interpret the title as a reference if the type is a non component or whit reference" do
89
+ ref = Puppet::Resource.new("Notify", "foo::bar[baz]")
90
+ ref.type.should == "Notify"
91
+ ref.title.should =="foo::bar[baz]"
92
+ end
93
+
88
94
  it "should be able to extract its information from a Puppet::Type instance" do
89
95
  ral = Puppet::Type.type(:file).new :path => basepath+"/foo"
90
96
  ref = Puppet::Resource.new(ral)
@@ -2,9 +2,12 @@
2
2
  require 'spec_helper'
3
3
  require 'ostruct'
4
4
  require 'puppet/settings/errors'
5
+ require 'puppet_spec/files'
6
+ require 'matchers/resource'
5
7
 
6
8
  describe Puppet::Settings do
7
9
  include PuppetSpec::Files
10
+ include Matchers::Resource
8
11
 
9
12
  let(:main_config_file_default_location) do
10
13
  File.join(Puppet::Util::RunMode[:master].conf_dir, "puppet.conf")
@@ -1338,6 +1341,16 @@ describe Puppet::Settings do
1338
1341
  @settings.to_catalog
1339
1342
  end
1340
1343
 
1344
+ it "should ignore manifestdir if environmentpath is set" do
1345
+ @settings.define_settings :main,
1346
+ :manifestdir => { :type => :directory, :default => @prefix+"/manifestdir", :desc => "a" },
1347
+ :environmentpath => { :type => :path, :default => @prefix+"/envs", :desc => "a" }
1348
+
1349
+ catalog = @settings.to_catalog(:main)
1350
+
1351
+ expect(catalog).to_not have_resource("File[#{@prefix}/manifestdir]")
1352
+ end
1353
+
1341
1354
  describe "on Microsoft Windows" do
1342
1355
  before :each do
1343
1356
  Puppet.features.stubs(:root?).returns true
@@ -1395,6 +1408,13 @@ describe Puppet::Settings do
1395
1408
  catalog = @settings.to_catalog
1396
1409
  expect(catalog.resource_keys).to include(["File", "#{default_path}/production"])
1397
1410
  end
1411
+
1412
+ it "does not add if the path to the default directory environment exists as a symlink", :if => Puppet.features.manages_symlinks? do
1413
+ Dir.mkdir(default_path)
1414
+ Puppet::FileSystem.symlink("#{tmpenv}/nowhere", File.join(default_path, 'production'))
1415
+ catalog = @settings.to_catalog
1416
+ expect(catalog.resource_keys).to_not include(["File", "#{default_path}/production"])
1417
+ end
1398
1418
  end
1399
1419
 
1400
1420
  describe "when adding users and groups to the catalog" do
@@ -39,14 +39,80 @@ describe Puppet::SSL::Validator::DefaultValidator do
39
39
 
40
40
  context 'When pre-verification is not OK' do
41
41
  context 'and the ssl_context is in an error state' do
42
- before :each do
43
- ssl_context.stubs(:error_string).returns("Something went wrong.")
42
+ let(:root_subject) { OpenSSL::X509::Certificate.new(root_ca).subject.to_s }
43
+ let(:code) { OpenSSL::X509::V_ERR_INVALID_CA }
44
+
45
+ it 'rejects the connection' do
46
+ ssl_context.stubs(:error_string).returns("Something went wrong")
47
+ ssl_context.stubs(:error).returns(code)
48
+
49
+ expect(subject.call(false, ssl_context)).to eq(false)
44
50
  end
45
51
 
46
52
  it 'makes the error available via #verify_errors' do
53
+ ssl_context.stubs(:error_string).returns("Something went wrong")
54
+ ssl_context.stubs(:error).returns(code)
55
+
56
+ subject.call(false, ssl_context)
57
+ expect(subject.verify_errors).to eq(["Something went wrong for #{root_subject}"])
58
+ end
59
+
60
+ it 'uses a generic message if error_string is nil' do
61
+ ssl_context.stubs(:error_string).returns(nil)
62
+ ssl_context.stubs(:error).returns(code)
63
+
47
64
  subject.call(false, ssl_context)
48
- msg_suffix = OpenSSL::X509::Certificate.new(root_ca).subject
49
- subject.verify_errors.should == ["Something went wrong. for #{msg_suffix}"]
65
+ expect(subject.verify_errors).to eq(["OpenSSL error #{code} for #{root_subject}"])
66
+ end
67
+
68
+ it 'uses 0 for nil error codes' do
69
+ ssl_context.stubs(:error_string).returns("Something went wrong")
70
+ ssl_context.stubs(:error).returns(nil)
71
+
72
+ subject.call(false, ssl_context)
73
+ expect(subject.verify_errors).to eq(["Something went wrong for #{root_subject}"])
74
+ end
75
+
76
+ context "when CRL is not yet valid" do
77
+ before :each do
78
+ ssl_context.stubs(:error_string).returns("CRL is not yet valid")
79
+ ssl_context.stubs(:error).returns(OpenSSL::X509::V_ERR_CRL_NOT_YET_VALID)
80
+ end
81
+
82
+ it 'rejects nil CRL' do
83
+ ssl_context.stubs(:current_crl).returns(nil)
84
+
85
+ expect(subject.call(false, ssl_context)).to eq(false)
86
+ expect(subject.verify_errors).to eq(["CRL is not yet valid"])
87
+ end
88
+
89
+ it 'includes the CRL issuer in the verify error message' do
90
+ crl = OpenSSL::X509::CRL.new
91
+ crl.issuer = OpenSSL::X509::Name.new([['CN','Puppet CA: puppetmaster.example.com']])
92
+ crl.last_update = Time.now + 24 * 60 * 60
93
+ ssl_context.stubs(:current_crl).returns(crl)
94
+
95
+ subject.call(false, ssl_context)
96
+ expect(subject.verify_errors).to eq(["CRL is not yet valid for /CN=Puppet CA: puppetmaster.example.com"])
97
+ end
98
+
99
+ it 'rejects CRLs whose last_update time is more than 5 minutes in the future' do
100
+ crl = OpenSSL::X509::CRL.new
101
+ crl.issuer = OpenSSL::X509::Name.new([['CN','Puppet CA: puppetmaster.example.com']])
102
+ crl.last_update = Time.now + 24 * 60 * 60
103
+ ssl_context.stubs(:current_crl).returns(crl)
104
+
105
+ expect(subject.call(false, ssl_context)).to eq(false)
106
+ end
107
+
108
+ it 'accepts CRLs whose last_update time is 10 seconds in the future' do
109
+ crl = OpenSSL::X509::CRL.new
110
+ crl.issuer = OpenSSL::X509::Name.new([['CN','Puppet CA: puppetmaster.example.com']])
111
+ crl.last_update = Time.now + 10
112
+ ssl_context.stubs(:current_crl).returns(crl)
113
+
114
+ expect(subject.call(false, ssl_context)).to eq(true)
115
+ end
50
116
  end
51
117
  end
52
118
  end
@@ -54,7 +120,7 @@ describe Puppet::SSL::Validator::DefaultValidator do
54
120
  context 'When pre-verification is OK' do
55
121
  context 'and the ssl_context is in an error state' do
56
122
  before :each do
57
- ssl_context.stubs(:error_string).returns("Something went wrong.")
123
+ ssl_context.stubs(:error_string).returns("Something went wrong")
58
124
  end
59
125
 
60
126
  it 'does not make the error available via #verify_errors' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.0
4
+ version: 3.7.1
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-03 00:00:00.000000000 Z
11
+ date: 2014-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: facter
@@ -1843,6 +1843,7 @@ files:
1843
1843
  - spec/integration/defaults_spec.rb
1844
1844
  - spec/integration/directory_environments_spec.rb
1845
1845
  - spec/integration/environments/default_manifest_spec.rb
1846
+ - spec/integration/environments/settings_interpolation_spec.rb
1846
1847
  - spec/integration/faces/ca_spec.rb
1847
1848
  - spec/integration/faces/documentation_spec.rb
1848
1849
  - spec/integration/faces/plugin_spec.rb
@@ -1882,6 +1883,7 @@ files:
1882
1883
  - spec/integration/provider/package_spec.rb
1883
1884
  - spec/integration/provider/service/init_spec.rb
1884
1885
  - spec/integration/provider/service/systemd_spec.rb
1886
+ - spec/integration/provider/service/windows_spec.rb
1885
1887
  - spec/integration/provider/ssh_authorized_key_spec.rb
1886
1888
  - spec/integration/reference/providers_spec.rb
1887
1889
  - spec/integration/reports_spec.rb
@@ -2920,6 +2922,7 @@ test_files:
2920
2922
  - spec/integration/defaults_spec.rb
2921
2923
  - spec/integration/directory_environments_spec.rb
2922
2924
  - spec/integration/environments/default_manifest_spec.rb
2925
+ - spec/integration/environments/settings_interpolation_spec.rb
2923
2926
  - spec/integration/faces/ca_spec.rb
2924
2927
  - spec/integration/faces/documentation_spec.rb
2925
2928
  - spec/integration/faces/plugin_spec.rb
@@ -2959,6 +2962,7 @@ test_files:
2959
2962
  - spec/integration/provider/package_spec.rb
2960
2963
  - spec/integration/provider/service/init_spec.rb
2961
2964
  - spec/integration/provider/service/systemd_spec.rb
2965
+ - spec/integration/provider/service/windows_spec.rb
2962
2966
  - spec/integration/provider/ssh_authorized_key_spec.rb
2963
2967
  - spec/integration/reference/providers_spec.rb
2964
2968
  - spec/integration/reports_spec.rb