puppet 6.25.0-universal-darwin → 6.25.1-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +3 -3
  3. data/lib/puppet/configurer.rb +69 -9
  4. data/lib/puppet/defaults.rb +6 -0
  5. data/lib/puppet/http/client.rb +1 -1
  6. data/lib/puppet/http/redirector.rb +5 -0
  7. data/lib/puppet/parser/resource.rb +1 -1
  8. data/lib/puppet/pops/evaluator/closure.rb +7 -5
  9. data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +1 -0
  10. data/lib/puppet/resource/catalog.rb +1 -1
  11. data/lib/puppet/resource.rb +38 -5
  12. data/lib/puppet/util/windows/service.rb +0 -5
  13. data/lib/puppet/util/windows.rb +3 -0
  14. data/lib/puppet/version.rb +1 -1
  15. data/man/man5/puppet.conf.5 +2 -2
  16. data/man/man8/puppet-agent.8 +1 -1
  17. data/man/man8/puppet-apply.8 +1 -1
  18. data/man/man8/puppet-catalog.8 +1 -1
  19. data/man/man8/puppet-config.8 +1 -1
  20. data/man/man8/puppet-describe.8 +1 -1
  21. data/man/man8/puppet-device.8 +1 -1
  22. data/man/man8/puppet-doc.8 +1 -1
  23. data/man/man8/puppet-epp.8 +1 -1
  24. data/man/man8/puppet-facts.8 +1 -1
  25. data/man/man8/puppet-filebucket.8 +1 -1
  26. data/man/man8/puppet-generate.8 +1 -1
  27. data/man/man8/puppet-help.8 +1 -1
  28. data/man/man8/puppet-key.8 +1 -1
  29. data/man/man8/puppet-lookup.8 +1 -1
  30. data/man/man8/puppet-man.8 +1 -1
  31. data/man/man8/puppet-module.8 +1 -1
  32. data/man/man8/puppet-node.8 +1 -1
  33. data/man/man8/puppet-parser.8 +1 -1
  34. data/man/man8/puppet-plugin.8 +1 -1
  35. data/man/man8/puppet-report.8 +1 -1
  36. data/man/man8/puppet-resource.8 +1 -1
  37. data/man/man8/puppet-script.8 +1 -1
  38. data/man/man8/puppet-ssl.8 +1 -1
  39. data/man/man8/puppet-status.8 +1 -1
  40. data/man/man8/puppet.8 +2 -2
  41. data/spec/fixtures/integration/application/agent/cached_deferred_catalog.json +2 -1
  42. data/spec/integration/application/agent_spec.rb +28 -0
  43. data/spec/integration/parser/pcore_resource_spec.rb +10 -0
  44. data/spec/unit/configurer_spec.rb +86 -25
  45. data/spec/unit/http/client_spec.rb +58 -1
  46. data/spec/unit/resource/catalog_spec.rb +14 -1
  47. data/spec/unit/resource_spec.rb +58 -2
  48. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a69790e629afa10ee25ecc00a28e2404f9a74011386ae193c3af640632a4d63
4
- data.tar.gz: ab6172abe15adda91b4285964adb04e7d62db5490b68abf81f27adc23b4d6e74
3
+ metadata.gz: 929abb48ad2fe62bcc1df80e068c92233fc3eb899eb0f5597158972f1a4aec48
4
+ data.tar.gz: 9be081a7aef093737aba6691f9ca1ecfb05a6dbee4056b60ff0be659d2084d53
5
5
  SHA512:
6
- metadata.gz: b4d3e9e4c588a512162c065c8e81878f1d163b69ea928625e2cbdf96e7a3c97031292f32b57b9c4fef2f43d9c7b70f6a4e07eaeed10a3749247c46ce51969dc2
7
- data.tar.gz: 5952cc4ef392cdbb8be1c53e4a5706793ffa1d8adf9ea55497eccd4f249d6c990fea201f33718d52a6a48869d466bb467a054cee9a1a881eb1cdea60a0810916
6
+ metadata.gz: fdfd1dbc26f1d7b72c95e9bbece2cca10b96d2413ef4174fc0829e2213f68350eb0cd249a5c07bdf80f7cc4084ce937b69fb8df164d1f7dabdb1b720e81978e0
7
+ data.tar.gz: 0c2904182336f09a377e5d2579aa39a810520abdd7fc518d3b4bd69f5504e8753730df153045a09f84d0b975055ec5fa92cf456348599cda1ba086ab976aab12
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  GIT
2
2
  remote: git://github.com/puppetlabs/packaging
3
- revision: 48564f11abbc1f61a159d9caa44c8236d910575a
3
+ revision: 4c5359786cad0d12877e10e98948065bfeb3e304
4
4
  branch: 1.0.x
5
5
  specs:
6
- packaging (0.99.81)
6
+ packaging (0.103.0)
7
7
  artifactory (~> 2)
8
8
  csv (= 3.1.5)
9
9
  rake (>= 12.3)
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- puppet (6.25.0)
15
+ puppet (6.25.1)
16
16
  CFPropertyList (~> 2.2)
17
17
  concurrent-ruby (~> 1.0)
18
18
  deep_merge (~> 1.0)
@@ -302,9 +302,16 @@ class Puppet::Configurer
302
302
  # We only need to find out the environment to run in if we don't already have a catalog
303
303
  unless (cached_catalog || options[:catalog] || Puppet.settings.set_by_cli?(:environment) || Puppet[:strict_environment_mode])
304
304
  Puppet.debug(_("Environment not passed via CLI and no catalog was given, attempting to find out the last server-specified environment"))
