puppet 6.4.3-x86-mingw32 → 6.4.4-x86-mingw32

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

Potentially problematic release.


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

Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/CODEOWNERS +9 -9
  3. data/Gemfile +2 -2
  4. data/Gemfile.lock +23 -23
  5. data/ext/project_data.yaml +2 -2
  6. data/install.rb +3 -21
  7. data/lib/puppet/application/agent.rb +12 -0
  8. data/lib/puppet/application/device.rb +14 -4
  9. data/lib/puppet/application/resource.rb +4 -4
  10. data/lib/puppet/defaults.rb +12 -0
  11. data/lib/puppet/face/config.rb +10 -48
  12. data/lib/puppet/face/facts.rb +1 -1
  13. data/lib/puppet/face/help.rb +1 -1
  14. data/lib/puppet/face/plugin.rb +9 -2
  15. data/lib/puppet/indirector/catalog/compiler.rb +11 -5
  16. data/lib/puppet/module_tool/tar/mini.rb +11 -1
  17. data/lib/puppet/network/http/factory.rb +1 -11
  18. data/lib/puppet/provider/file/posix.rb +5 -0
  19. data/lib/puppet/provider/nameservice.rb +10 -3
  20. data/lib/puppet/provider/package/dnf.rb +1 -1
  21. data/lib/puppet/provider/package/pip.rb +2 -2
  22. data/lib/puppet/provider/package/rpm.rb +51 -13
  23. data/lib/puppet/provider/package/yum.rb +8 -4
  24. data/lib/puppet/provider/service/launchd.rb +20 -5
  25. data/lib/puppet/provider/service/systemd.rb +5 -10
  26. data/lib/puppet/provider/service/windows.rb +8 -0
  27. data/lib/puppet/provider/user/pw.rb +12 -3
  28. data/lib/puppet/provider/user/user_role_add.rb +4 -0
  29. data/lib/puppet/provider/user/useradd.rb +23 -7
  30. data/lib/puppet/resource.rb +17 -0
  31. data/lib/puppet/settings.rb +40 -0
  32. data/lib/puppet/type/exec.rb +14 -6
  33. data/lib/puppet/type/package.rb +10 -0
  34. data/lib/puppet/type/service.rb +7 -2
  35. data/lib/puppet/util/execution.rb +4 -3
  36. data/lib/puppet/util/http_proxy.rb +19 -5
  37. data/lib/puppet/util/selinux.rb +5 -1
  38. data/lib/puppet/util/windows/security.rb +2 -0
  39. data/lib/puppet/util/windows/service.rb +149 -4
  40. data/lib/puppet/util/windows/sid.rb +1 -0
  41. data/lib/puppet/version.rb +1 -1
  42. data/locales/puppet.pot +168 -152
  43. data/man/man5/puppet.conf.5 +18 -2
  44. data/man/man8/puppet-agent.8 +1 -1
  45. data/man/man8/puppet-apply.8 +1 -1
  46. data/man/man8/puppet-catalog.8 +1 -1
  47. data/man/man8/puppet-config.8 +1 -1
  48. data/man/man8/puppet-describe.8 +1 -1
  49. data/man/man8/puppet-device.8 +1 -1
  50. data/man/man8/puppet-doc.8 +1 -1
  51. data/man/man8/puppet-epp.8 +1 -1
  52. data/man/man8/puppet-facts.8 +1 -1
  53. data/man/man8/puppet-filebucket.8 +1 -1
  54. data/man/man8/puppet-generate.8 +1 -1
  55. data/man/man8/puppet-help.8 +1 -1
  56. data/man/man8/puppet-key.8 +1 -1
  57. data/man/man8/puppet-lookup.8 +1 -1
  58. data/man/man8/puppet-man.8 +1 -1
  59. data/man/man8/puppet-module.8 +1 -1
  60. data/man/man8/puppet-node.8 +1 -1
  61. data/man/man8/puppet-parser.8 +1 -1
  62. data/man/man8/puppet-plugin.8 +1 -1
  63. data/man/man8/puppet-report.8 +1 -1
  64. data/man/man8/puppet-resource.8 +1 -1
  65. data/man/man8/puppet-script.8 +1 -1
  66. data/man/man8/puppet-ssl.8 +1 -1
  67. data/man/man8/puppet-status.8 +1 -1
  68. data/man/man8/puppet.8 +3 -3
  69. data/spec/integration/provider/service/systemd_spec.rb +8 -5
  70. data/spec/integration/type/file_spec.rb +28 -0
  71. data/spec/integration/util/execution_spec.rb +27 -0
  72. data/spec/unit/application/agent_spec.rb +20 -8
  73. data/spec/unit/application/device_spec.rb +27 -1
  74. data/spec/unit/face/facts_spec.rb +9 -0
  75. data/spec/unit/face/plugin_spec.rb +8 -0
  76. data/spec/unit/indirector/catalog/compiler_spec.rb +62 -5
  77. data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
  78. data/spec/unit/network/http/api/indirected_routes_spec.rb +25 -10
  79. data/spec/unit/network/http/factory_spec.rb +27 -5
  80. data/spec/unit/pops/validator/validator_spec.rb +7 -0
  81. data/spec/unit/provider/package/aptrpm_spec.rb +1 -1
  82. data/spec/unit/provider/package/dnf_spec.rb +7 -0
  83. data/spec/unit/provider/package/dpkg_spec.rb +2 -2
  84. data/spec/unit/provider/package/pip_spec.rb +8 -0
  85. data/spec/unit/provider/package/rpm_spec.rb +150 -16
  86. data/spec/unit/provider/package/yum_spec.rb +7 -0
  87. data/spec/unit/provider/service/launchd_spec.rb +28 -0
  88. data/spec/unit/provider/service/systemd_spec.rb +14 -0
  89. data/spec/unit/provider/service/windows_spec.rb +20 -0
  90. data/spec/unit/provider/user/pw_spec.rb +37 -0
  91. data/spec/unit/provider/user/useradd_spec.rb +42 -0
  92. data/spec/unit/resource_spec.rb +26 -1
  93. data/spec/unit/transaction_spec.rb +18 -0
  94. data/spec/unit/type/exec_spec.rb +9 -0
  95. data/spec/unit/type/file/source_spec.rb +4 -4
  96. data/spec/unit/type/schedule_spec.rb +3 -1
  97. data/spec/unit/type/service_spec.rb +16 -0
  98. data/spec/unit/util/http_proxy_spec.rb +40 -1
  99. data/spec/unit/util/log_spec.rb +27 -1
  100. data/spec/unit/util/windows/service_spec.rb +9 -0
  101. metadata +5 -9
  102. data/ext/windows/eventlog/Rakefile +0 -32
  103. data/ext/windows/eventlog/puppetres.dll +0 -0
  104. data/ext/windows/eventlog/puppetres.mc +0 -18
