puppet 7.1.0 → 7.3.0

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 (118) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +15 -13
  3. data/lib/puppet/application.rb +10 -6
  4. data/lib/puppet/application/agent.rb +1 -0
  5. data/lib/puppet/application/apply.rb +3 -2
  6. data/lib/puppet/application/device.rb +1 -0
  7. data/lib/puppet/application/script.rb +1 -0
  8. data/lib/puppet/configurer.rb +16 -3
  9. data/lib/puppet/defaults.rb +5 -14
  10. data/lib/puppet/face/facts.rb +15 -1
  11. data/lib/puppet/file_serving/configuration/parser.rb +5 -2
  12. data/lib/puppet/module_tool/applications/installer.rb +48 -2
  13. data/lib/puppet/module_tool/errors/shared.rb +17 -2
  14. data/lib/puppet/network/formats.rb +67 -0
  15. data/lib/puppet/parser/ast/leaf.rb +3 -2
  16. data/lib/puppet/pops/evaluator/deferred_resolver.rb +5 -3
  17. data/lib/puppet/pops/model/ast_transformer.rb +1 -1
  18. data/lib/puppet/provider/package/apt.rb +4 -0
  19. data/lib/puppet/reference/configuration.rb +6 -5
  20. data/lib/puppet/settings.rb +33 -28
  21. data/lib/puppet/settings/alias_setting.rb +37 -0
  22. data/lib/puppet/util/autoload.rb +1 -8
  23. data/lib/puppet/util/posix.rb +1 -1
  24. data/lib/puppet/version.rb +1 -1
  25. data/locales/puppet.pot +157 -141
  26. data/man/man5/puppet.conf.5 +6 -6
  27. data/man/man8/puppet-agent.8 +2 -2
  28. data/man/man8/puppet-apply.8 +2 -2
  29. data/man/man8/puppet-catalog.8 +1 -1
  30. data/man/man8/puppet-config.8 +1 -1
  31. data/man/man8/puppet-describe.8 +1 -1
  32. data/man/man8/puppet-device.8 +2 -2
  33. data/man/man8/puppet-doc.8 +1 -1
  34. data/man/man8/puppet-epp.8 +1 -1
  35. data/man/man8/puppet-facts.8 +5 -2
  36. data/man/man8/puppet-filebucket.8 +1 -1
  37. data/man/man8/puppet-generate.8 +1 -1
  38. data/man/man8/puppet-help.8 +1 -1
  39. data/man/man8/puppet-lookup.8 +1 -1
  40. data/man/man8/puppet-module.8 +1 -1
  41. data/man/man8/puppet-node.8 +1 -1
  42. data/man/man8/puppet-parser.8 +1 -1
  43. data/man/man8/puppet-plugin.8 +1 -1
  44. data/man/man8/puppet-report.8 +1 -1
  45. data/man/man8/puppet-resource.8 +1 -1
  46. data/man/man8/puppet-script.8 +2 -2
  47. data/man/man8/puppet-ssl.8 +1 -1
  48. data/man/man8/puppet.8 +2 -2
  49. data/spec/fixtures/integration/application/agent/cached_deferred_catalog.json +91 -0
  50. data/spec/integration/application/agent_spec.rb +127 -3
  51. data/spec/integration/application/apply_spec.rb +19 -0
  52. data/spec/integration/defaults_spec.rb +0 -7
  53. data/spec/integration/indirector/file_content/file_server_spec.rb +0 -2
  54. data/spec/integration/indirector/file_metadata/file_server_spec.rb +0 -2
  55. data/spec/integration/resource/type_collection_spec.rb +2 -6
  56. data/spec/integration/transaction_spec.rb +4 -9
  57. data/spec/integration/util/windows/adsi_spec.rb +3 -1
  58. data/spec/integration/util/windows/registry_spec.rb +0 -10
  59. data/spec/spec_helper.rb +1 -4
  60. data/spec/unit/agent_spec.rb +8 -6
  61. data/spec/unit/application/agent_spec.rb +0 -1
  62. data/spec/unit/application/filebucket_spec.rb +0 -2
  63. data/spec/unit/application_spec.rb +17 -9
  64. data/spec/unit/confine/feature_spec.rb +1 -1
  65. data/spec/unit/confine_spec.rb +8 -2
  66. data/spec/unit/face/node_spec.rb +0 -11
  67. data/spec/unit/file_serving/configuration/parser_spec.rb +8 -1
  68. data/spec/unit/file_serving/metadata_spec.rb +3 -3
  69. data/spec/unit/file_serving/terminus_helper_spec.rb +11 -4
  70. data/spec/unit/forge/module_release_spec.rb +2 -7
  71. data/spec/unit/indirector/face_spec.rb +0 -1
  72. data/spec/unit/indirector/facts/facter_spec.rb +11 -5
  73. data/spec/unit/indirector/file_bucket_file/selector_spec.rb +26 -8
  74. data/spec/unit/indirector/indirection_spec.rb +8 -12
  75. data/spec/unit/indirector_spec.rb +2 -2
  76. data/spec/unit/module_tool/applications/installer_spec.rb +66 -0
  77. data/spec/unit/network/formats_spec.rb +41 -0
  78. data/spec/unit/network/http/api/indirected_routes_spec.rb +0 -4
  79. data/spec/unit/parser/compiler_spec.rb +3 -19
  80. data/spec/unit/parser/resource_spec.rb +14 -8
  81. data/spec/unit/pops/evaluator/deferred_resolver_spec.rb +20 -0
  82. data/spec/unit/property_spec.rb +1 -0
  83. data/spec/unit/provider/nameservice_spec.rb +66 -65
  84. data/spec/unit/provider/package/apt_spec.rb +4 -8
  85. data/spec/unit/provider/package/base_spec.rb +6 -5
  86. data/spec/unit/provider/package/pacman_spec.rb +18 -12
  87. data/spec/unit/provider/package/pip_spec.rb +6 -11
  88. data/spec/unit/provider/package/pkgdmg_spec.rb +0 -4
  89. data/spec/unit/provider/user/hpux_spec.rb +1 -1
  90. data/spec/unit/provider_spec.rb +6 -8
  91. data/spec/unit/resource/type_spec.rb +1 -1
  92. data/spec/unit/resource_spec.rb +11 -10
  93. data/spec/unit/settings_spec.rb +13 -6
  94. data/spec/unit/ssl/base_spec.rb +0 -1
  95. data/spec/unit/ssl/ssl_provider_spec.rb +5 -2
  96. data/spec/unit/transaction/additional_resource_generator_spec.rb +3 -7
  97. data/spec/unit/transaction/event_manager_spec.rb +14 -11
  98. data/spec/unit/transaction_spec.rb +13 -4
  99. data/spec/unit/type/file/content_spec.rb +0 -1
  100. data/spec/unit/type/file/selinux_spec.rb +0 -2
  101. data/spec/unit/type/file_spec.rb +0 -6
  102. data/spec/unit/type/group_spec.rb +13 -6
  103. data/spec/unit/type/resources_spec.rb +7 -7
  104. data/spec/unit/type/service_spec.rb +1 -1
  105. data/spec/unit/type/tidy_spec.rb +0 -1
  106. data/spec/unit/type_spec.rb +2 -2
  107. data/spec/unit/util/at_fork_spec.rb +2 -2
  108. data/spec/unit/util/autoload_spec.rb +5 -1
  109. data/spec/unit/util/backups_spec.rb +1 -2
  110. data/spec/unit/util/execution_spec.rb +15 -11
  111. data/spec/unit/util/inifile_spec.rb +6 -14
  112. data/spec/unit/util/log_spec.rb +8 -7
  113. data/spec/unit/util/logging_spec.rb +3 -3
  114. data/spec/unit/util/posix_spec.rb +16 -10
  115. data/spec/unit/util/selinux_spec.rb +76 -52
  116. data/spec/unit/util/suidmanager_spec.rb +44 -41
  117. data/spec/unit/util_spec.rb +13 -6
  118. metadata +7 -2