305
- if last_server_specified_environment
306
- @environment = last_server_specified_environment
307
- report.environment = last_server_specified_environment
305
+ initial_environment, loaded_last_environment = last_server_specified_environment
306
+
307
+ unless loaded_last_environment
308
+ Puppet.debug(_("Requesting environment from the server"))
309
+ initial_environment = current_server_specified_environment(@environment, configured_environment, options)
310
+ end
311
+
312
+ if initial_environment
313
+ @environment = initial_environment
314
+ report.environment = initial_environment
308
315
 
309
316
  push_current_environment_and_loaders
310
317
  else
@@ -463,24 +470,77 @@ class Puppet::Configurer
463
470
  end
464
471
  private :find_functional_server
465
472
 
473
+ #
474
+ # @api private
475
+ #
476
+ # Read the last server-specified environment from the lastrunfile. The
477
+ # environment is considered to be server-specified if the values of
478
+ # `initial_environment` and `converged_environment` are different.
479
+ #
480
+ # @return [String, Boolean] An array containing a string with the environment
481
+ # read from the lastrunfile in case the server is authoritative, and a
482
+ # boolean marking whether the last environment was correctly loaded.
466
483
  def last_server_specified_environment
467
- return @last_server_specified_environment if @last_server_specified_environment
484
+ return @last_server_specified_environment, @loaded_last_environment if @last_server_specified_environment
485
+
468
486
  if Puppet::FileSystem.exist?(Puppet[:lastrunfile])
469
487
  summary = Puppet::Util::Yaml.safe_load_file(Puppet[:lastrunfile])
470
- return unless summary.dig('application', 'run_mode') == 'agent'
471
- initial_environment = summary.dig('application', 'initial_environment')
472
- converged_environment = summary.dig('application', 'converged_environment')
488
+ return [nil, nil] unless summary['application']['run_mode'] == 'agent'
489
+ initial_environment = summary['application']['initial_environment']
490
+ converged_environment = summary['application']['converged_environment']
473
491
  @last_server_specified_environment = converged_environment if initial_environment != converged_environment
492
+ Puppet.debug(_("Successfully loaded last environment from the lastrunfile"))
493
+ @loaded_last_environment = true
474
494
  end
475
495
 
476
496
  Puppet.debug(_("Found last server-specified environment: %{environment}") % { environment: @last_server_specified_environment }) if @last_server_specified_environment
477
- @last_server_specified_environment
497
+ [@last_server_specified_environment, @loaded_last_environment]
478
498
  rescue => detail
479
499
  Puppet.debug(_("Could not find last server-specified environment: %{detail}") % { detail: detail })
480
- nil
500
+ [nil, nil]
481
501
  end
482
502
  private :last_server_specified_environment
483
503
 
504
+ def current_server_specified_environment(current_environment, configured_environment, options)
505
+ return @server_specified_environment if @server_specified_environment
506
+
507
+ begin
508
+ node_retr_time = thinmark do
509
+ node = Puppet::Node.indirection.find(Puppet[:node_name_value],
510
+ :environment => Puppet::Node::Environment.remote(current_environment),
511
+ :configured_environment => configured_environment,
512
+ :ignore_cache => true,
513
+ :transaction_uuid => @transaction_uuid,
514
+ :fail_on_404 => true)
515
+
516
+ # The :rest node terminus returns a node with an environment_name, but not an
517
+ # environment instance. Attempting to get the environment instance will load
518
+ # it from disk, which will likely fail. So create a remote environment.
519
+ #
520
+ # The :plain node terminus returns a node with an environment, but not an
521
+ # environment_name.
522
+ if !node.has_environment_instance? && node.environment_name
523
+ node.environment = Puppet::Node::Environment.remote(node.environment_name)
524
+ end
525
+
526
+ @server_specified_environment = node.environment.to_s
527
+
528
+ if @server_specified_environment != @environment
529
+ Puppet.notice _("Local environment: '%{local_env}' doesn't match server specified node environment '%{node_env}', switching agent to '%{node_env}'.") % { local_env: @environment, node_env: @server_specified_environment }
530
+ end
531
+ end
532
+
533
+ options[:report].add_times(:node_retrieval, node_retr_time)
534
+
535
+ @server_specified_environment
536
+ rescue => detail
537
+ Puppet.warning(_("Unable to fetch my node definition, but the agent run will continue:"))
538
+ Puppet.warning(detail)
539
+ nil
540
+ end
541
+ end
542
+ private :current_server_specified_environment
543
+
484
544
  def send_report(report)
485
545
  puts report.summary if Puppet[:summarize]
486
546
  save_last_run_summary(report)
@@ -800,6 +800,12 @@ Valid values are 0 (never cache) and 15 (15 second minimum wait time).
800
800
  :owner => "service",
801
801
  :group => "service",
802
802
  :desc => "The directory where catalog previews per node are generated."
803
+ },
804
+ :location_trusted => {
805
+ :default => false,
806
+ :type => :boolean,
807
+ :desc => "This will allow sending the name + password and the cookie header to all hosts that puppet may redirect to.
808
+ This may or may not introduce a security breach if puppet redirects you to a site to which you'll send your authentication info and cookies."
803
809
  }
804
810
  )
805
811
 
@@ -303,7 +303,7 @@ class Puppet::HTTP::Client
303
303
 
304
304
  while !done do
305
305
  connect(request.uri, options: options) do |http|
306
- apply_auth(request, basic_auth)
306
+ apply_auth(request, basic_auth) if redirects.zero?
307
307
 
308
308
  # don't call return within the `request` block
309
309
  http.request(request) do |nethttp|
@@ -57,6 +57,11 @@ class Puppet::HTTP::Redirector
57
57
  new_request = request.class.new(url)
58
58
  new_request.body = request.body
59
59
  request.each do |header, value|
60
+ unless Puppet[:location_trusted]
61
+ # skip adding potentially sensitive header to other hosts
62
+ next if header.casecmp('Authorization').zero? && request.uri.host.casecmp(location.host) != 0
63
+ next if header.casecmp('Cookie').zero? && request.uri.host.casecmp(location.host) != 0
64
+ end
60
65
  new_request[header] = value
