puppet 6.19.1-x64-mingw32 → 6.20.0-x64-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.

Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/CODEOWNERS +2 -16
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +30 -25
  5. data/lib/puppet/application.rb +10 -6
  6. data/lib/puppet/application/agent.rb +1 -0
  7. data/lib/puppet/application/apply.rb +3 -2
  8. data/lib/puppet/application/device.rb +1 -0
  9. data/lib/puppet/application/filebucket.rb +2 -2
  10. data/lib/puppet/application/script.rb +1 -0
  11. data/lib/puppet/application_support.rb +7 -0
  12. data/lib/puppet/configurer.rb +28 -18
  13. data/lib/puppet/defaults.rb +24 -18
  14. data/lib/puppet/environments.rb +38 -54
  15. data/lib/puppet/face/config.rb +10 -0
  16. data/lib/puppet/face/epp.rb +12 -2
  17. data/lib/puppet/face/facts.rb +60 -0
  18. data/lib/puppet/ffi/posix.rb +10 -0
  19. data/lib/puppet/ffi/posix/constants.rb +14 -0
  20. data/lib/puppet/ffi/posix/functions.rb +24 -0
  21. data/lib/puppet/functions/epp.rb +1 -0
  22. data/lib/puppet/functions/inline_epp.rb +1 -0
  23. data/lib/puppet/indirector/fact_search.rb +60 -0
  24. data/lib/puppet/indirector/facts/json.rb +27 -0
  25. data/lib/puppet/indirector/facts/yaml.rb +3 -58
  26. data/lib/puppet/indirector/json.rb +5 -1
  27. data/lib/puppet/indirector/node/json.rb +8 -0
  28. data/lib/puppet/indirector/report/json.rb +34 -0
  29. data/lib/puppet/module_tool/applications/installer.rb +48 -2
  30. data/lib/puppet/module_tool/errors/shared.rb +17 -2
  31. data/lib/puppet/network/formats.rb +2 -1
  32. data/lib/puppet/pal/pal_impl.rb +70 -17
  33. data/lib/puppet/parser/ast/leaf.rb +3 -2
  34. data/lib/puppet/parser/templatewrapper.rb +1 -1
  35. data/lib/puppet/pops/evaluator/deferred_resolver.rb +5 -3
  36. data/lib/puppet/pops/evaluator/evaluator_impl.rb +22 -3
  37. data/lib/puppet/pops/model/ast_transformer.rb +1 -1
  38. data/lib/puppet/provider/package/apt.rb +4 -0
  39. data/lib/puppet/provider/user/aix.rb +2 -2
  40. data/lib/puppet/reference/configuration.rb +6 -5
  41. data/lib/puppet/settings.rb +33 -28
  42. data/lib/puppet/settings/alias_setting.rb +37 -0
  43. data/lib/puppet/settings/base_setting.rb +26 -2
  44. data/lib/puppet/util/autoload.rb +1 -8
  45. data/lib/puppet/util/fact_dif.rb +62 -0
  46. data/lib/puppet/util/posix.rb +54 -5
  47. data/lib/puppet/util/rubygems.rb +5 -1
  48. data/lib/puppet/version.rb +1 -1
  49. data/locales/puppet.pot +188 -164
  50. data/man/man5/puppet.conf.5 +6 -6
  51. data/man/man8/puppet-agent.8 +2 -2
  52. data/man/man8/puppet-apply.8 +2 -2
  53. data/man/man8/puppet-catalog.8 +1 -1
  54. data/man/man8/puppet-config.8 +1 -1
  55. data/man/man8/puppet-describe.8 +1 -1
  56. data/man/man8/puppet-device.8 +2 -2
  57. data/man/man8/puppet-doc.8 +1 -1
  58. data/man/man8/puppet-epp.8 +1 -1
  59. data/man/man8/puppet-facts.8 +32 -1
  60. data/man/man8/puppet-filebucket.8 +3 -3
  61. data/man/man8/puppet-generate.8 +1 -1
  62. data/man/man8/puppet-help.8 +1 -1
  63. data/man/man8/puppet-key.8 +1 -1
  64. data/man/man8/puppet-lookup.8 +1 -1
  65. data/man/man8/puppet-man.8 +1 -1
  66. data/man/man8/puppet-module.8 +1 -1
  67. data/man/man8/puppet-node.8 +4 -1
  68. data/man/man8/puppet-parser.8 +1 -1
  69. data/man/man8/puppet-plugin.8 +1 -1
  70. data/man/man8/puppet-report.8 +4 -1
  71. data/man/man8/puppet-resource.8 +1 -1
  72. data/man/man8/puppet-script.8 +2 -2
  73. data/man/man8/puppet-ssl.8 +1 -1
  74. data/man/man8/puppet-status.8 +1 -1
  75. data/man/man8/puppet.8 +2 -2
  76. data/spec/fixtures/integration/application/agent/cached_deferred_catalog.json +91 -0
  77. data/spec/fixtures/unit/provider/user/aix/aix_passwd_file.out +4 -0
  78. data/spec/integration/application/agent_spec.rb +127 -3
  79. data/spec/integration/application/apply_spec.rb +19 -0
  80. data/spec/integration/defaults_spec.rb +0 -7
  81. data/spec/integration/environments/setting_hooks_spec.rb +1 -1
  82. data/spec/integration/resource/type_collection_spec.rb +2 -6
  83. data/spec/integration/transaction_spec.rb +4 -9
  84. data/spec/integration/util/windows/adsi_spec.rb +3 -1
  85. data/spec/integration/util/windows/registry_spec.rb +0 -10
  86. data/spec/lib/puppet_spec/settings.rb +6 -1
  87. data/spec/spec_helper.rb +1 -4
  88. data/spec/unit/agent_spec.rb +8 -6
  89. data/spec/unit/application/agent_spec.rb +0 -1
  90. data/spec/unit/application/config_spec.rb +224 -4
  91. data/spec/unit/application/filebucket_spec.rb +0 -2
  92. data/spec/unit/application_spec.rb +51 -9
  93. data/spec/unit/confine/feature_spec.rb +1 -1
  94. data/spec/unit/confine_spec.rb +8 -2
  95. data/spec/unit/defaults_spec.rb +20 -1
  96. data/spec/unit/environments_spec.rb +96 -19
  97. data/spec/unit/face/config_spec.rb +27 -32
  98. data/spec/unit/face/node_spec.rb +0 -11
  99. data/spec/unit/file_serving/configuration/parser_spec.rb +0 -1
  100. data/spec/unit/file_serving/metadata_spec.rb +3 -3
  101. data/spec/unit/file_serving/terminus_helper_spec.rb +11 -4
  102. data/spec/unit/forge/module_release_spec.rb +2 -7
  103. data/spec/unit/functions/inline_epp_spec.rb +26 -1
  104. data/spec/unit/http/service/compiler_spec.rb +49 -0
  105. data/spec/unit/http/service_spec.rb +1 -1
  106. data/spec/unit/indirector/face_spec.rb +0 -1
  107. data/spec/unit/indirector/facts/facter_spec.rb +0 -1
  108. data/spec/unit/indirector/facts/json_spec.rb +255 -0
  109. data/spec/unit/indirector/file_bucket_file/selector_spec.rb +26 -8
  110. data/spec/unit/indirector/indirection_spec.rb +8 -12
  111. data/spec/unit/indirector/key/file_spec.rb +0 -1
  112. data/spec/unit/indirector/node/json_spec.rb +33 -0
  113. data/spec/{integration/indirector/report/yaml.rb → unit/indirector/report/json_spec.rb} +13 -24
  114. data/spec/unit/indirector/report/yaml_spec.rb +72 -8
  115. data/spec/unit/indirector_spec.rb +2 -2
  116. data/spec/unit/module_tool/applications/installer_spec.rb +66 -0
  117. data/spec/unit/network/authconfig_spec.rb +0 -3
  118. data/spec/unit/network/http/api/indirected_routes_spec.rb +0 -9
  119. data/spec/unit/network/http/handler_spec.rb +0 -5
  120. data/spec/unit/parser/compiler_spec.rb +3 -19
  121. data/spec/unit/parser/resource_spec.rb +14 -8
  122. data/spec/unit/parser/templatewrapper_spec.rb +4 -3
  123. data/spec/unit/pops/evaluator/deferred_resolver_spec.rb +20 -0
  124. data/spec/unit/property_spec.rb +1 -0
  125. data/spec/unit/provider/nameservice_spec.rb +66 -65
  126. data/spec/unit/provider/package/apt_spec.rb +4 -8
  127. data/spec/unit/provider/package/base_spec.rb +6 -5
  128. data/spec/unit/provider/package/pacman_spec.rb +18 -12
  129. data/spec/unit/provider/package/pip_spec.rb +6 -11
  130. data/spec/unit/provider/package/pkgdmg_spec.rb +0 -4
  131. data/spec/unit/provider/user/aix_spec.rb +5 -0
  132. data/spec/unit/provider/user/hpux_spec.rb +1 -1
  133. data/spec/unit/provider/user/pw_spec.rb +2 -0
  134. data/spec/unit/provider/user/useradd_spec.rb +1 -0
  135. data/spec/unit/provider_spec.rb +8 -10
  136. data/spec/unit/puppet_pal_catalog_spec.rb +45 -0
  137. data/spec/unit/resource/capability_finder_spec.rb +6 -1
  138. data/spec/unit/resource/type_spec.rb +1 -1
  139. data/spec/unit/resource_spec.rb +11 -10
  140. data/spec/unit/settings_spec.rb +419 -242
  141. data/spec/unit/ssl/base_spec.rb +0 -1
  142. data/spec/unit/ssl/host_spec.rb +0 -5
  143. data/spec/unit/ssl/ssl_provider_spec.rb +14 -8
  144. data/spec/unit/transaction/additional_resource_generator_spec.rb +3 -7
  145. data/spec/unit/transaction/event_manager_spec.rb +14 -11
  146. data/spec/unit/transaction_spec.rb +13 -4
  147. data/spec/unit/type/file/content_spec.rb +0 -1
  148. data/spec/unit/type/file/selinux_spec.rb +0 -2
  149. data/spec/unit/type/file_spec.rb +0 -6
  150. data/spec/unit/type/group_spec.rb +13 -6
  151. data/spec/unit/type/resources_spec.rb +7 -7
  152. data/spec/unit/type/service_spec.rb +1 -1
  153. data/spec/unit/type/tidy_spec.rb +0 -1
  154. data/spec/unit/type_spec.rb +2 -2
  155. data/spec/unit/util/at_fork_spec.rb +2 -2
  156. data/spec/unit/util/autoload_spec.rb +5 -1
  157. data/spec/unit/util/backups_spec.rb +1 -2
  158. data/spec/unit/util/execution_spec.rb +15 -11
  159. data/spec/unit/util/inifile_spec.rb +6 -14
  160. data/spec/unit/util/log_spec.rb +8 -7
  161. data/spec/unit/util/logging_spec.rb +3 -3
  162. data/spec/unit/util/posix_spec.rb +363 -15
  163. data/spec/unit/util/rubygems_spec.rb +2 -2
  164. data/spec/unit/util/selinux_spec.rb +76 -52
  165. data/spec/unit/util/storage_spec.rb +3 -1
  166. data/spec/unit/util/suidmanager_spec.rb +44 -41
  167. data/spec/unit/util_spec.rb +13 -6
  168. metadata +21 -10
  169. data/spec/integration/application/config_spec.rb +0 -74
  170. data/spec/unit/face/catalog_spec.rb +0 -6
  171. data/spec/unit/face/module_spec.rb +0 -3