@@ -64,6 +64,13 @@ describe Puppet::Type.type(:package).provider(:yum) do
64
64
 
65
65
  before { allow(described_class).to receive(:command).with(:cmd).and_return("/usr/bin/yum") }
66
66
 
67
+ describe 'provider features' do
68
+ it { is_expected.to be_versionable }
69
+ it { is_expected.to be_install_options }
70
+ it { is_expected.to be_virtual_packages }
71
+ it { is_expected.to be_install_only }
72
+ end
73
+
67
74
  context "when installing" do
68
75
  it "should use the supplied source as the explicit path to a package to install" do
69
76
  resource[:ensure] = :present
@@ -127,6 +127,8 @@ describe 'Puppet::Type::Service::Provider::Launchd', unless: Puppet::Util::Platf
127
127
  end
128
128
 
129
129
  describe "when starting the service" do
130
+ let(:services) { "12345 0 #{joblabel}" }
131
+
130
132
  it "should call any explicit 'start' command" do
131
133
  resource[:start] = "/bin/false"
132
134
  expect(subject).to receive(:texecute).with(:start, ["/bin/false"], true)
@@ -134,6 +136,7 @@ describe 'Puppet::Type::Service::Provider::Launchd', unless: Puppet::Util::Platf
134
136
  end
135
137
 
136
138
  it "should look for the relevant plist once" do
139
+ allow(provider).to receive(:launchctl).with(:list).and_return(services)
137
140
  expect(subject).to receive(:plist_from_label).and_return([joblabel, {}]).once
138
141
  expect(subject).to receive(:enabled?).and_return(:true)
139
142
  expect(subject).to receive(:execute).with([:launchctl, :load, "-w", joblabel])