61
66
  end
62
67
 
@@ -13,7 +13,7 @@ class Puppet::Parser::Resource < Puppet::Resource
13
13
 
14
14
  attr_accessor :source, :scope, :collector_id
15
15
  attr_accessor :virtual, :override, :translated, :catalog, :evaluated
16
- attr_accessor :file, :line
16
+ attr_accessor :file, :line, :kind
17
17
 
18
18
  attr_reader :exported, :parameters
19
19
 
@@ -219,16 +219,15 @@ class Closure < CallableSignature
219
219
  def call_with_scope(scope, args)
220
220
  variable_bindings = combine_values_with_parameters(scope, args)
221
221
 
222
- tc = Types::TypeCalculator.singleton
223
- final_args = tc.infer_set(parameters.reduce([]) do |tmp_args, param|
222
+ final_args = parameters.reduce([]) do |tmp_args, param|
224
223
  if param.captures_rest
225
224
  tmp_args.concat(variable_bindings[param.name])
226
225
  else
227
226
  tmp_args << variable_bindings[param.name]
228
227
  end
229
- end)
228
+ end
230
229
 
231
- if type.callable?(final_args)
230
+ if type.callable_with?(final_args, block_type)
232
231
  result = catch(:next) do
233
232
  @evaluator.evaluate_block_with_bindings(scope, variable_bindings, @model.body)
234
233
  end
@@ -236,7 +235,9 @@ class Closure < CallableSignature
236
235
  "value returned from #{closure_name}"
237
236
  end
238
237
  else
239
- raise ArgumentError, Types::TypeMismatchDescriber.describe_signatures(closure_name, [self], final_args)
238
+ tc = Types::TypeCalculator.singleton
239
+ args_type = tc.infer_set(final_args)
240
+ raise ArgumentError, Types::TypeMismatchDescriber.describe_signatures(closure_name, [self], args_type)
240
241
  end
241
242
  end
242
243
 
@@ -309,6 +310,7 @@ class Closure < CallableSignature
309
310
  to += param_range[1]
310
311
  end
311
312
  param_types = Types::PTupleType.new(types, Types::PIntegerType.new(from, to))
313
+ # The block_type for a Closure is always nil for now, see comment in block_name above
312
314
  Types::PCallableType.new(param_types, nil, return_type)
313
315
  end
314
316
 
@@ -40,6 +40,7 @@ module Runtime3ResourceSupport
40
40
  :parameters => evaluated_parameters,
41
41
  :file => file,
42
42
  :line => line,
43
+ :kind => Puppet::Resource.to_kind(resolved_type),
43
44
  :exported => exported,
44
45
  :virtual => virtual,
45
46
  # WTF is this? Which source is this? The file? The name of the context ?
@@ -315,7 +315,7 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
315
315
  super()
316
316
  @name = name
317
317
  @catalog_uuid = SecureRandom.uuid
318
- @catalog_format = 1
318
+ @catalog_format = 2
319
319
  @metadata = {}
320
320
  @recursive_metadata = {}
321
321
  @classes = []
@@ -11,7 +11,7 @@ class Puppet::Resource
11
11
  include Puppet::Util::PsychSupport
12
12
 
13
13
  include Enumerable
14
- attr_accessor :file, :line, :catalog, :exported, :virtual, :strict
14
+ attr_accessor :file, :line, :catalog, :exported, :virtual, :strict, :kind
15
15
  attr_reader :type, :title, :parameters
16
16
 
17
17
  # @!attribute [rw] sensitive_parameters
@@ -29,11 +29,16 @@ class Puppet::Resource
29
29
  EMPTY_ARRAY = [].freeze
30
30
  EMPTY_HASH = {}.freeze
31
31
 
32
- ATTRIBUTES = [:file, :line, :exported].freeze
32
+ ATTRIBUTES = [:file, :line, :exported, :kind].freeze
33
33
  TYPE_CLASS = 'Class'.freeze
34
34
  TYPE_NODE = 'Node'.freeze
35
35
  TYPE_SITE = 'Site'.freeze
36
36
 
37
+ CLASS_STRING = 'class'.freeze
38
+ DEFINED_TYPE_STRING = 'defined_type'.freeze
39
+ COMPILABLE_TYPE_STRING = 'compilable_type'.freeze
40
+ UNKNOWN_TYPE_STRING = 'unknown'.freeze
41
+
37
42
  PCORE_TYPE_KEY = '__ptype'.freeze
38
43
  VALUE_KEY = 'value'.freeze
39
44
 
@@ -194,6 +199,18 @@ class Puppet::Resource
194
199
  resource_type.is_a?(Puppet::CompilableResourceType)
195
200
  end
196
201
 
202
+ def self.to_kind(resource_type)
203
+ if resource_type == CLASS_STRING
204
+ CLASS_STRING
205
+ elsif resource_type.is_a?(Puppet::Resource::Type) && resource_type.type == :definition
206
+ DEFINED_TYPE_STRING
207
+ elsif resource_type.is_a?(Puppet::CompilableResourceType)
208
+ COMPILABLE_TYPE_STRING
209
+ else
210
+ UNKNOWN_TYPE_STRING
211
+ end
212
+ end
213
+
197
214
  # Iterate over each param/value pair, as required for Enumerable.
198
215
  def each
199
216
  parameters.each { |p,v| yield p, v }
@@ -248,6 +265,7 @@ class Puppet::Resource
248
265
  src = type
249
266
  self.file = src.file
250
267
  self.line = src.line
268
+ self.kind = src.kind
251
269
  self.exported = src.exported
252
270
  self.virtual = src.virtual
253
271
  self.set_tags(src)
@@ -310,6 +328,7 @@ class Puppet::Resource
310
328
 