@@ -42,7 +42,6 @@ describe Puppet::Application::Filebucket do
42
42
  describe "during setup" do
43
43
  before :each do
44
44
  allow(Puppet::Log).to receive(:newdestination)
45
- allow(Puppet).to receive(:settraps)
46
45
  allow(Puppet::FileBucket::Dipper).to receive(:new)
47
46
  allow(@filebucket.options).to receive(:[])
48
47
  end
@@ -157,7 +156,6 @@ describe Puppet::Application::Filebucket do
157
156
  describe "when running" do
158
157
  before :each do
159
158
  allow(Puppet::Log).to receive(:newdestination)
160
- allow(Puppet).to receive(:settraps)
161
159
  allow(Puppet::FileBucket::Dipper).to receive(:new)
162
160
  allow(@filebucket.options).to receive(:[])
163
161
 
@@ -7,8 +7,10 @@ require 'timeout'
7
7
 
8
8
  describe Puppet::Application do
9
9
  before(:each) do
10
- @app = Class.new(Puppet::Application).new
11
- @appclass = @app.class
10
+ @appclass = Class.new(Puppet::Application) do
11
+ def handle_unknown(opt, arg); end
12
+ end
13
+ @app = @appclass.new
12
14
 
13
15
  allow(@app).to receive(:name).and_return("test_app")