@@ -663,4 +663,23 @@ class amod::bad_type {
663
663
  end
664
664
  end
665
665
  end
666
+
667
+ context 'rich data' do
668
+ it "calls a deferred 4x function" do
669
+ apply.command_line.args = ['-e', 'notify { "deferred3x": message => Deferred("join", [[1,2,3], ":"]) }']
670
+
671
+ expect {
672
+ apply.run
673
+ }.to exit_with(0) # for some reason apply returns 0 instead of 2
674
+ .and output(%r{Notice: /Stage\[main\]/Main/Notify\[deferred3x\]/message: defined 'message' as '1:2:3'}).to_stdout
675
+ end
676
+
677
+ it "calls a deferred 3x function" do
678
+ apply.command_line.args = ['-e', 'notify { "deferred4x": message => Deferred("sprintf", ["%s", "I am deferred"]) }']
679
+ expect {
680
+ apply.run
681
+ }.to exit_with(0) # for some reason apply returns 0 instead of 2
682
+ .and output(%r{Notice: /Stage\[main\]/Main/Notify\[deferred4x\]/message: defined 'message' as 'I am deferred'}).to_stdout
683
+ end
684
+ end
666
685
  end
@@ -36,13 +36,6 @@ describe "Puppet defaults" do
36
36
  end
37
37
  end
38
38
 
39
- describe "when setting the :serverport" do
40
- it "should also set the :masterport to the same value" do
41
- Puppet.settings[:serverport] = 9000
42
- expect(Puppet.settings[:masterport]).to eq(9000)
43
- end
44
- end
45
-
46
39
  describe "when setting the :factpath" do
47
40
  it "should add the :factpath to Facter's search paths" do
48
41
  expect(Facter).to receive(:search).with("/my/fact/path")
@@ -86,8 +86,6 @@ describe Puppet::Indirector::FileContent::FileServer, " when finding files" do
86
86
 
87
87
  # Use a real mount, so the integration is a bit deeper.
88
88
  mount1 = Puppet::FileServing::Configuration::Mount::File.new("one")
89
- allow(mount1).to receive(:globalallow?).and_return(true)
90
- allow(mount1).to receive(:allowed?).and_return(true)
91
89
  mount1.path = File.join(path, "%h")
92
90
 
93
91
  parser = double('parser', :changed? => false)
@@ -59,8 +59,6 @@ describe Puppet::Indirector::FileMetadata::FileServer, " when finding files" do
59
59
 
60
60
  # Use a real mount, so the integration is a bit deeper.
61
61
  mount1 = Puppet::FileServing::Configuration::Mount::File.new("one")
62
- allow(mount1).to receive(:globalallow?).and_return(true)
63
- allow(mount1).to receive(:allowed?).and_return(true)
64
62
  mount1.path = File.join(env_path, "%h")
65
63
 
66
64
  parser = double('parser', :changed? => false)
@@ -11,12 +11,8 @@ describe Puppet::Resource::TypeCollection do
11
11
  @dir = tmpfile("autoload_testing")
12
12
  FileUtils.mkdir_p @dir
13
13
 
14
- loader = Object.new
15
- allow(loader).to receive(:load).and_return(nil)
16
- allow(loader).to receive(:set_entry)
17
-
18
- loaders = Object.new
19
- expect(loaders).to receive(:runtime3_type_loader).at_most(:once).and_return(loader)
14
+ loader = double('loader', load: nil, set_entry: nil)
15
+ loaders = double('loaders', runtime3_type_loader: loader)
20
16
  expect(Puppet::Pops::Loaders).to receive(:loaders).at_most(:once).and_return(loaders)
21
17
 
22
18
  environment = Puppet::Node::Environment.create(:env, [@dir])
@@ -61,7 +61,7 @@ describe Puppet::Transaction do
61
61
 
62
62
  transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::SequentialPrioritizer.new)