311
329
  rt = resource_type
312
330
 
331
+ self.kind = self.class.to_kind(rt) unless kind
313
332
  if strict? && rt.nil?
314
333
  if self.class?
315
334
  raise ArgumentError, _("Could not find declared class %{title}") % { title: title }
@@ -493,10 +512,24 @@ class Puppet::Resource
493
512
  ref
494
513
  end
495
514
 
496
- # Convert our resource to a RAL resource instance. Creates component
497
- # instances for resource types that don't exist.
515
+ # Convert our resource to a RAL resource instance. Creates component
516
+ # instances for resource types that are not of a compilable_type kind. In case
517
+ # the resource doesn’t exist and it’s compilable_type kind, raise an error.
518
+ # There are certain cases where a resource won't be in a catalog, such as
519
+ # when we create a resource directly by using Puppet::Resource.new(...), so we
520
+ # must check its kind before deciding whether the catalog format is of an older
521
+ # version or not.
498
522
  def to_ral
499
- typeklass = Puppet::Type.type(self.type) || Puppet::Type.type(:component)
523
+ if self.kind == COMPILABLE_TYPE_STRING
524
+ typeklass = Puppet::Type.type(self.type)
525
+ elsif self.catalog && self.catalog.catalog_format >= 2
526
+ typeklass = Puppet::Type.type(:component)
527
+ else
528
+ typeklass = Puppet::Type.type(self.type) || Puppet::Type.type(:component)
529
+ end
530
+
531
+ raise(Puppet::Error, "Resource type '#{self.type}' was not found") unless typeklass
532
+
500
533
  typeklass.new(self)
501
534
  end
502
535
 
@@ -13,11 +13,6 @@ module Puppet::Util::Windows
13
13
 
14
14
  FILE = Puppet::Util::Windows::File
15
15
 
16
- # integer value of the floor for timeouts when waiting for service pending states.
17
- # puppet will wait the length of dwWaitHint if it is longer than this value, but
18
- # no shorter
19
- DEFAULT_TIMEOUT = 30
20
-
21
16
  # Service error codes
22
17
  # https://docs.microsoft.com/en-us/windows/desktop/debug/system-error-codes--1000-1299-
23
18
  ERROR_SERVICE_DOES_NOT_EXIST = 0x00000424
@@ -9,6 +9,9 @@ module Puppet::Util::Windows
9
9
  module File; end
10
10
  module Registry
11
11
  end
12
+ module Service
13
+ DEFAULT_TIMEOUT = 30
14
+ end
12
15
  module SID
13
16
  class Principal; end
14
17
  end
@@ -6,7 +6,7 @@
6
6
  # Raketasks and such to set the version based on the output of `git describe`
7
7
 
8
8
  module Puppet
9
- PUPPETVERSION = '6.25.0'
9
+ PUPPETVERSION = '6.25.1'
10
10
 
11
11
  ##
12
12
  # version is a public API method intended to always provide a fast and
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPETCONF" "5" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPETCONF" "5" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  \fBThis page is autogenerated; any changes will get overwritten\fR
6
6
  .
7
7
  .SH "Configuration settings"
@@ -945,7 +945,7 @@ The time to wait for data to be read from an HTTP connection\. If nothing is rea
945
945
  The HTTP User\-Agent string to send when making network requests\.
946
946
  .
947
947
  .IP "\(bu" 4
948
- \fIDefault\fR: \fBPuppet/6\.25\.0 Ruby/2\.5\.1\-p57 (x86_64\-linux)\fR
948
+ \fIDefault\fR: \fBPuppet/6\.25\.1 Ruby/2\.5\.1\-p57 (x86_64\-linux)\fR
949
949
  .
950
950
  .IP "" 0
951
951
  .
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-AGENT" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-AGENT" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-agent\fR \- The puppet agent daemon
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-APPLY" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-APPLY" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-apply\fR \- Apply Puppet manifests locally
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-CATALOG" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-CATALOG" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-catalog\fR \- Compile, save, view, and convert catalogs\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-CONFIG" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-CONFIG" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-config\fR \- Interact with Puppet\'s settings\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-DESCRIBE" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-DESCRIBE" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-describe\fR \- Display help about resource types
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-DEVICE" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-DEVICE" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-device\fR \- Manage remote network devices
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-DOC" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-DOC" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-doc\fR \- Generate Puppet references
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-EPP" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-EPP" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-epp\fR \- Interact directly with the EPP template parser/renderer\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-FACTS" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-FACTS" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-facts\fR \- Retrieve and store facts\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-FILEBUCKET" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-FILEBUCKET" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-filebucket\fR \- Store and retrieve files in a filebucket
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-GENERATE" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-GENERATE" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-generate\fR \- Generates Puppet code from Ruby definitions\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-HELP" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-HELP" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-help\fR \- Display Puppet help\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-KEY" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-KEY" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-key\fR \- Create, save, and remove certificate keys\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-LOOKUP" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-LOOKUP" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-lookup\fR \- Interactive Hiera lookup
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-MAN" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-MAN" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-man\fR \- Display Puppet manual pages\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-MODULE" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-MODULE" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-module\fR \- Creates, installs and searches for modules on the Puppet Forge\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-NODE" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-NODE" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-node\fR \- View and manage node definitions\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-PARSER" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-PARSER" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-parser\fR \- Interact directly with the parser\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-PLUGIN" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-PLUGIN" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-plugin\fR \- Interact with the Puppet plugin system\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-REPORT" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-REPORT" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-report\fR \- Create, display, and submit reports\.
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-RESOURCE" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-RESOURCE" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-resource\fR \- The resource abstraction layer shell
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-SCRIPT" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-SCRIPT" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-script\fR \- Run a puppet manifests as a script without compiling a catalog
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-SSL" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-SSL" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-ssl\fR \- Manage SSL keys and certificates for puppet SSL clients
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET\-STATUS" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-STATUS" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-status\fR \- View puppet server status\.
data/man/man8/puppet.8 CHANGED
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET" "8" "September 2021" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET" "8" "October 2021" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\fR
@@ -25,4 +25,4 @@ Specialized:
25
25
  catalog Compile, save, view, and convert catalogs\. describe Display help about resource types device Manage remote network devices doc Generate Puppet references epp Interact directly with the EPP template parser/renderer\. facts Retrieve and store facts\. filebucket Store and retrieve files in a filebucket generate Generates Puppet code from Ruby definitions\. node View and manage node definitions\. parser Interact directly with the parser\. plugin Interact with the Puppet plugin system\. script Run a puppet manifests as a script without compiling a catalog ssl Manage SSL keys and certificates for puppet SSL clients