14
16
  end
@@ -511,6 +513,40 @@ describe Puppet::Application do
511
513
 
512
514
  expect { @app.configure_indirector_routes }.to raise_error(Puppet::Error, /mapping values are not allowed/)
513
515
  end
516
+
517
+ it "should treat master routes on server application" do
518
+ allow(@app).to receive(:name).and_return("server")
519
+
520
+ Puppet[:route_file] = tmpfile('routes')
521
+ File.open(Puppet[:route_file], 'w') do |f|
522
+ f.print <<-ROUTES
523
+ master:
524
+ node:
525
+ terminus: exec
526
+ ROUTES
527
+ end
528
+
529
+ @app.configure_indirector_routes
530
+
531
+ expect(Puppet::Node.indirection.terminus_class).to eq('exec')
532
+ end
533
+
534
+ it "should treat server routes on master application" do
535
+ allow(@app).to receive(:name).and_return("master")
536
+
537
+ Puppet[:route_file] = tmpfile('routes')
538
+ File.open(Puppet[:route_file], 'w') do |f|
539
+ f.print <<-ROUTES
540
+ server:
541
+ node:
542
+ terminus: exec
543
+ ROUTES
544
+ end
545
+
546
+ @app.configure_indirector_routes
547
+
548
+ expect(Puppet::Node.indirection.terminus_class).to eq('exec')
549
+ end
514
550
  end
