puppet 5.5.0-universal-darwin → 5.5.1-universal-darwin

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.

Files changed (94) hide show
  1. data/Rakefile +1 -1
  2. data/ext/upload_facts.rb +1 -1
  3. data/lib/hiera/scope.rb +24 -2
  4. data/lib/puppet.rb +1 -1
  5. data/lib/puppet/application.rb +2 -2
  6. data/lib/puppet/application/face_base.rb +1 -1
  7. data/lib/puppet/application/resource.rb +1 -1
  8. data/lib/puppet/configurer.rb +15 -12
  9. data/lib/puppet/context.rb +1 -1
  10. data/lib/puppet/error.rb +2 -7
  11. data/lib/puppet/face/config.rb +10 -4
  12. data/lib/puppet/functions/break.rb +3 -7
  13. data/lib/puppet/functions/empty.rb +1 -3
  14. data/lib/puppet/functions/next.rb +1 -8
  15. data/lib/puppet/functions/return.rb +1 -8
  16. data/lib/puppet/functions/strftime.rb +1 -7
  17. data/lib/puppet/indirector/request.rb +6 -10
  18. data/lib/puppet/indirector/rest.rb +9 -9
  19. data/lib/puppet/module_tool/dependency.rb +1 -1
  20. data/lib/puppet/network/http/compression.rb +1 -1
  21. data/lib/puppet/network/http/connection.rb +8 -0
  22. data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +9 -2
  23. data/lib/puppet/parser/functions/create_resources.rb +1 -7
  24. data/lib/puppet/parser/functions/return.rb +22 -1
  25. data/lib/puppet/parser/scope.rb +2 -2
  26. data/lib/puppet/pops/evaluator/runtime3_support.rb +2 -7
  27. data/lib/puppet/pops/parser/epp_parser.rb +1 -1
  28. data/lib/puppet/pops/parser/lexer2.rb +1 -1
  29. data/lib/puppet/pops/puppet_stack.rb +15 -1
  30. data/lib/puppet/pops/serialization/to_data_converter.rb +5 -5
  31. data/lib/puppet/provider/augeas/augeas.rb +7 -0
  32. data/lib/puppet/provider/service/systemd.rb +1 -1
  33. data/lib/puppet/provider/user/aix.rb +1 -1
  34. data/lib/puppet/provider/yumrepo/inifile.rb +1 -0
  35. data/lib/puppet/settings.rb +9 -5
  36. data/lib/puppet/transaction/report.rb +0 -2
  37. data/lib/puppet/type/tidy.rb +4 -0
  38. data/lib/puppet/type/user.rb +34 -3
  39. data/lib/puppet/type/yumrepo.rb +4 -9
  40. data/lib/puppet/util/checksums.rb +0 -2
  41. data/lib/puppet/util/instance_loader.rb +1 -1
  42. data/lib/puppet/util/json.rb +9 -0
  43. data/lib/puppet/util/tagging.rb +16 -3
  44. data/lib/puppet/version.rb +1 -1
  45. data/locales/ja/puppet.po +318 -245
  46. data/locales/puppet.pot +65 -65
  47. data/man/man5/puppet.conf.5 +2 -2
  48. data/man/man8/puppet-agent.8 +1 -1
  49. data/man/man8/puppet-apply.8 +1 -1
  50. data/man/man8/puppet-ca.8 +1 -1
  51. data/man/man8/puppet-catalog.8 +1 -1
  52. data/man/man8/puppet-cert.8 +1 -1
  53. data/man/man8/puppet-certificate.8 +1 -1
  54. data/man/man8/puppet-certificate_request.8 +1 -1
  55. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  56. data/man/man8/puppet-config.8 +1 -1
  57. data/man/man8/puppet-describe.8 +1 -1
  58. data/man/man8/puppet-device.8 +1 -1
  59. data/man/man8/puppet-doc.8 +1 -1
  60. data/man/man8/puppet-epp.8 +1 -1
  61. data/man/man8/puppet-facts.8 +1 -1
  62. data/man/man8/puppet-filebucket.8 +1 -1
  63. data/man/man8/puppet-generate.8 +1 -1
  64. data/man/man8/puppet-help.8 +1 -1
  65. data/man/man8/puppet-key.8 +1 -1
  66. data/man/man8/puppet-lookup.8 +1 -1
  67. data/man/man8/puppet-man.8 +1 -1
  68. data/man/man8/puppet-master.8 +1 -1
  69. data/man/man8/puppet-module.8 +1 -1
  70. data/man/man8/puppet-node.8 +1 -1
  71. data/man/man8/puppet-parser.8 +1 -1
  72. data/man/man8/puppet-plugin.8 +1 -1
  73. data/man/man8/puppet-report.8 +1 -1
  74. data/man/man8/puppet-resource.8 +1 -1
  75. data/man/man8/puppet-script.8 +1 -1
  76. data/man/man8/puppet-status.8 +1 -1
  77. data/man/man8/puppet.8 +2 -2
  78. data/spec/integration/parser/compiler_spec.rb +9 -0
  79. data/spec/unit/configurer_spec.rb +31 -3
  80. data/spec/unit/face/config_spec.rb +37 -21
  81. data/spec/unit/functions/empty_spec.rb +2 -2
  82. data/spec/unit/functions/epp_spec.rb +5 -2
  83. data/spec/unit/indirector/rest_spec.rb +43 -0
  84. data/spec/unit/parser/functions/create_resources_spec.rb +1 -1
  85. data/spec/unit/pops/puppet_stack_spec.rb +38 -9
  86. data/spec/unit/provider/augeas/augeas_spec.rb +7 -1
  87. data/spec/unit/provider/service/systemd_spec.rb +1 -1
  88. data/spec/unit/provider/yumrepo/inifile_spec.rb +17 -1
  89. data/spec/unit/settings_spec.rb +43 -0
  90. data/spec/unit/transaction/report_spec.rb +1 -25
  91. data/spec/unit/type/tidy_spec.rb +2 -0
  92. data/spec/unit/type/yumrepo_spec.rb +37 -12
  93. data/spec/unit/util/tagging_spec.rb +15 -1
  94. metadata +3428 -3428