26
26
  .
27
27
  .P
28
- See \'puppet help \fIsubcommand\fR \fIaction\fR\' for help on a specific subcommand action\. See \'puppet help \fIsubcommand\fR\' for help on a specific subcommand\. Puppet v6\.25\.0
28
+ See \'puppet help \fIsubcommand\fR \fIaction\fR\' for help on a specific subcommand action\. See \'puppet help \fIsubcommand\fR\' for help on a specific subcommand\. Puppet v6\.25\.1
@@ -6,7 +6,7 @@
6
6
  "version": 1607629733,
7
7
  "code_id": null,
8
8
  "catalog_uuid": "afc8472a-306b-4b24-b060-e956dffb79b8",
9
- "catalog_format": 1,
9
+ "catalog_format": 2,
10
10
  "environment": "production",
11
11
  "resources": [
12
12
  {
@@ -50,6 +50,7 @@
50
50
  ],
51
51
  "file": "",
52
52
  "line": 1,
53
+ "kind": "compilable_type",
53
54
  "exported": false,
54
55
  "parameters": {
55
56
  "message": {
@@ -642,6 +642,34 @@ describe "puppet agent", unless: Puppet::Util::Platform.jruby? do
642
642
  end
643
643
 
644
644
  context "environment convergence" do
645
+ it "falls back to making a node request if the last server-specified environment cannot be loaded" do
646
+ mounts = {}
647
+ mounts[:node] = -> (req, res) {
648
+ node = Puppet::Node.new('test', environment: Puppet::Node::Environment.remote('doesnotexistonagent'))
649
+ res.body = formatter.render(node)
650
+ res['Content-Type'] = formatter.mime
651
+ }
652
+
653
+ server.start_server(mounts: mounts) do |port|
654
+ Puppet[:serverport] = port
655
+ Puppet[:log_level] = 'debug'
656
+
657
+ expect {
658
+ agent.command_line.args << '--test'
659
+ agent.run
660
+ }.to exit_with(0)
661
+ .and output(a_string_matching(%r{Debug: Requesting environment from the server})).to_stdout
662
+
663
+ Puppet::Application.clear!
664
+
665
+ expect {
666
+ agent.command_line.args << '--test'
667
+ agent.run
668
+ }.to exit_with(0)
669
+ .and output(a_string_matching(%r{Debug: Successfully loaded last environment from the lastrunfile})).to_stdout
670
+ end
671
+ end
672
+
645
673
  it "switches to 'newenv' environment and retries the run" do
646
674
  first_run = true
647
675
  libdir = File.join(my_fixture_dir, 'lib')
@@ -136,6 +136,16 @@ describe 'when pcore described resources types are in use' do
136
136
  expect(catalog.resource(:cap, "c")['message']).to eq('c works')
137
137
  end
138
138
 
139
+ it 'considers Pcore types to be builtin ' do
140
+ genface.types
141
+ catalog = compile_to_catalog(<<-MANIFEST)
142
+ test1 { 'a':
143
+ message => 'a works'
144
+ }
145
+ MANIFEST
146
+ expect(catalog.resource(:test1, "a").kind).to eq('compilable_type')
147
+ end
148
+
139
149
  it 'the validity of attribute names are checked' do
140
150
  genface.types
141
151
  expect do
@@ -2,6 +2,8 @@ require 'spec_helper'
2
2
  require 'puppet/configurer'
3
3
 
4
4
  describe Puppet::Configurer do
5
+ include PuppetSpec::Files
6
+
5
7
  before do
6
8
  Puppet[:server] = "puppetmaster"
7
9
  Puppet[:report] = true
@@ -10,6 +12,17 @@ describe Puppet::Configurer do
10
12
  allow_any_instance_of(described_class).to(
11
13
  receive(:valid_server_environment?).and_return(true)
12
14
  )
15
+
16
+ Puppet[:lastrunfile] = file_containing('last_run_summary.yaml', <<~SUMMARY)
17
+ ---
18
+ version:
19
+ config: 1624882680
20
+ puppet: #{Puppet.version}
21
+ application:
22
+ initial_environment: #{Puppet[:environment]}
23
+ converged_environment: #{Puppet[:environment]}
24
+ run_mode: agent
25
+ SUMMARY
13
26
  end
14
27
 
15
28
  let(:node_name) { Puppet[:node_name_value] }
@@ -742,7 +755,7 @@ describe Puppet::Configurer do
742
755
  expect(configurer.run).to be_nil
743
756
  end
744
757
 
745
- it "should proceed with the cached catalog if its environment matchs the local environment" do
758
+ it "should proceed with the cached catalog if its environment matches the local environment" do
746
759
  expects_cached_catalog_only(catalog)
747
760
 
748
761
  expect(configurer.run).to eq(0)
@@ -1099,7 +1112,6 @@ describe Puppet::Configurer do
1099
1112
  end
1100
1113
 
1101
1114
  describe "when selecting an environment" do
1102
- include PuppetSpec::Files
1103
1115
  include PuppetSpec::Settings
1104
1116
 
1105
1117
  describe "when the last used environment is available" do
@@ -1116,6 +1128,9 @@ describe Puppet::Configurer do
1116
1128
  converged_environment: #{last_server_specified_environment}
1117
1129
  run_mode: agent
1118
1130
  SUMMARY
1131
+
1132
+ expect(Puppet::Node.indirection).not_to receive(:find)
1133
+ .with(anything, hash_including(:ignore_cache => true, :fail_on_404 => true))
1119
1134
  end
1120
1135
 
1121
1136
  it "prefers the environment set via cli" do
@@ -1125,26 +1140,27 @@ describe Puppet::Configurer do
1125
1140
  expect(configurer.environment).to eq('usethis')
1126
1141
  end
1127
1142
 
1128
- it "prefers the environment set via config" do
1143
+ it "prefers the environment set via lastrunfile over config" do
1129
1144
  FileUtils.mkdir_p(Puppet[:confdir])
1130
1145
  set_puppet_conf(Puppet[:confdir], <<~CONF)
1131
1146
  [main]
1132
1147
  environment = usethis
1148
+ lastrunfile = #{Puppet[:lastrunfile]}
1133
1149
  CONF
1134
1150
 
1135
1151
  Puppet.initialize_settings
1136
1152
  configurer.run
1137
1153
 
1138
- expect(configurer.environment).to eq('usethis')
1154
+ expect(configurer.environment).to eq(last_server_specified_environment)
1139
1155
  end
1140
1156
 
1141
- it "uses environment from Puppet[:environment] if given a catalog" do
1157
+ it "uses the environment from Puppet[:environment] if given a catalog" do
1142
1158
  configurer.run(catalog: catalog)
1143
1159
 
1144
1160
  expect(configurer.environment).to eq(Puppet[:environment])
1145
1161
  end
1146
1162
 
1147
- it "uses environment from Puppet[:environment] if use_cached_catalog = true" do
1163
+ it "uses the environment from Puppet[:environment] if use_cached_catalog = true" do
1148
1164
  Puppet[:use_cached_catalog] = true
1149
1165
  expects_cached_catalog_only(catalog)
1150
1166
  configurer.run
@@ -1173,14 +1189,14 @@ describe Puppet::Configurer do
1173
1189
  configurer.run
1174
1190
  end
1175
1191
 
1176
- it "uses environment from Puppet[:environment] if strict_environment_mode is set" do
1192
+ it "uses the environment from Puppet[:environment] if strict_environment_mode is set" do
1177
1193
  Puppet[:strict_environment_mode] = true
1178
1194
  configurer.run
1179
1195
 
1180
1196
  expect(configurer.environment).to eq(Puppet[:environment])
1181
1197
  end
1182
1198
 
1183
- it "uses environment from Puppet[:environment] if initial_environment is the same as converged_environment" do
1199
+ it "uses the environment from Puppet[:environment] if initial_environment is the same as converged_environment" do
1184
1200
  Puppet[:lastrunfile] = file_containing('last_run_summary.yaml', <<~SUMMARY)
1185
1201
  ---
1186
1202
  version:
@@ -1195,41 +1211,86 @@ describe Puppet::Configurer do
1195
1211
 
1196
1212
  expect(configurer.environment).to eq(Puppet[:environment])
1197
1213
  end
1214
+ end
1215
+ end
1216
+
1217
+ describe "when the last used environment is not available" do
1218
+ describe "when the node request succeeds" do
1219
+ let(:node_environment) { Puppet::Node::Environment.remote(:salam) }
1220
+ let(:node) { Puppet::Node.new(Puppet[:node_name_value]) }
1221
+ let(:last_server_specified_environment) { 'development' }
1222
+
1223
+ before do
1224
+ node.environment = node_environment
1225
+
1226
+ allow(Puppet::Node.indirection).to receive(:find)
1227
+ allow(Puppet::Node.indirection).to receive(:find)
1228
+ .with(anything, hash_including(:ignore_cache => true, :fail_on_404 => true))
1229
+ .and_return(node)
1230
+ end
1198
1231
 
1199
- it "uses environment from Puppet[:environment] if the run mode doesn't match" do
1232
+ it "uses the environment from the node request if the run mode doesn't match" do
1200
1233
  Puppet[:lastrunfile] = file_containing('last_run_summary.yaml', <<~SUMMARY)
1201
- ---
1202
- version:
1203
- config: 1624882680
1204
- puppet: 6.24.0
1205
- application:
1206
- initial_environment: #{Puppet[:environment]}
1207
- converged_environment: #{last_server_specified_environment}
1208
- run_mode: user
1234
+ ---
1235
+ version:
1236
+ config: 1624882680
1237
+ puppet: 6.24.0
1238
+ application:
1239
+ initial_environment: #{Puppet[:environment]}
1240
+ converged_environment: #{last_server_specified_environment}
1241
+ run_mode: user
1209
1242
  SUMMARY
1210
1243
  configurer.run
1211
1244
 
1212
- expect(configurer.environment).to eq(Puppet[:environment])
1245
+ expect(configurer.environment).to eq(node_environment.name.to_s)
1213
1246
  end
1214
1247
 
1215
- it "uses environment from Puppet[:environment] if lastrunfile is invalid YAML" do
1248
+ it "uses the environment from the node request if lastrunfile does not contain the expected keys" do
1216
1249
  Puppet[:lastrunfile] = file_containing('last_run_summary.yaml', <<~SUMMARY)
1217
- Key: 'this is my very very very ' +
1218
- 'long string'
1250
+ ---
1251
+ version:
1252
+ config: 1624882680
1253
+ puppet: 6.24.0
1219
1254
  SUMMARY
1220
1255
  configurer.run
1221
1256
 
1222
- expect(configurer.environment).to eq(Puppet[:environment])
1257
+ expect(configurer.environment).to eq(node_environment.name.to_s)
1223
1258
  end
1224
1259
 
1225
- it "uses environment from Puppet[:environment] if lastrunfile exists but is empty" do
1260
+ it "uses the environment from the node request if lastrunfile is invalid YAML" do
1261
+ Puppet[:lastrunfile] = file_containing('last_run_summary.yaml', <<~SUMMARY)
1262
+ Key: 'this is my very very very ' +
1263
+ 'long string'
1264
+ SUMMARY
1265
+ configurer.run
1266
+
1267
+ expect(configurer.environment).to eq(node_environment.name.to_s)
1268
+ end
1269
+
1270
+ it "uses the environment from the node request if lastrunfile exists but is empty" do
1226
1271
  Puppet[:lastrunfile] = file_containing('last_run_summary.yaml', '')
1227
1272
  configurer.run
1228
1273
 
1229
- expect(configurer.environment).to eq(Puppet[:environment])
1274
+ expect(configurer.environment).to eq(node_environment.name.to_s)
1275
+ end
1276
+
1277
+ it "uses the environment from the node request if the last used one cannot be found" do
1278
+ Puppet[:lastrunfile] = tmpfile('last_run_summary.yaml')
1279
+ configurer.run
1280
+
1281
+ expect(configurer.environment).to eq(node_environment.name.to_s)
1282
+ end
1283
+ end
1284
+
1285
+ describe "when the node request fails" do
1286
+ before do
1287
+ allow(Puppet::Node.indirection).to receive(:find).and_call_original
1288
+ allow(Puppet::Node.indirection).to receive(:find)
1289
+ .with(anything, hash_including(:ignore_cache => true, :fail_on_404 => true))
1290
+ .and_raise(Puppet::Error)
1230
1291
  end
1231
1292
 
1232
- it "uses environment from Puppet[:environment] if the last used one cannot be found" do
1293
+ it "uses the environment from Puppet[:environment] if the last used one cannot be found" do
1233
1294
  Puppet[:lastrunfile] = tmpfile('last_run_summary.yaml')
1234
1295
  configurer.run
1235
1296
 
@@ -597,11 +597,68 @@ describe Puppet::HTTP::Client do
597
597
  expect(response).to be_success
598
598
  end
599
599
 
600
- it "preserves basic authorization" do
600
+ it "does not preserve basic authorization when redirecting to different hosts" do
601
+ stub_request(:get, start_url).with(basic_auth: credentials).to_return(redirect_to(url: other_host))
602
+ stub_request(:get, other_host).to_return(status: 200)
603
+
604
+ client.get(start_url, options: {basic_auth: {user: 'user', password: 'pass'}})
605
+ expect(a_request(:get, other_host).
606
+ with{ |req| !req.headers.key?('Authorization')}).to have_been_made
607
+ end
608
+
609
+ it "does preserve basic authorization when redirecting to the same hosts" do
610
+ stub_request(:get, start_url).with(basic_auth: credentials).to_return(redirect_to(url: bar_url))
611
+ stub_request(:get, bar_url).with(basic_auth: credentials).to_return(status: 200)
612
+
613
+ client.get(start_url, options: {basic_auth: {user: 'user', password: 'pass'}})
614
+ expect(a_request(:get, bar_url).
615
+ with{ |req| req.headers.key?('Authorization')}).to have_been_made
616
+ end
617
+
618
+ it "does not preserve cookie header when redirecting to different hosts" do
619
+ headers = { 'Cookie' => 'TEST_COOKIE'}
620
+
621
+ stub_request(:get, start_url).with(headers: headers).to_return(redirect_to(url: other_host))
622
+ stub_request(:get, other_host).to_return(status: 200)
623
+
624
+ client.get(start_url, headers: headers)
625
+ expect(a_request(:get, other_host).
626
+ with{ |req| !req.headers.key?('Cookie')}).to have_been_made
627
+ end
628
+
629
+ it "does preserve cookie header when redirecting to the same hosts" do
630
+ headers = { 'Cookie' => 'TEST_COOKIE'}
631
+
632
+ stub_request(:get, start_url).with(headers: headers).to_return(redirect_to(url: bar_url))
633
+ stub_request(:get, bar_url).with(headers: headers).to_return(status: 200)
634
+
635
+ client.get(start_url, headers: headers)
636
+ expect(a_request(:get, bar_url).
637
+ with{ |req| req.headers.key?('Cookie')}).to have_been_made
638
+ end
639
+
640
+ it "does preserves cookie header and basic authentication when Puppet[:location_trusted] is true redirecting to different hosts" do
641
+ headers = { 'cookie' => 'TEST_COOKIE'}
642
+ Puppet[:location_trusted] = true
643
+
644
+ stub_request(:get, start_url).with(headers: headers, basic_auth: credentials).to_return(redirect_to(url: other_host))
645
+ stub_request(:get, other_host).with(headers: headers, basic_auth: credentials).to_return(status: 200)
646
+
647
+ client.get(start_url, headers: headers, options: {basic_auth: {user: 'user', password: 'pass'}})
648
+ expect(a_request(:get, other_host).
649
+ with{ |req| req.headers.key?('Authorization') && req.headers.key?('Cookie')}).to have_been_made
650
+ end
651
+
652
+ it "treats hosts as case-insensitive" do
653
+ start_url = URI("https://www.EXAmple.com:8140/Start")
654
+ bar_url = "https://www.example.com:8140/bar"
655
+
601
656
  stub_request(:get, start_url).with(basic_auth: credentials).to_return(redirect_to(url: bar_url))
602
657
  stub_request(:get, bar_url).with(basic_auth: credentials).to_return(status: 200)
603
658
 
604
659
  client.get(start_url, options: {basic_auth: {user: 'user', password: 'pass'}})
660
+ expect(a_request(:get, bar_url).
661
+ with{ |req| req.headers.key?('Authorization')}).to have_been_made
605
662
  end
606
663
 
607
664
  it "redirects given a relative location" do
@@ -104,7 +104,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
104
104
 
105
105
  it "should include the current catalog_format" do
106
106
  catalog = Puppet::Resource::Catalog.new("host")
107
- expect(catalog.catalog_format).to eq(1)
107
+ expect(catalog.catalog_format).to eq(2)
108
108
  end
109
109
 
110
110
  describe "when compiling" do
@@ -178,6 +178,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
178
178
  @original.add_edge(@middle, @bottom)
179
179
  @original.add_edge(@bottom, @bottomobject)
180
180
 
181
+ @original.catalog_format = 1
181
182
  @catalog = @original.to_ral
182
183
  end
183
184
 
@@ -190,6 +191,18 @@ describe Puppet::Resource::Catalog, "when compiling" do
190
191
  end
191
192
  end
192
193
 
194
+ it "should raise if an unknown resource is being converted" do
195
+ @new_res = Puppet::Resource.new "Unknown", "type", :kind => 'compilable_type'
196
+ @resource_array = [@new_res]
197
+
198
+ @original.add_resource(*@resource_array)
199
+ @original.add_edge(@bottomobject, @new_res)
200
+
201
+ @original.catalog_format = 2
202
+
203
+ expect { @original.to_ral }.to raise_error(Puppet::Error, "Resource type 'Unknown' was not found")
204
+ end
205
+
193
206
  it "should copy the tag list to the new catalog" do
194
207
  expect(@catalog.tags.sort).to eq(@original.tags.sort)
195
208
  end
@@ -694,19 +694,68 @@ describe Puppet::Resource do
694
694
  it "should use the resource type's :new method to create the resource if the resource is of a builtin type" do
695
695
  resource = Puppet::Resource.new("file", basepath+"/my/file")
696
696
  result = resource.to_ral
697
+
697
698
  expect(result).to be_instance_of(Puppet::Type.type(:file))
698
699
  expect(result[:path]).to eq(basepath+"/my/file")
699
700
  end
700
701
 
701
- it "should convert to a component instance if the resource type is not of a builtin type" do
702
+ it "should convert to a component instance if the resource is not a compilable_type" do
702
703
  resource = Puppet::Resource.new("foobar", "somename")
703
704
  result = resource.to_ral
704
705
 
705
706
  expect(result).to be_instance_of(Puppet::Type.type(:component))
706
707
  expect(result.title).to eq("Foobar[somename]")
707
708
  end
708
- end
709
709
 
710
+ it "should convert to a component instance if the resource is a class" do
711
+ resource = Puppet::Resource.new("Class", "somename")
712
+ result = resource.to_ral
713
+
714
+ expect(result).to be_instance_of(Puppet::Type.type(:component))
715
+ expect(result.title).to eq("Class[Somename]")
716
+ end
717
+
718
+ it "should convert to component when the resource is a defined_type" do
719
+ resource = Puppet::Resource.new("Unknown", "type", :kind => 'defined_type')
720
+
721
+ result = resource.to_ral
722
+ expect(result).to be_instance_of(Puppet::Type.type(:component))
723
+ end
724
+
725
+ it "should raise if a resource type is a compilable_type and it wasn't found" do
726
+ resource = Puppet::Resource.new("Unknown", "type", :kind => 'compilable_type')
727
+
728
+ expect { resource.to_ral }.to raise_error(Puppet::Error, "Resource type 'Unknown' was not found")
729
+ end
730
+
731
+ it "should use the old behaviour when the catalog_format is equal to 1" do
732
+ resource = Puppet::Resource.new("Unknown", "type")
733
+ catalog = Puppet::Resource::Catalog.new("mynode")
734
+
735
+ resource.catalog = catalog
736
+ resource.catalog.catalog_format = 1
737
+
738
+ result = resource.to_ral
739
+ expect(result).to be_instance_of(Puppet::Type.type(:component))
740
+ end
741
+
742
+ it "should use the new behaviour and fail when the catalog_format is greater than 1" do
743
+ resource = Puppet::Resource.new("Unknown", "type", :kind => 'compilable_type')
744
+ catalog = Puppet::Resource::Catalog.new("mynode")
745
+
746
+ resource.catalog = catalog
747
+ resource.catalog.catalog_format = 2
748
+
749
+ expect { resource.to_ral }.to raise_error(Puppet::Error, "Resource type 'Unknown' was not found")
750
+ end
751
+
752
+ it "should use the resource type when the resource doesn't respond to kind and the resource type can be found" do
753
+ resource = Puppet::Resource.new("file", basepath+"/my/file")
754
+
755
+ result = resource.to_ral
756
+ expect(result).to be_instance_of(Puppet::Type.type(:file))
757
+ end
758
+ end
710
759
  describe "when converting to puppet code" do
711
760
  before do
712
761
  @resource = Puppet::Resource.new("one::two", "/my/file",
@@ -822,6 +871,13 @@ describe Puppet::Resource do
822
871
  expect(Puppet::Resource.from_data_hash(JSON.parse(resource.to_json)).line).to eq(50)
823
872
  end
824
873
 
874
+ it "should include the kind if one is set" do
875
+ resource = Puppet::Resource.new("File", "/foo")
876
+ resource.kind = 'im_a_file'
877
+
878
+ expect(Puppet::Resource.from_data_hash(JSON.parse(resource.to_json)).kind).to eq('im_a_file')
879
+ end
880
+
825
881
  it "should include the 'exported' value if one is set" do
826
882
  resource = Puppet::Resource.new("File", "/foo")
827
883
  resource.exported = true
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: 6.25.0
4
+ version: 6.25.1
5
5
  platform: universal-darwin
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-06 00:00:00.000000000 Z
11
+ date: 2021-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: facter