515
551
 
516
552
  describe "when running" do
@@ -560,13 +596,6 @@ describe Puppet::Application do
560
596
  end
561
597
 
562
598
  it "should raise an error if dispatch returns no command" do
563
- allow(@app).to receive(:get_command).and_return(nil)
564
- expect(Puppet).to receive(:send_log).with(:err, "Could not run: No valid command or main")
565
- expect { @app.run }.to exit_with 1
566
- end
567
-
568
- it "should raise an error if dispatch returns an invalid command" do
569
- allow(@app).to receive(:get_command).and_return(:this_function_doesnt_exist)
570
599
  expect(Puppet).to receive(:send_log).with(:err, "Could not run: No valid command or main")
571
600
  expect { @app.run }.to exit_with 1
572
601
  end
@@ -684,5 +713,18 @@ describe Puppet::Application do
684
713
 
685
714
  @app.handle_logdest_arg(nil)
686
715
  end
716
+
717
+ it "accepts multiple destinations as a comma sepparated list" do
718
+ dest1 = '/tmp/path1'
719
+ dest2 = 'console'
720
+ dest3 = '/tmp/path2'
721
+ dest_args = [dest1, dest2, dest3].join(' , ')
722
+
723
+ [dest1, dest2, dest3].each do |dest|
724
+ expect(Puppet::Util::Log).to receive(:newdestination).with(dest)
725
+ end
726
+
727
+ @app.handle_logdest_arg(dest_args)
728
+ end
687
729
  end