63
63
 
64
- expect(resource).not_to receive(:evaluate)
64
+ expect(resource).not_to receive(:retrieve)
65
65
 
66
66
  transaction.evaluate
67
67
  end
@@ -86,7 +86,7 @@ describe Puppet::Transaction do
86
86
 
87
87
  transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::SequentialPrioritizer.new)
88
88
 
89
- expect(resource).not_to receive(:evaluate)
89
+ expect(resource).not_to receive(:retrieve)
90
90
 
91
91
  transaction.evaluate
92
92
  end
@@ -315,16 +315,14 @@ describe Puppet::Transaction do
315
315
  file1 = tmpfile("file1")
316
316
  file2 = tmpfile("file2")
317
317
 
318
+ expect(Puppet::FileSystem).to_not be_exist(file2)
319
+
318
320
  exec1 = Puppet::Type.type(:exec).new(
319
321
  :name => "exec1",
320
322
  :path => ENV["PATH"],
321
323
  :command => touch(file1),
322
324
  )
323
325
 
324
- allow(exec1).to receive(:eval_generate).and_return(
325
- [ Puppet::Type.type(:notify).new(:name => "eval1_notify") ]
326
- )
327
-
328
326
  exec2 = Puppet::Type.type(:exec).new(
329
327
  :name => "exec2",
330
328
  :path => ENV["PATH"],
@@ -332,9 +330,6 @@ describe Puppet::Transaction do
332
330
  :refreshonly => true,
333
331
  :subscribe => exec1,
334
332
  )