@@ -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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-CONFIG" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-DESCRIBE" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-DEVICE" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-DOC" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-EPP" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-FACTS" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-FILEBUCKET" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-GENERATE" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-HELP" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-KEY" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-LOOKUP" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-MAN" "8" "April 2018" "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\-MASTER" "8" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-MASTER" "8" "April 2018" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-master\fR \- The puppet master 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\-MODULE" "8" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-MODULE" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-NODE" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-PARSER" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-PLUGIN" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-REPORT" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-RESOURCE" "8" "April 2018" "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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-SCRIPT" "8" "April 2018" "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\-STATUS" "8" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET\-STATUS" "8" "April 2018" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\-status\fR \- View puppet server status\.
@@ -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" "March 2018" "Puppet, Inc." "Puppet manual"
4
+ .TH "PUPPET" "8" "April 2018" "Puppet, Inc." "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\fR
@@ -16,4 +16,4 @@ Available subcommands:
16
16
  agent The puppet agent daemon apply Apply Puppet manifests locally ca Local Puppet Certificate Authority management\. (Deprecated) catalog Compile, save, view, and convert catalogs\. cert Manage certificates and requests certificate Provide access to the CA for certificate management\. certificate_request Manage certificate requests\. (Deprecated) certificate_revocation_list Manage the list of revoked certificates\. (Deprecated) config Interact with Puppet\'s settings\. 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\. help Display Puppet help\. key Create, save, and remove certificate keys\. (Deprecated) lookup Interactive Hiera lookup man Display Puppet manual pages\. (Deprecated) master The puppet master daemon module Creates, installs and searches for modules on the Puppet Forge\. node View and manage node definitions\. parser Interact directly with the parser\. plugin Interact with the Puppet plugin system\. report Create, display, and submit reports\. resource The resource abstraction layer shell script Run a puppet manifests as a script without compiling a catalog status View puppet server status\. (Deprecated)