688
730
  end
@@ -22,7 +22,7 @@ describe Puppet::Confine::Feature do
22
22
  end
23
23
 
24
24
  it "should use the Puppet features instance to test validity" do
25
- expect(Puppet.features).to receive(:myfeature?)
25
+ Puppet.features.add(:myfeature) do true end
26
26
  @confine.valid?
27
27
  end
28
28
 
@@ -2,6 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  require 'puppet/confine'
4
4
 
5
+ class Puppet::TestConfine < Puppet::Confine
6
+ def pass?(value)
7
+ false
8
+ end
9
+ end
10
+
5
11
  describe Puppet::Confine do
6
12
  it "should require a value" do
7
13
  expect { Puppet::Confine.new }.to raise_error(ArgumentError)
@@ -33,7 +39,7 @@ describe Puppet::Confine do
33
39
 
34
40
  describe "when testing all values" do
35
41
  before do
36
- @confine = Puppet::Confine.new(%w{a b c})
42
+ @confine = Puppet::TestConfine.new(%w{a b c})
37
43
  @confine.label = "foo"
38
44
  end
39
45
 
@@ -64,7 +70,7 @@ describe Puppet::Confine do
64
70
  end
65
71
 
66
72
  describe "when testing the result of the values" do
67
- before { @confine = Puppet::Confine.new(%w{a b c d}) }
73
+ before { @confine = Puppet::TestConfine.new(%w{a b c d}) }
68
74
 
69
75
  it "should return an array with the result of the test for each value" do
70
76
  allow(@confine).to receive(:pass?).and_return(true)
@@ -189,6 +189,7 @@ describe "Defaults" do
189
189
 
190
190
  it "raises an exception if facter-ng could not be loaded" do
191
191
  allow_any_instance_of(Puppet::Settings::BooleanSetting).to receive(:require).with('facter-ng').and_raise(LoadError)
192
+ allow(Facter).to receive(:value).with('facterversion').and_return('3.11.4')
192
193
 
193
194
  expect{ Puppet.settings[:facterng] = true }.to raise_exception ArgumentError, 'facter-ng could not be loaded'
194
195
  end
@@ -198,7 +199,9 @@ describe "Defaults" do
198
199
  @original_facter = Object.const_get(:Facter)
199
200
 
200
201
  Object.send(:remove_const, :Facter)
201
- Object.const_set(:Facter, Module.new)
202
+ facter = double('facter')
203
+ allow(facter).to receive(:value).with('facterversion').and_return('3.11.4')
204
+ Object.const_set(:Facter, facter)
202
205
 
203
206
  allow_any_instance_of(Puppet::Settings::BooleanSetting).to receive(:require).with('facter-ng').and_return(true)
204
207
  allow(Facter).to receive(:respond_to?).and_return(false)
@@ -215,4 +218,20 @@ describe "Defaults" do
215
218
  end
216
219
  end
217
220
  end
221
+
222
+ describe "deprecated settings" do
223
+ it 'does not issue a deprecation warning by default' do
224
+ expect(Puppet).to receive(:deprecation_warning).never
225
+
226
+ Puppet.initialize_settings
227
+ end
228
+
229
+ it 'issues a deprecation warning when func3x_check is disabled' do
230
+ Puppet[:func3x_check] = false
231
+
232
+ expect(Puppet).to receive(:deprecation_warning).with("The 'func3x_check' setting is deprecated and will be removed in a future release.")
233
+
234
+ Puppet.initialize_settings
235
+ end
236
+ end
218
237
  end
@@ -629,19 +629,6 @@ config_version=$vardir/random/scripts
629
629
  context "expiration policies" do
630
630
  let(:service) { ReplayExpirationService.new }
631
631
 