@@ -141,6 +144,7 @@ describe 'Puppet::Type::Service::Provider::Launchd', unless: Puppet::Util::Platf
141
144
  end
142
145
 
143
146
  it "should execute 'launchctl load' once without writing to the plist if the job is enabled" do
147
+ allow(provider).to receive(:launchctl).with(:list).and_return(services)
144
148
  expect(subject).to receive(:plist_from_label).and_return([joblabel, {}])
145
149
  expect(subject).to receive(:enabled?).and_return(:true)
146
150
  expect(subject).to receive(:execute).with([:launchctl, :load, "-w", joblabel]).once
@@ -244,6 +248,30 @@ describe 'Puppet::Type::Service::Provider::Launchd', unless: Puppet::Util::Platf
244
248
  end
245
249
  end
246
250
 
251
+ describe "when a service is unavailable" do
252
+ let(:map) { {"some.random.job" => "/path/to/job.plist"} }
253
+
254
+ before :each do
255
+ allow(provider).to receive(:make_label_to_path_map).and_return(map)
256
+ end
257
+
258
+ it "should fail when searching for the unavailable service" do
259
+ expect { provider.jobsearch("NOSUCH") }.to raise_error(Puppet::Error)
260
+ end
261
+
262
+ it "should return false when enabling the service" do
263
+ expect(subject.enabled?).to eq(:false)
264
+ end
265
+
266
+ it "should fail when starting the service" do
267
+ expect { subject.start }.to raise_error(Puppet::Error)
268
+ end
269
+
270
+ it "should fail when starting the service" do
271
+ expect { subject.stop }.to raise_error(Puppet::Error)
272
+ end
273
+ end
274
+
247
275
  [[10, "10.6"], [13, "10.9"]].each do |kernel, version|
248
276
  describe "when enabling the service on OS X #{version}" do
249
277
  it "should write to the global launchd overrides file once" do
@@ -120,6 +120,20 @@ describe 'Puppet::Type::Service::Provider::Systemd', unless: Puppet::Util::Platf
120
120
  expect(provider_class).to be_default
121
121
  end
122
122
 
123
+ it "should be the default provider on debian11" do
124
+ allow(Facter).to receive(:value).with(:osfamily).and_return(:debian)
125
+ allow(Facter).to receive(:value).with(:operatingsystem).and_return(:debian)
126
+ allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("11")
127
+ expect(provider_class).to be_default
128
+ end
129
+
130
+ it "should be the default provider on debian bookworm/sid" do
131
+ allow(Facter).to receive(:value).with(:osfamily).and_return(:debian)
132
+ allow(Facter).to receive(:value).with(:operatingsystem).and_return(:debian)
133
+ allow(Facter).to receive(:value).with(:operatingsystemmajrelease).and_return("bookworm/sid")
134
+ expect(provider_class).to be_default
135
+ end
136
+
123
137
  it "should not be the default provider on ubuntu14.04" do
124
138
  allow(Facter).to receive(:value).with(:osfamily).and_return(:debian)
125
139
  allow(Facter).to receive(:value).with(:operatingsystem).and_return(:ubuntu)
@@ -150,6 +150,11 @@ describe 'Puppet::Type::Service::Provider::Windows',
150
150
  expect(provider.enabled?).to eq(:manual)
151
151
  end
152
152
 
153
+ it "should report a service with a startup type of delayed as delayed" do
154
+ expect(service_util).to receive(:service_start_type).with(name).and_return(:SERVICE_DELAYED_AUTO_START)
155
+ expect(provider.enabled?).to eq(:delayed)
156
+ end
157
+
153
158
  it "should report a service with a startup type of disabled as false" do
154
159
  expect(service_util).to receive(:service_start_type).with(name).and_return(:SERVICE_DISABLED)
155
160
  expect(provider.enabled?).to eq(:false)