335
- allow(exec2).to receive(:eval_generate).and_return(
336
- [ Puppet::Type.type(:notify).new(:name => "eval2_notify") ]
337
- )
338
333
 
339
334
  Puppet[:tags] = "exec"
340
335
  catalog = mk_catalog(exec1, exec2)
@@ -157,7 +157,9 @@ describe Puppet::Util::Windows::ADSI::Group,
157
157
 
158
158
  # touch the native_object member to have it lazily loaded, so COM objects can be stubbed
159
159
  admins.native_object
160
- allow(admins.native_object).to receive(:Members).and_return(members)
160
+ without_partial_double_verification do
161
+ allow(admins.native_object).to receive(:Members).and_return(members)
162
+ end
161
163
 
162
164
  # well-known NULL SID
163
165
  expect(admins.members[0].sid).to eq('S-1-0-0')
@@ -146,16 +146,6 @@ describe Puppet::Util::Windows::Registry do
146
146
  utf_8_bytes = ENDASH_UTF_8 + TM_UTF_8
147
147
  utf_8_str = utf_8_bytes.pack('c*').force_encoding(Encoding::UTF_8)
148
148
 
149
- # this problematic Ruby codepath triggers a conversion of UTF-16LE to
150
- # a local codepage which can totally break when that codepage has no
151
- # conversion from the given UTF-16LE characters to local codepage
152
- # a prime example is that IBM437 has no conversion from a Unicode en-dash
153
- expect(Win32::Registry).not_to receive(:export_string)
154
-
155
- # also, expect that we're using our variants of keys / values, not Rubys
156
- expect(Win32::Registry).not_to receive(:each_key)
157
- expect(Win32::Registry).not_to receive(:each_value)
158
-
159
149
  hklm.create("#{puppet_key}\\#{subkey_name}", Win32::Registry::KEY_ALL_ACCESS | regsam) do |reg|
160
150
  reg.write("#{guid}", Win32::Registry::REG_SZ, utf_16_str)
161
151
 
@@ -84,10 +84,7 @@ RSpec.configure do |config|
84
84
  config.filter_run_when_matching :focus
85
85
 
86
86
  config.mock_with :rspec do |mocks|