632
- # The environment named `:an_environment` will already be loaded when the
633
- # block is yielded to
634
- def with_environment_loaded(service, &block)
635
- loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
636
- using_expiration_service(service) do
637
- cached = Puppet::Environments::Cached.new(loader)
638
- cached.get!(:an_environment)
639
-
640
- yield cached if block_given?
641
- end
642
- end
643
- end
644
-
645
632
  it "notifies when the environment is first created" do
646
633
  with_environment_loaded(service)
647
634
 
@@ -662,10 +649,7 @@ config_version=$vardir/random/scripts
662
649
  it "evicts an expired environment" do
663
650
  service = ReplayExpirationService.new
664
651
 
665
- # The `Cached#clear_all_expired` method tries to optimize the case where
666
- # no entries are expired. But if `Time.now < @next_expiration` and there is
667
- # an expired entry, then the `service#expired?` method is called twice.
668
- expect(service).to receive(:expired?).twice.and_return(true)
652
+ expect(service).to receive(:expired?).and_return(true)
669
653
 
670
654
  with_environment_loaded(service) do |cached|
671
655
  cached.get!(:an_environment)
@@ -709,8 +693,7 @@ config_version=$vardir/random/scripts
709
693
  Puppet[:environment_timeout] = 60
710
694
  Puppet[:environment_timeout_mode] = :from_last_used
711
695
 
712
- # see note above about "twice"
713
- expect(service).to receive(:expired?).twice.and_return(true)
696
+ expect(service).to receive(:expired?).and_return(true)
714
697
 
715
698
  with_environment_loaded(service) do |cached|
716
699
  # even though the environment was recently touched, it's been expired
@@ -729,6 +712,87 @@ config_version=$vardir/random/scripts
729
712
  with_global_module_path([])
730
713
  end
731
714
  end
715
+
716
+ context '#clear' do
717
+ let(:service) { ReplayExpirationService.new }
718
+
719
+ it "evicts an environment" do
720
+ with_environment_loaded(service) do |cached|
721
+ cached.clear(:an_environment)
722
+ end
723
+
724
+ expect(service.evicted_envs).to eq([:an_environment])
725
+ end
726
+ end
727
+
728
+ context '#clear_all' do
729
+ let(:service) { ReplayExpirationService.new }
730
+
731
+ it 'evicts all environments' do
732
+ with_environment_loaded(service) do |cached|
733
+ cached.get(:an_environment)
734
+ cached.get(:another_environment)
735
+ cached.clear_all
736
+
737
+ expect(service.evicted_envs).to match([:an_environment, :another_environment])
738
+ end
739
+ end
740
+
741
+ it 'clears cached environment settings' do
742
+ base_dir = File.expand_path("envdir")
743
+ original_envdir = FS::MemoryFile.a_directory(base_dir, [
744
+ FS::MemoryFile.a_directory("env3", [
745
+ FS::MemoryFile.a_regular_file_containing("environment.conf", <<-EOF)
746
+ manifest=/manifest_orig
747
+ modulepath=/modules_orig
748
+ environment_timeout=60
749
+ EOF
750
+ ]),
751
+ ])
752
+
753
+ FS.overlay(original_envdir) do
754
+ dir_loader = Puppet::Environments::Directories.new(original_envdir, [])
755
+ loader = Puppet::Environments::Cached.new(dir_loader)
756
+ Puppet.override(:environments => loader) do
757
+ original_env = loader.get("env3") # force the environment.conf to be read
758
+
759
+ changed_envdir = FS::MemoryFile.a_directory(base_dir, [
760
+ FS::MemoryFile.a_directory("env3", [
761
+ FS::MemoryFile.a_regular_file_containing("environment.conf", <<-EOF)
762
+ manifest=/manifest_changed
763
+ modulepath=/modules_changed
764
+ environment_timeout=60
765
+ EOF
766
+ ]),
767
+ ])
768
+
769
+ #Clear all cached environments
770
+ loader.clear_all
771
+
772
+ FS.overlay(changed_envdir) do
773
+ changed_env = loader.get("env3")
774
+
775
+ expect(original_env).to environment(:env3).
776
+ with_manifest(File.expand_path("/manifest_orig")).
777
+ with_full_modulepath([File.expand_path("/modules_orig")])
778
+
779
+ expect(changed_env).to environment(:env3).
780
+ with_manifest(File.expand_path("/manifest_changed")).
781
+ with_full_modulepath([File.expand_path("/modules_changed")])
782
+ end
783
+ end
784
+ end
785
+ end
786
+
787
+ it 'deletes environment text domains' do
788
+ with_environment_loaded(service) do |cached|
789
+ cached.get(:an_environment)
790
+ cached.clear_all
791
+
792
+ expect(FastGettext.text_domain).to eq(Puppet::GettextConfig::DEFAULT_TEXT_DOMAIN)
793
+ end
794
+ end
795
+ end
732
796
  end