17
17
  .
18
18
  .P
19
- 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 v5\.5\.0
19
+ 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 v5\.5\.1
@@ -520,6 +520,15 @@ describe Puppet::Parser::Compiler do
520
520
  PP
521
521
  }.to raise_error(/Could not find resource 'Notify\[tooth_fairy\]' in parameter 'require'/)
522
522
  end
523
+
524
+ it 'faulty references are reported with source location' do
525
+ expect {
526
+ compile_to_catalog(<<-PP)
527
+ notify{ x :
528
+ require => tooth_fairy }
529
+ PP
530
+ }.to raise_error(/"tooth_fairy" is not a valid resource reference.*\(line: 2\)/)
531
+ end
523
532
  end
524
533
 
525
534
  describe "relationships can be formed" do
@@ -264,6 +264,12 @@ describe Puppet::Configurer do
264
264
  expect(@agent.run).to eq(1234)
265
265
  end
266
266
 
267
+ it "should return nil if catalog application fails" do
268
+ @catalog.expects(:apply).raises(Puppet::Error, 'One or more resource dependency cycles detected in graph')
269
+ report = Puppet::Transaction::Report.new
270
+ expect(@agent.run(catalog: @catalog, report: report)).to be_nil
271
+ end
272
+
267
273
  it "should send the transaction report even if the pre-run command fails" do
268
274
  report = Puppet::Transaction::Report.new
269
275
  Puppet::Transaction::Report.expects(:new).returns(report)
@@ -352,11 +358,33 @@ describe Puppet::Configurer do
352
358
  expect(@agent.run).to be_nil
353
359
  end
354
360
 
355
- it "should record the time it took to apply the catalog" do
361
+ it 'includes total time metrics in the report after successfully applying the catalog' do
356
362
  report = Puppet::Transaction::Report.new
357
363
  @catalog.stubs(:apply).with(:report => report)
358
- report.expects(:add_times).with(:catalog_application, kind_of(Numeric))
359
- @agent.apply_catalog(@catalog, {:report => report})
364
+ @agent.run(report: report)
365
+
366
+ expect(report.metrics['time']).to be
367
+ expect(report.metrics['time']['total']).to be_a_kind_of(Numeric)
368
+ end
369
+
370
+ it 'includes total time metrics in the report even if prerun fails' do
371
+ Puppet.settings[:prerun_command] = "/my/command"
372
+ Puppet::Util::Execution.expects(:execute).with(["/my/command"]).raises(Puppet::ExecutionFailure, "Failed")
373
+
374
+ report = Puppet::Transaction::Report.new
375
+ @agent.run(report: report)
376
+
377
+ expect(report.metrics['time']).to be
378
+ expect(report.metrics['time']['total']).to be_a_kind_of(Numeric)
379
+ end
380
+
381
+ it 'includes total time metrics in the report even if catalog retrieval fails' do
382
+ report = Puppet::Transaction::Report.new
383
+ @agent.stubs(:prepare_and_retrieve_catalog_from_cache).raises
384
+ @agent.run(:report => report)
385
+
386
+ expect(report.metrics['time']).to be
387
+ expect(report.metrics['time']['total']).to be_a_kind_of(Numeric)
360
388
  end
361
389
 
362
390
  it "should refetch the catalog if the server specifies a new environment in the catalog" do
@@ -13,11 +13,6 @@ describe Puppet::Face[:config, '0.0.1'] do
13
13
 
14
14
  FS = Puppet::FileSystem
15
15
 
16
- before :each do
17
- subject.stubs(:warn_default_section)
18
- subject.stubs(:report_section_and_environment)
19
- end
20
-
21
16
  it "prints a single setting without the name" do
22
17
  Puppet[:trace] = true
23
18
 
@@ -61,27 +56,44 @@ trace = true
61
56
  expect(render(:print, result)).to eq("file\n")
62
57
  end
63
58
 
64
- it "prints the section and environment, and not a warning, when a section is given" do
59
+ it "prints the section and environment, and not a warning, when a section is given and verbose is set" do
65
60
  Puppet.settings.parse_config(<<-CONF)