87
- # We really should have this on, but it breaks a _lot_ of tests. We'll
88
- # need to go through and fix those tests first before it can be enabled
89
- # for real.
90
- mocks.verify_partial_doubles = false
87
+ mocks.verify_partial_doubles = true
91
88
  end
92
89
 
93
90
  tmpdir = Puppet::FileSystem.expand_path(Dir.mktmpdir("rspecrun"))
@@ -3,9 +3,13 @@ require 'puppet/agent'
3
3
  require 'puppet/configurer'
4
4
 
5
5
  class AgentTestClient
6
- def run
6
+ def initialize(transaction_uuid = nil, job_id = nil)
7
+ end
8
+
9
+ def run(client_args)
7
10
  # no-op
8
11
  end
12
+
9
13
  def stop
10
14
  # no-op
11
15
  end
@@ -49,11 +53,10 @@ describe Puppet::Agent do
49
53
 
50
54
  it "should create an instance of its client class and run it when asked to run" do
51
55
  client = double('client')
52
- expect(AgentTestClient).to receive(:new).and_return(client)
53
-
54
- expect(client).to receive(:run)
56
+ allow(AgentTestClient).to receive(:new).with(nil, nil).and_return(client)
55
57
 
56
58
  allow(@agent).to receive(:disabled?).and_return(false)
59
+ expect(client).to receive(:run)
57
60
  @agent.run
58
61
  end
59
62
 
@@ -90,7 +93,6 @@ describe Puppet::Agent do
90
93
 
91
94
  describe "when being run" do
92
95
  before do
93
- allow(AgentTestClient).to receive(:lockfile_path).and_return("/my/lock")
94
96
  allow(@agent).to receive(:disabled?).and_return(false)
95
97
  end
96
98
 
@@ -186,7 +188,7 @@ describe Puppet::Agent do
186
188
  allow(lockfile).to receive(:lock).and_return(false)
187
189
  end
188
190
 
189
- it "should notify that a run is already in progres" do
191
+ it "should notify that a run is already in progress" do
190
192
  client = AgentTestClient.new
191
193
  expect(AgentTestClient).to receive(:new).and_return(client)
192
194
  expect(Puppet).to receive(:notice).with(/Run of .* already in progress; skipping .* exists/)
@@ -202,7 +202,6 @@ describe Puppet::Application::Agent do
202
202
  allow(Puppet::Resource::Catalog.indirection).to receive(:terminus_class=)
203
203
  allow(Puppet::Resource::Catalog.indirection).to receive(:cache_class=)
204
204
  allow(Puppet::Node::Facts.indirection).to receive(:terminus_class=)
205
- allow(Puppet).to receive(:settraps)
206
205
  end
207
206
 
208
207
  it "should not run with extra arguments" do
@@ -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
@@ -159,7 +158,6 @@ describe Puppet::Application::Filebucket do
159
158
  describe "when running" do
160
159
  before :each do
161
160
  allow(Puppet::Log).to receive(:newdestination)
162
- allow(Puppet).to receive(:settraps)
163
161
  allow(Puppet::FileBucket::Dipper).to receive(:new)
164
162
  allow(@filebucket.options).to receive(:[])
165
163
 
@@ -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
@@ -594,13 +596,6 @@ describe Puppet::Application do
594
596
  end
595
597
 
596
598
  it "should raise an error if dispatch returns no command" do
597
- allow(@app).to receive(:get_command).and_return(nil)
598
- expect(Puppet).to receive(:send_log).with(:err, "Could not run: No valid command or main")
599
- expect { @app.run }.to exit_with 1
600
- end
601
-
602
- it "should raise an error if dispatch returns an invalid command" do
603
- allow(@app).to receive(:get_command).and_return(:this_function_doesnt_exist)
604
599
  expect(Puppet).to receive(:send_log).with(:err, "Could not run: No valid command or main")
605
600
  expect { @app.run }.to exit_with 1
606
601
  end