733
797
 
734
798
  RSpec::Matchers.define :environment do |name|
@@ -823,6 +887,19 @@ config_version=$vardir/random/scripts
823
887
  end
824
888
  end
825
889
 
890
+ # The environment named `:an_environment` will already be loaded when the
891
+ # block is yielded to
892
+ def with_environment_loaded(service, &block)
893
+ loader_from(:filesystem => [directory_tree], :directory => directory_tree.children.first) do |loader|
894
+ using_expiration_service(service) do
895
+ cached = Puppet::Environments::Cached.new(loader)
896
+ cached.get!(:an_environment)
897
+
898
+ yield cached if block_given?
899
+ end
900
+ end
901
+ end
902
+
826
903
  class ReplayExpirationService < Puppet::Environments::Cached::DefaultCacheExpirationService
827
904
  attr_reader :created_envs, :evicted_envs
828
905
 
@@ -138,7 +138,7 @@ trace = true
138
138
  Puppet[:log_level] = 'info'
139
139
  allow(Puppet::FileSystem).to receive(:open).with(path, anything, anything).and_yield(StringIO.new)
140
140
  expect {
141
- subject.set('foo', 'bar')
141
+ subject.set('certname', 'bar')
142
142
  }.to output("\e[1;33mResolving settings from section 'main' in environment 'production'\e[0m\n").to_stderr
143
143
  end
144
144
 
@@ -146,19 +146,19 @@ trace = true
146
146
  Puppet[:log_level] = 'info'
147
147
  allow(Puppet::FileSystem).to receive(:open).with(path, anything, anything).and_yield(StringIO.new)
148
148
  expect {
149
- subject.set('foo', 'bar', {:section => "baz"})
149
+ subject.set('certname', 'bar', {:section => "baz"})
150
150
  }.to output("\e[1;33mResolving settings from section 'baz' in environment 'production'\e[0m\n").to_stderr
151
151
  end
152
152
 
153
153
  it "writes to the correct puppet config file" do
154
154
  expect(Puppet::FileSystem).to receive(:open).with(path, anything, anything)
155
- subject.set('foo', 'bar')
155
+ subject.set('certname', 'bar')
156
156
  end
157
157
 
158
158
  it "creates a config file if one does not exist" do
159
159
  allow(Puppet::FileSystem).to receive(:open).with(path, anything, anything).and_yield(StringIO.new)
160
160
  expect(Puppet::FileSystem).to receive(:touch).with(path)
161
- subject.set('foo', 'bar')
161
+ subject.set('certname', 'bar')
162
162
  end
163
163
 
164
164
  it "sets the supplied config/value in the default section (main)" do
@@ -167,8 +167,8 @@ trace = true
167
167
  manipulator = Puppet::Settings::IniFile::Manipulator.new(config)
168
168
  allow(Puppet::Settings::IniFile::Manipulator).to receive(:new).and_return(manipulator)
169
169
 
170
- expect(manipulator).to receive(:set).with("main", "foo", "bar")
171
- subject.set('foo', 'bar')
170
+ expect(manipulator).to receive(:set).with("main", "certname", "bar")
171
+ subject.set('certname', 'bar')
172
172
  end