@@ -215,4 +220,19 @@ describe 'Puppet::Type::Service::Provider::Windows',
215
220
  }.to raise_error(Puppet::Error, /Cannot enable #{name}/)
216
221
  end
217
222
  end
223
+
224
+ describe "#delayed_start" do
225
+ it "should set service start type to Service_Config_Delayed_Auto_Start (delayed) when delayed" do
226
+ expect(service_util).to receive(:set_startup_mode).with(name, :SERVICE_AUTO_START, true)
227
+ provider.delayed_start
228
+ end
229
+
230
+ it "raises an error if set_startup_mode fails" do
231
+ expect(service_util).to receive(:set_startup_mode).with(name, :SERVICE_AUTO_START, true).and_raise(Puppet::Error.new('foobar'))
232
+
233
+ expect {
234
+ provider.delayed_start
235
+ }.to raise_error(Puppet::Error, /Cannot enable #{name}/)
236
+ end
237
+ end
218
238
  end
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'open3'
2
3
 
3
4
  RSpec::Matchers.define_negated_matcher :excluding, :include
4
5
 
@@ -81,6 +82,23 @@ describe Puppet::Type.type(:user).provider(:pw) do
81
82
  provider.create
82
83
  end
83
84
 
85
+ it "should call execute with sensitive true when the password property is set" do
86
+ Puppet::Util::Log.level = :debug
87
+ resource[:password] = "abc123"
88
+ expect(provider).to receive(:execute).with(kind_of(Array), hash_including(sensitive: true))
89
+ popen = double("popen", :puts => nil, :close => nil)
90
+ expect(Open3).to receive(:popen3).and_return(popen)
91
+ expect(popen).to receive(:puts).with("abc123")
92
+ provider.create
93
+ expect(@logs).not_to be_any {|log| log.level == :debug and log.message =~ /abc123/}
94
+ end
95
+
96
+ it "should call execute with sensitive false when a non-sensitive property is set" do
97
+ resource[:managehome] = true
98
+ expect(provider).to receive(:execute).with(kind_of(Array), hash_including(sensitive: false))
99
+ provider.create
100
+ end
101
+
84
102
  it "should use -s with the correct argument when the shell property is set" do
85
103
  resource[:shell] = "/bin/sh"
86
104
  expect(provider).to receive(:execute).with(include("-s").and(include("/bin/sh")), kind_of(Hash))
@@ -209,5 +227,24 @@ describe Puppet::Type.type(:user).provider(:pw) do
209
227
  expect(provider).to receive(:execute).with(include("-u").and(include(54321)), hash_including(custom_environment: {}))
210
228
  provider.uid = 54321
211
229
  end
230
+
231
+ it "should print a debug message with sensitive data redacted when the password property is set" do
232
+ Puppet::Util::Log.level = :debug
233
+ resource[:password] = "*"
234
+ popen = double("popen", :puts => nil, :close => nil)
235
+ expect(Open3).to receive(:popen3).and_return(popen)
236
+ expect(popen).to receive(:puts).with("abc123")
237
+ provider.password = "abc123"
238
+
239
+ expect(@logs).not_to be_any {|log| log.level == :debug and log.message =~ /abc123/}
240
+ end
241
+
242
+ it "should call execute with sensitive false when a non-sensitive property is set" do
243
+ Puppet::Util::Log.level = :debug
244
+ resource[:home] = "/home/testuser"
245
+ resource[:managehome] = true
246
+ expect(provider).to receive(:execute).with(kind_of(Array), hash_including(sensitive: false))
247
+ provider.home = "/newhome/testuser"
248
+ end
212
249
  end
213
250
  end
@@ -44,6 +44,27 @@ describe Puppet::Type.type(:user).provider(:useradd) do
44
44
  allow(provider).to receive(:exists?).and_return(false)
45
45
  end
46
46
 
47
+ it "should not redact the command from debug logs if there is no password" do
48
+ described_class.has_feature :manages_passwords
49
+ resource[:ensure] = :present
50
+ expect(provider).to receive(:execute).with(kind_of(Array), hash_including(sensitive: false))
51
+ provider.create
52
+ end
53
+
54
+ it "should redact the command from debug logs if there is a password" do
55
+ described_class.has_feature :manages_passwords
56
+ resource2 = Puppet::Type.type(:user).new(
57
+ :name => 'myuser',
58
+ :password => 'a pass word',
59
+ :managehome => :false,
60
+ :system => :false,
61
+ :provider => provider,
62
+ )
63
+ resource2[:ensure] = :present
64
+ expect(provider).to receive(:execute).with(kind_of(Array), hash_including(sensitive: true))
65
+ provider.create
66
+ end
67
+
47
68
  it "should add -g when no gid is specified and group already exists" do
48
69
  allow(Puppet::Util).to receive(:gid).and_return(true)
49
70
  resource[:ensure] = :present
@@ -165,6 +186,27 @@ describe Puppet::Type.type(:user).provider(:useradd) do
165
186
  end
166
187
  end
167
188
 
189
+ describe 'when modifying the password' do
190
+ before do
191
+ described_class.has_feature :libuser
192
+ described_class.has_feature :manages_passwords
193
+ #Setting any resource value here initializes needed variables and methods in the resource and provider
194
+ #Setting a password value here initializes the existence and management of the password parameter itself
195
+ #Otherwise, this value would not need to be initialized for the test
196
+ resource[:password] = ''
197
+ end
198
+
199
+ it "should not call execute with sensitive if non-sensitive data is changed" do
200
+ expect(provider).to receive(:execute).with(kind_of(Array), hash_including(sensitive: false))
201
+ provider.home = 'foo/bar'
202
+ end
203
+
204
+ it "should call execute with sensitive if sensitive data is changed" do
205
+ expect(provider).to receive(:execute).with(kind_of(Array), hash_including(sensitive: true))
206
+ provider.password = 'bird bird bird'
207
+ end
208
+ end
209
+
168
210
  describe '#modify' do
169
211
  describe "on systems with the libuser and forcelocal=false" do
170
212
  before do
@@ -747,7 +747,8 @@ describe Puppet::Resource do
747
747
  @resource = Puppet::Resource.new("one::two", "/my/file",
748
748
  :parameters => {
749
749
  :noop => true,
750
- :foo => %w{one two},
750
+ :foo => [:one, "two"],
751
+ :bar => 'a\'b',
751
752
  :ensure => 'present',
752
753
  }
753
754
  )
@@ -757,10 +758,34 @@ describe Puppet::Resource do
757
758
  expect(@resource.to_hierayaml).to eq(<<-HEREDOC.gsub(/^\s{8}/, ''))
758
759
  /my/file:
759
760
  ensure: 'present'
761
+ bar : 'a\\'b'
760
762
  foo : ['one', 'two']
761
763
  noop : true
762
764
  HEREDOC
763
765
  end
766
+
767
+ it "should convert some types to String" do
768
+ expect(@resource.to_hiera_hash).to eq(
769
+ "/my/file" => {
770
+ 'ensure' => "present",
771
+ 'bar' => "a'b",
772
+ 'foo' => ["one", "two"],
773
+ 'noop' => true
774
+ }
775
+ )
776
+ end
777
+
778
+ it "accepts symbolic titles" do
779
+ res = Puppet::Resource.new(:file, "/my/file", :parameters => { 'ensure' => "present" })
780
+
781
+ expect(res.to_hiera_hash.keys).to eq(["/my/file"])
782
+ end
783
+
784
+ it "emits an empty parameters hash" do
785
+ res = Puppet::Resource.new(:file, "/my/file")
786
+
787
+ expect(res.to_hiera_hash).to eq({"/my/file" => {}})
788
+ end
764
789
  end
765
790
 
766
791
  describe "when converting to json" do
@@ -779,6 +779,24 @@ describe Puppet::Transaction do
779
779
 
780
780
  transaction.evaluate
781
781
  end
782
+
783
+ it "should call Selinux.matchpathcon_fini in case Selinux is enabled ", :if => Puppet.features.posix? do
784
+ unless defined?(Selinux)
785
+ module Selinux
786
+ def self.is_selinux_enabled
787
+ true
788
+ end
789
+ end
790
+ end
791
+
792
+ resource = Puppet::Type.type(:file).new(:path => make_absolute("/tmp/foo"))
793
+ transaction = transaction_with_resource(resource)
794
+
795
+ expect(Selinux).to receive(:matchpathcon_fini)
796
+ expect(Puppet::Util::SELinux).to receive(:selinux_support?).and_return(true)
797
+
798
+ transaction.evaluate
799
+ end
782
800
  end
783
801
 
784
802
  describe 'when checking application run state' do
@@ -771,6 +771,15 @@ RSpec.describe Puppet::Type.type(:exec) do
771
771
  expect(@test.check_all_attributes).to eq(true)
772
772
  expect(@logs.shift.message).to eq("test output")
773
773
  end
774
+
775
+ it "should not emit output to debug if sensitive is true" do
776
+ Puppet::Util::Log.level = :debug
777
+ @test[param] = @fail
778
+ allow(@test.parameters[param]).to receive(:sensitive).and_return(true)
779
+ expect(@test.check_all_attributes).to eq(true)
780
+ expect(@logs).not_to include(an_object_having_attributes(level: :debug, message: "test output"))
781
+ expect(@logs).to include(an_object_having_attributes(level: :debug, message: "[output redacted]"))
782
+ end
774
783
  end
775
784
  end
776
785
  end
@@ -34,11 +34,11 @@ describe Puppet::Type.type(:file).attrclass(:source), :uses_checksums => true do
34
34
  it "should fail if the set values are not URLs" do
35
35
  expect(URI).to receive(:parse).with('foo').and_raise(RuntimeError)
36
36
 
37
- expect(lambda { resource[:source] = %w{foo} }).to raise_error(Puppet::Error)
37
+ expect { resource[:source] = %w{foo} }.to raise_error(Puppet::Error)
38
38
  end
39
39
 
40
40
  it "should fail if the URI is not a local file, file URI, or puppet URI" do
41
- expect(lambda { resource[:source] = %w{ftp://foo/bar} }).to raise_error(Puppet::Error, /Cannot use URLs of type 'ftp' as source for fileserving/)
41
+ expect { resource[:source] = %w{ftp://foo/bar} }.to raise_error(Puppet::Error, /Cannot use URLs of type 'ftp' as source for fileserving/)
42
42
  end
43
43
 
44
44
  it "should strip trailing forward slashes", :unless => Puppet::Util::Platform.windows? do
@@ -61,11 +61,11 @@ describe Puppet::Type.type(:file).attrclass(:source), :uses_checksums => true do
61
61
  end
62
62
 
63
63
  it "should reject relative URI sources" do
64
- expect(lambda { resource[:source] = 'foo/bar' }).to raise_error(Puppet::Error)
64
+ expect { resource[:source] = 'foo/bar' }.to raise_error(Puppet::Error)
65
65
  end
66
66
 
67
67
  it "should reject opaque sources" do
68
- expect(lambda { resource[:source] = 'mailto:foo@com' }).to raise_error(Puppet::Error)
68
+ expect { resource[:source] = 'mailto:foo@com' }.to raise_error(Puppet::Error)
69
69
  end
70
70
 
71
71
  it "should accept URI authority component" do
@@ -446,7 +446,9 @@ describe Puppet::Type.type(:schedule) do
446
446
 
447
447
  it "should fail if the periodmatch is 'number'" do
448
448
  @schedule[:periodmatch] = :number
449
- expect(proc { @schedule[:repeat] = 2 }).to raise_error(Puppet::Error)
449
+ expect {
450
+ @schedule[:repeat] = 2
451
+ }.to raise_error(Puppet::Error)
450
452
  end
451
453
 
452
454
  it "should match if the previous run was further away than the distance divided by the repeat" do
@@ -93,6 +93,13 @@ describe test_title, "when validating attribute values" do
93
93
  expect(srv.should(:enable)).to eq(:manual)
94
94
  end
95
95
 
96
+ it "should support :delayed as a value on Windows" do
97
+ allow(Puppet::Util::Platform).to receive(:windows?).and_return(true)
98
+
99
+ srv = Puppet::Type.type(:service).new(:name => "yay", :enable => :delayed)
100
+ expect(srv.should(:enable)).to eq(:delayed)
101
+ end
102
+
96
103
  it "should not support :manual as a value when not on Windows" do
97
104
  allow(Puppet::Util::Platform).to receive(:windows?).and_return(false)
98
105
 
@@ -101,6 +108,15 @@ describe test_title, "when validating attribute values" do
101
108
  /Setting enable to manual is only supported on Microsoft Windows\./
102
109
  )
103
110
  end
111
+
112
+ it "should not support :delayed as a value when not on Windows" do
113
+ allow(Puppet::Util::Platform).to receive(:windows?).and_return(false)
114
+
115
+ expect { Puppet::Type.type(:service).new(:name => "yay", :enable => :delayed) }.to raise_error(
116
+ Puppet::Error,
117
+ /Setting enable to delayed is only supported on Microsoft Windows\./
118
+ )
119
+ end
104
120
  end
105
121
 
106
122
  describe "the timeout parameter" do
@@ -129,9 +129,32 @@ describe Puppet::Util::HttpProxy do
129
129
 
130
130
  end
131
131
 
132
+ describe ".no_proxy" do
133
+ no_proxy = '127.0.0.1, localhost'
134
+ it "should use a no_proxy list if set in environment" do
135
+ Puppet::Util.withenv('NO_PROXY' => no_proxy) do
136
+ expect(subject.no_proxy).to eq(no_proxy)
137
+ end
138
+ end
139
+
140
+ it "should use a no_proxy list if set in config" do
141
+ Puppet.settings[:no_proxy] = no_proxy
142
+ expect(subject.no_proxy).to eq(no_proxy)
143
+ end
144
+
145
+ it "should use environment variable before puppet settings" do
146
+ no_proxy_puppet_setting = '10.0.0.1, localhost'
147
+ Puppet::Util.withenv('NO_PROXY' => no_proxy) do
148
+ Puppet.settings[:no_proxy] = no_proxy_puppet_setting
149
+ expect(subject.no_proxy).to eq(no_proxy)
150
+ end
151
+ end
152
+ end
153
+
132
154
  describe ".no_proxy?" do
133
155
  no_proxy = '127.0.0.1, localhost, mydomain.com, *.otherdomain.com, oddport.com:8080, *.otheroddport.com:8080, .anotherdomain.com, .anotheroddport.com:8080'
134
- it "should return false if no_proxy does not exist in env" do
156
+
157
+ it "should return false if no_proxy does not exist in environment or puppet settings" do
135
158
  Puppet::Util.withenv('no_proxy' => nil) do
136
159
  dest = 'https://puppetlabs.com'
137
160
  expect(subject.no_proxy?(dest)).to be false
@@ -269,5 +292,21 @@ describe Puppet::Util::HttpProxy do
269
292
 
270
293
  subject.request_with_redirects(dest, :head, 0)
271
294
  end
295
+
296
+ it 'preserves query parameters' do
297
+ url = URI.parse('http://mydomain.com/some/path?foo=bar')
298
+
299
+ expect_any_instance_of(Net::HTTP).to receive(:head) do |_method, path, _headers|
300
+ expect(path).to eq(url)
301
+ end.and_return(http_ok)
302
+
303
+ expect_any_instance_of(Net::HTTP).to receive(:request_get) do |_http, path, _headers, &block|
304
+ expect(path).to eq(url)
305
+ end.and_return(http_ok)
306
+
307
+ subject.request_with_redirects(url, :get, 0) do
308
+ # unused
309
+ end
310
+ end
272
311
  end
273
312
  end
@@ -178,7 +178,7 @@ describe Puppet::Util::Log do
178
178
  expect(logs.collect(&:message)).to include("Inner block", "Outer block")
179
179
  end
180
180
 
181
- it 'includes backtrace for RuntimeError in log message when trace is enabled' do
181
+ it 'includes backtrace for RuntimeError in log message when trace option is passed' do
182
182
  logs = []
183
183
  destination = Puppet::Test::LogCollector.new(logs)
184
184
 
@@ -196,6 +196,32 @@ describe Puppet::Util::Log do
196
196
  expect(log.backtrace).to be_nil
197
197
  end
198
198
 
199
+ context "global options" do
200
+ around :each do |example|
201
+ Puppet[:trace] = true
202
+ example.run
203
+ Puppet[:trace] = false
204
+ end
205
+
206
+ it 'includes backtrace for RuntimeError in log message when trace is enabled globally' do
207
+ logs = []
208
+ destination = Puppet::Test::LogCollector.new(logs)
209
+
210
+ Puppet::Util::Log.newdestination(destination)
211
+ Puppet::Util::Log.with_destination(destination) do
212
+ begin
213
+ raise RuntimeError, 'Oops'
214
+ rescue RuntimeError => e
215
+ Puppet.log_exception(e, :default)
216
+ end
217
+ end
218
+ expect(logs.size).to eq(1)
219
+ log = logs[0]
220
+ expect(log.message).to match('/log_spec.rb')
221
+ expect(log.backtrace).to be_nil
222
+ end
223
+ end
224
+
199
225
  it 'excludes backtrace for RuntimeError in log message when trace is disabled' do
200
226
  logs = []
201
227
  destination = Puppet::Test::LogCollector.new(logs)