@@ -718,5 +713,18 @@ describe Puppet::Application do
718
713
 
719
714
  @app.handle_logdest_arg(nil)
720
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
721
729
  end
722
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)
@@ -15,13 +15,6 @@ describe Puppet::Face[:node, '0.0.1'] do
15
15
  end
16
16
 
17
17
  describe 'when running #clean' do
18
- before :each do
19
- allow(Puppet::Node::Facts.indirection).to receive(:terminus_class=)
20
- allow(Puppet::Node::Facts.indirection).to receive(:cache_class=)
21
- allow(Puppet::Node).to receive(:terminus_class=)
22
- allow(Puppet::Node).to receive(:cache_class=)
23
- end
24
-
25
18
  it 'should invoke #cleanup' do
26
19
  expect(subject).to receive(:cleanup).with('hostname')
27
20
  subject.clean('hostname')
@@ -30,10 +23,6 @@ describe Puppet::Face[:node, '0.0.1'] do
30
23
 
31
24
  describe "clean action" do
32
25
  before :each do
33
- allow(Puppet::Node::Facts.indirection).to receive(:terminus_class=)
34
- allow(Puppet::Node::Facts.indirection).to receive(:cache_class=)
35
- allow(Puppet::Node).to receive(:terminus_class=)
36
- allow(Puppet::Node).to receive(:cache_class=)
37
26
  allow(subject).to receive(:cleanup)
38
27
  end
39
28
 
@@ -87,7 +87,6 @@ describe Puppet::FileServing::Configuration::Parser do
87
87
  before do
88
88
  @mount = double('testmount', :name => "one", :validate => true)
89
89
  expect(Puppet::FileServing::Mount::File).to receive(:new).with("one").and_return(@mount)
90
- allow(@parser).to receive(:add_modules_mount)
91
90
  end
92
91
 
93
92
  it "should set the mount path to the path attribute from that section" do
@@ -122,6 +121,14 @@ describe Puppet::FileServing::Configuration::Parser do
122
121
  end
123
122
  }
124
123
 
124
+ it "should not generate an error when parsing 'allow *'" do
125
+ write_config_file "[one]\nallow *\n"
126
+
127
+ expect(Puppet).to receive(:err).never
128
+
129
+ @parser.parse
130
+ end
131
+
125
132
  it "should return comprehensible error message, if failed on invalid attribute" do
126
133
  write_config_file "[one]\ndo something\n"
127
134
 
@@ -266,9 +266,9 @@ describe Puppet::FileServing::Metadata, :uses_checksums => true do
266
266
  path = tmpfile('bar')
267
267
  FileUtils.touch(path)
268
268
 
269
- allow(Puppet::Util::Windows::Security).to receive(:get_owner).with(path, :use).and_raise(invalid_error)
270
- allow(Puppet::Util::Windows::Security).to receive(:get_group).with(path, :use).and_raise(invalid_error)
271
- allow(Puppet::Util::Windows::Security).to receive(:get_mode).with(path, :use).and_raise(invalid_error)
269
+ allow(Puppet::Util::Windows::Security).to receive(:get_owner).with(path).and_raise(invalid_error)
270
+ allow(Puppet::Util::Windows::Security).to receive(:get_group).with(path).and_raise(invalid_error)
271
+ allow(Puppet::Util::Windows::Security).to receive(:get_mode).with(path).and_raise(invalid_error)
272
272
 
273
273
  stat = Puppet::FileSystem.stat(path)
274
274
 
@@ -2,13 +2,20 @@ require 'spec_helper'
2
2
 
3
3
  require 'puppet/file_serving/terminus_helper'
4
4
 
5
+ class Puppet::FileServing::TestHelper
6
+ include Puppet::FileServing::TerminusHelper
7
+
8
+ attr_reader :model
9
+
10
+ def initialize(model)
11
+ @model = model
12
+ end
13
+ end
14
+
5
15
  describe Puppet::FileServing::TerminusHelper do