173
173
 
174
174
  it "sets the value in the supplied section" do
@@ -177,8 +177,8 @@ trace = true
177
177
  manipulator = Puppet::Settings::IniFile::Manipulator.new(config)
178
178
  allow(Puppet::Settings::IniFile::Manipulator).to receive(:new).and_return(manipulator)
179
179
 
180
- expect(manipulator).to receive(:set).with("baz", "foo", "bar")
181
- subject.set('foo', 'bar', {:section => "baz"})
180
+ expect(manipulator).to receive(:set).with("baz", "certname", "bar")
181
+ subject.set('certname', 'bar', {:section => "baz"})
182
182
  end
183
183
 
184
184
  it "does not duplicate an existing default section when a section is not specified" do
@@ -190,53 +190,48 @@ trace = true
190
190
  myfile = StringIO.new(contents)
191
191
  allow(Puppet::FileSystem).to receive(:open).with(path, anything, anything).and_yield(myfile)
192
192
 
193
- subject.set('foo', 'bar')
193
+ subject.set('certname', 'bar')
194
194
 
195
- expect(myfile.string).to match(/foo = bar/)
195
+ expect(myfile.string).to match(/certname = bar/)
196
196
  expect(myfile.string).not_to match(/main.*main/)
197
197
  end
198
198
 
199
199
  it "opens the file with UTF-8 encoding" do
200
200
  expect(Puppet::FileSystem).to receive(:open).with(path, nil, 'r+:UTF-8')
201
- subject.set('foo', 'bar')
201
+ subject.set('certname', 'bar')
202
202
  end
203
203
 
204
204
  it "sets settings into the [server] section when setting [master] section settings" do
205
- initial_contents = <<-CONFIG
206
- [master]
207
- setting = old_setting_value
208
- untouched_setting = value
205
+ initial_contents = <<~CONFIG
206
+ [master]
207
+ node_terminus = none
208
+ reports = log
209
209
  CONFIG
210
210
 
211
211
  myinitialfile = StringIO.new(initial_contents)
212
212
  allow(Puppet::FileSystem).to receive(:open).with(path, anything, anything).and_yield(myinitialfile)
213
213
 
214
214
  expect {
215
- subject.set('setting', 'new_setting_value', {:section => 'master'})
216
- }.to output("Deleted setting from 'master': 'setting = old_setting_value', and adding it to 'server' section\n").to_stdout
217
- modified_content = <<-CONFIG
218
- [master]
219
- untouched_setting = value
220
- [server]
221
- setting = new_setting_value
222
- CONFIG
215
+ subject.set('node_terminus', 'exec', {:section => 'master'})
216
+ }.to output("Deleted setting from 'master': 'node_terminus = none', and adding it to 'server' section\n").to_stdout
223
217
 
224
- mymodifiedfile = StringIO.new(modified_content)
225
- expect(myinitialfile.string).to match(mymodifiedfile.string)
218
+ expect(myinitialfile.string).to match(<<~CONFIG)
219
+ [master]
220
+ reports = log
221
+ [server]
222
+ node_terminus = exec
223
+ CONFIG
226
224
  end
227
225
 
228
226
  it "setting [master] section settings, sets settings into [server] section instead" do
229
227
  myinitialfile = StringIO.new("")
230
228
  allow(Puppet::FileSystem).to receive(:open).with(path, anything, anything).and_yield(myinitialfile)
231
- subject.set('setting_name', 'value', {:section => 'master'})
229
+ subject.set('node_terminus', 'exec', {:section => 'master'})
232
230
 
233
- expected_content = <<-CONFIG
234
- [server]
235
- setting_name = value
231
+ expect(myinitialfile.string).to match(<<~CONFIG)
232
+ [server]
233
+ node_terminus = exec
236
234
  CONFIG
237
-
238
- myexpectedfile = StringIO.new(expected_content)
239
- expect(myinitialfile.string).to match(myexpectedfile.string)
240
235
  end
241
236
  end
242
237