66
61
  [user]
67
62
  syslogfacility = file
68
63
  CONF
69
64
 
70
- subject.expects(:warn_default_section).never
71
- subject.expects(:report_section_and_environment).once
65
+ #This has to be after the settings above, which resets the value
66
+ Puppet[:log_level] = 'info'
72
67
 
73
- result = subject.print("syslogfacility", :section => "user")
74
- expect(render(:print, result)).to eq("file\n")
68
+ Puppet.expects(:warning).never
69
+ expect {
70
+ result = subject.print("syslogfacility", :section => "user")
71
+ expect(render(:print, result)).to eq("file\n")
72
+ }.to output("\e[1;33mResolving settings from section 'user' in environment 'production'\e[0m\n").to_stderr
75
73
  end
76
74
 
77
- it "prints a warning and the section and environment when no section is given" do
75
+ it "prints a warning and the section and environment when no section is given and verbose is set" do
76
+ Puppet[:log_level] = 'info'
78
77
  Puppet[:trace] = true
79
78
 
80
- subject.expects(:warn_default_section).once
81
- subject.expects(:report_section_and_environment).once
79
+ Puppet.expects(:warning).with("No section specified; defaulting to 'main'.\nSet the config section " +
80
+ "by using the `--section` flag.\nFor example, `puppet config --section user print foo`.\nFor more " +
81
+ "information, see https://puppet.com/docs/puppet/latest/configuration.html")
82
+ expect {
83
+ result = subject.print("trace")
84
+ expect(render(:print, result)).to eq("true\n")
85
+ }.to output("\e[1;33mResolving settings from section 'main' in environment 'production'\e[0m\n").to_stderr
86
+ end
82
87
 
83
- result = subject.print("trace")
84
- expect(render(:print, result)).to eq("true\n")
88
+ it "does not print a warning or the section and environment when no section is given and verbose is not set" do
89
+ Puppet[:log_level] = 'notice'
90
+ Puppet[:trace] = true
91
+
92
+ Puppet.expects(:warning).never
93
+ expect {
94
+ result = subject.print("trace")
95
+ expect(render(:print, result)).to eq("true\n")
96
+ }.to_not output.to_stderr
85
97
  end
86
98
 
87
99
  it "defaults to all when no arguments are given" do
@@ -124,16 +136,20 @@ trace = true
124
136
  Puppet::FileSystem.stubs(:touch)
125
137
  end
126
138
 
127
- it "prints the section and environment when no section is given" do
139
+ it "prints the section and environment when no section is given and verbose is set" do
140
+ Puppet[:log_level] = 'info'
128
141
  Puppet::FileSystem.stubs(:open).with(path, anything, anything).yields(StringIO.new)
129
- subject.expects(:report_section_and_environment).once
130
- subject.set('foo', 'bar')
142
+ expect {
143
+ subject.set('foo', 'bar')
144
+ }.to output("\e[1;33mResolving settings from section 'main' in environment 'production'\e[0m\n").to_stderr
131
145
  end
132
146
 
133
- it "prints the section and environment when a section is given" do
147
+ it "prints the section and environment when a section is given and verbose is set" do
148
+ Puppet[:log_level] = 'info'
134
149
  Puppet::FileSystem.stubs(:open).with(path, anything, anything).yields(StringIO.new)
135
- subject.expects(:report_section_and_environment).once
136
- subject.set('foo', 'bar', {:section => "baz"})
150
+ expect {
151
+ subject.set('foo', 'bar', {:section => "baz"})
152
+ }.to output("\e[1;33mResolving settings from section 'baz' in environment 'production'\e[0m\n").to_stderr
137
153
  end
138
154
 
139
155
  it "writes to the correct puppet config file" do
@@ -67,11 +67,11 @@ describe 'the empty function' do
67
67
  end
68
68
 
69
69
  context 'for undef it' do