6
16
  before do
7
- @helper = Object.new
8
- @helper.extend(Puppet::FileServing::TerminusHelper)
9
-
10
17
  @model = double('model')
11
- allow(@helper).to receive(:model).and_return(@model)
18
+ @helper = Puppet::FileServing::TestHelper.new(@model)
12
19
 
13
20
  @request = double('request', :key => "url", :options => {})
14
21
 
@@ -22,13 +22,8 @@ describe Puppet::Forge::ModuleRelease do
22
22
  let(:uri) { " "}
23
23
  let(:release) { Puppet::Forge::ModuleRelease.new(ssl_repository, JSON.parse(release_json)) }
24
24
 
25
- let(:mock_file) {
26
- mock_io = StringIO.new
27
- allow(mock_io).to receive(:path).and_return('/dev/null')
28
- mock_io
29
- }
30
-
31
- let(:mock_dir) { '/tmp' }
25
+ let(:mock_file) { double('file', path: '/dev/null') }
26
+ let(:mock_dir) { tmpdir('dir') }
32
27
 
33
28
  let(:destination) { tmpfile('forge_module_release') }
34
29
 
@@ -33,7 +33,6 @@ describe Puppet::Indirector::Face do
33
33
  describe "as an instance" do
34
34
  it "should be able to determine its indirection" do
35
35
  # Loading actions here can get, um, complicated
36
- allow(Puppet::Face).to receive(:load_actions)
37
36
  expect(Puppet::Indirector::Face.new(:catalog, '0.0.1').indirection).to equal(Puppet::Resource::Catalog.indirection)
38
37
  end
39
38
  end
@@ -22,7 +22,6 @@ describe Puppet::Node::Facts::Facter do
22
22
  end
23
23
 
24
24
  before :each do
25
- allow(Puppet::Node::Facts::Facter).to receive(:reload_facter)
26
25
  @facter = Puppet::Node::Facts::Facter.new
27
26
  allow(Facter).to receive(:to_hash).and_return({})
28
27
  @name = "me"
@@ -154,19 +153,17 @@ describe Puppet::Node::Facts::Facter do
154
153
  end
155
154
 
156
155
  describe 'when :resolve_options is true' do
157
- let(:options) { { resolve_options: true, user_query: ["os", "timezone"], show_legacy: true } }
156
+ let(:options) { { resolve_options: true, user_query: ["os", "timezone"] } }
158
157
  let(:facts) { Puppet::Node::Facts.new("foo") }
159
158
 
160
159
  before :each do
161
160
  allow(@request).to receive(:options).and_return(options)
162
161
  allow(Puppet::Node::Facts).to receive(:new).and_return(facts)
163
- allow(Facter).to receive(:respond_to?).and_return(false)
164
- allow(Facter).to receive(:respond_to?).with(:resolve).and_return(true)
165
162
  allow(facts).to receive(:add_local_facts)
166
163
  end
167
164
 
168
165
  it 'should call Facter.resolve method' do
169
- expect(Facter).to receive(:resolve).with("os timezone --show-legacy")
166
+ expect(Facter).to receive(:resolve).with("os timezone")
170
167
  @facter.find(@request)
171
168
  end
172
169
 
@@ -176,6 +173,15 @@ describe Puppet::Node::Facts::Facter do
176
173
  @facter.find(@request)
177
174
  end
178
175
 
176
+ context 'when --show-legacy flag is present' do
177
+ let(:options) { { resolve_options: true, user_query: ["os", "timezone"], show_legacy: true } }
178
+
179
+ it 'should call Facter.resolve method with show-legacy' do
180
+ expect(Facter).to receive(:resolve).with("os timezone --show-legacy")
181
+ @facter.find(@request)
182
+ end
183
+ end
184
+
179
185
  describe 'when Facter version is lower than 4.0.40' do
180
186
  before :each do
181
187
  allow(Facter).to receive(:respond_to?).and_return(false)