70
- it 'returns true and issues deprecation warning' do
70
+ it 'returns true without deprecation warning' do
71
71
  Puppet::Util::Log.with_destination(Puppet::Test::LogCollector.new(logs)) do
72
72
  expect(compile_to_catalog("notify { String(empty(undef)): }")).to have_resource('Notify[true]')
73
73
  end
74
- expect(warnings).to include(/Calling function empty\(\) with Undef value is deprecated/)
74
+ expect(warnings).to_not include(/Calling function empty\(\) with Undef value is deprecated/)
75
75
  end
76
76
  end
77
77
  end
@@ -117,6 +117,9 @@ describe "the epp function" do
117
117
  end
118
118
  end
119
119
 
120
+ it "preserves CRLF when reading the template" do
121
+ expect(eval_template("some text that\r\nis static with CRLF")).to eq("some text that\r\nis static with CRLF")
122
+ end
120
123
 
121
124
  # although never a problem with epp
122
125
  it "is not interfered with by having a variable named 'string' (#14093)" do
@@ -148,7 +151,7 @@ describe "the epp function" do
148
151
  def eval_template_with_args(content, args_hash)
149
152
  file_path = tmpdir('epp_spec_content')
150
153
  filename = File.join(file_path, "template.epp")
151
- File.open(filename, "w+") { |f| f.write(content) }
154
+ File.open(filename, "wb+") { |f| f.write(content) }
152
155
 
153
156
  Puppet::Parser::Files.stubs(:find_template).returns(filename)
154
157
  epp_function.call(scope, 'template', args_hash)
@@ -157,7 +160,7 @@ describe "the epp function" do
157
160
  def eval_template(content)
158
161
  file_path = tmpdir('epp_spec_content')
159
162
  filename = File.join(file_path, "template.epp")
160
- File.open(filename, "w+") { |f| f.write(content) }
163
+ File.open(filename, "wb+") { |f| f.write(content) }
161
164
 
162
165
  Puppet::Parser::Files.stubs(:find_template).returns(filename)
163
166
  epp_function.call(scope, 'template')
@@ -723,6 +723,49 @@ describe Puppet::Indirector::REST do
723
723
  end
724
724
  end
725
725
 
726
+ describe '#handle_response' do
727
+ # There are multiple request types to choose from, this may not be the one I want for this situation
728
+ let(:response) { mock_response(200, 'body') }
729
+ let(:connection) { stub('mock http connection', :put => response, :verify_callback= => nil) }
730
+ let(:instance) { model.new('the thing', 'some contents') }
731
+ let(:request) { save_request(instance.name, instance) }
732
+
733
+ before :each do
734
+ terminus.stubs(:network).returns(connection)
735
+ end
736
+
737
+ it 'adds server_agent_version to the context if not already set' do
738
+ Puppet.expects(:push_context).with(:server_agent_version => Puppet.version)
739
+ terminus.handle_response(request, response)
740
+ end
741
+
742
+ it 'does not add server_agent_version to the context if it is already set' do
743
+ Puppet.override(:server_agent_version => "5.3.4") do
744
+ Puppet.expects(:push_context).never
745
+ terminus.handle_response(request, response)
746
+ end
747
+ end
748
+
749
+ it 'downgrades to pson and emits a warning' do
750
+ response.stubs(:[]).with(Puppet::Network::HTTP::HEADER_PUPPET_VERSION).returns('4.2.8')
751
+ Puppet[:preferred_serialization_format] = 'other'
752
+
753
+ Puppet.expects(:warning).with('Downgrading to PSON for future requests')
754
+
755
+ terminus.handle_response(request, response)
756
+
757
+ expect(Puppet[:preferred_serialization_format]).to eq('pson')
758
+ end
759
+
760
+ it 'preserves the set serialization format' do
761
+ Puppet[:preferred_serialization_format] = 'other'
762
+
763
+ expect(Puppet[:preferred_serialization_format]).to eq('other')
764
+
765
+ terminus.handle_response(request, response)
766
+ end
767
+ end
768
+
726
769
  context 'dealing with SRV settings' do
727
770
  [
728
771
  :destroy,