puppet 6.4.4-x86-mingw32 → 6.4.5-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 (221) hide show
  1. checksums.yaml +4 -4
  2. data/CODEOWNERS +1 -1
  3. data/Gemfile +4 -4
  4. data/Gemfile.lock +38 -32
  5. data/ext/build_defaults.yaml +1 -0
  6. data/ext/cert_inspector +3 -3
  7. data/ext/puppet-test +2 -2
  8. data/ext/regexp_nodes/regexp_nodes.rb +4 -4
  9. data/ext/windows/service/daemon.rb +38 -8
  10. data/install.rb +6 -6
  11. data/lib/puppet/application.rb +1 -1
  12. data/lib/puppet/application/apply.rb +2 -2
  13. data/lib/puppet/application/describe.rb +3 -9
  14. data/lib/puppet/application/doc.rb +1 -1
  15. data/lib/puppet/application/lookup.rb +1 -1
  16. data/lib/puppet/application/script.rb +2 -2
  17. data/lib/puppet/application/ssl.rb +4 -1
  18. data/lib/puppet/configurer.rb +86 -30
  19. data/lib/puppet/configurer/downloader.rb +2 -6
  20. data/lib/puppet/defaults.rb +32 -6
  21. data/lib/puppet/error.rb +9 -1
  22. data/lib/puppet/face/module/list.rb +5 -5
  23. data/lib/puppet/face/module/search.rb +1 -1
  24. data/lib/puppet/face/module/uninstall.rb +1 -1
  25. data/lib/puppet/face/module/upgrade.rb +1 -1
  26. data/lib/puppet/file_serving/http_metadata.rb +1 -1
  27. data/lib/puppet/file_system.rb +0 -8
  28. data/lib/puppet/file_system/memory_file.rb +1 -1
  29. data/lib/puppet/file_system/posix.rb +3 -2
  30. data/lib/puppet/forge.rb +3 -3
  31. data/lib/puppet/functions.rb +1 -2
  32. data/lib/puppet/functions/camelcase.rb +2 -2
  33. data/lib/puppet/functions/epp.rb +4 -4
  34. data/lib/puppet/functions/find_file.rb +9 -9
  35. data/lib/puppet/functions/inline_epp.rb +5 -5
  36. data/lib/puppet/gettext/module_translations.rb +1 -1
  37. data/lib/puppet/graph/rb_tree_map.rb +2 -2
  38. data/lib/puppet/graph/simple_graph.rb +4 -3
  39. data/lib/puppet/indirector/file_bucket_file/file.rb +1 -1
  40. data/lib/puppet/indirector/hiera.rb +2 -0
  41. data/lib/puppet/indirector/resource/ral.rb +1 -3
  42. data/lib/puppet/indirector/resource/validator.rb +1 -1
  43. data/lib/puppet/interface.rb +2 -1
  44. data/lib/puppet/loaders.rb +0 -1
  45. data/lib/puppet/metatype/manager.rb +1 -1
  46. data/lib/puppet/module.rb +1 -1
  47. data/lib/puppet/module/task.rb +20 -4
  48. data/lib/puppet/module_tool/applications/installer.rb +1 -1
  49. data/lib/puppet/module_tool/applications/uninstaller.rb +3 -3
  50. data/lib/puppet/module_tool/metadata.rb +1 -1
  51. data/lib/puppet/module_tool/shared_behaviors.rb +4 -4
  52. data/lib/puppet/module_tool/tar/mini.rb +1 -1
  53. data/lib/puppet/network/http/api/indirected_routes.rb +12 -11
  54. data/lib/puppet/network/http/connection.rb +10 -12
  55. data/lib/puppet/network/http/pool.rb +2 -0
  56. data/lib/puppet/network/http/site.rb +1 -1
  57. data/lib/puppet/network/resolver.rb +2 -2
  58. data/lib/puppet/node/environment.rb +4 -2
  59. data/lib/puppet/pal/pal_impl.rb +2 -2
  60. data/lib/puppet/parser/ast.rb +1 -1
  61. data/lib/puppet/parser/ast/resourceparam.rb +1 -1
  62. data/lib/puppet/parser/functions.rb +1 -1
  63. data/lib/puppet/parser/functions/epp.rb +3 -3
  64. data/lib/puppet/parser/functions/inline_epp.rb +5 -5
  65. data/lib/puppet/parser/scope.rb +8 -7
  66. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +1 -1
  67. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +1 -1
  68. data/lib/puppet/pops/evaluator/external_syntax_support.rb +3 -2
  69. data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -4
  70. data/lib/puppet/pops/loader/task_instantiator.rb +4 -0
  71. data/lib/puppet/pops/loaders.rb +1 -1
  72. data/lib/puppet/pops/lookup/hiera_config.rb +1 -0
  73. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  74. data/lib/puppet/pops/merge_strategy.rb +22 -18
  75. data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
  76. data/lib/puppet/pops/parser/interpolation_support.rb +4 -4
  77. data/lib/puppet/pops/parser/locator.rb +1 -1
  78. data/lib/puppet/pops/parser/pn_parser.rb +17 -16
  79. data/lib/puppet/pops/puppet_stack.rb +51 -49
  80. data/lib/puppet/pops/types/p_sensitive_type.rb +1 -1
  81. data/lib/puppet/pops/types/string_converter.rb +10 -10
  82. data/lib/puppet/pops/types/types.rb +3 -3
  83. data/lib/puppet/property.rb +1 -1
  84. data/lib/puppet/property/ensure.rb +1 -1
  85. data/lib/puppet/provider/exec.rb +6 -2
  86. data/lib/puppet/provider/nameservice/directoryservice.rb +1 -1
  87. data/lib/puppet/provider/nameservice/pw.rb +2 -2
  88. data/lib/puppet/provider/package/apt.rb +5 -1
  89. data/lib/puppet/provider/package/dnfmodule.rb +87 -0
  90. data/lib/puppet/provider/package/dpkg.rb +34 -18
  91. data/lib/puppet/provider/package/openbsd.rb +1 -1
  92. data/lib/puppet/provider/package/pip.rb +34 -9
  93. data/lib/puppet/provider/package/portage.rb +4 -4
  94. data/lib/puppet/provider/package/rpm.rb +5 -5
  95. data/lib/puppet/provider/package/windows/package.rb +1 -1
  96. data/lib/puppet/provider/package/yum.rb +1 -1
  97. data/lib/puppet/provider/package_targetable.rb +5 -4
  98. data/lib/puppet/provider/parsedfile.rb +1 -1
  99. data/lib/puppet/provider/service/daemontools.rb +9 -9
  100. data/lib/puppet/provider/service/openbsd.rb +1 -1
  101. data/lib/puppet/provider/service/rcng.rb +2 -2
  102. data/lib/puppet/provider/service/runit.rb +2 -8
  103. data/lib/puppet/provider/service/systemd.rb +9 -9
  104. data/lib/puppet/provider/user/directoryservice.rb +1 -1
  105. data/lib/puppet/provider/user/hpux.rb +1 -1
  106. data/lib/puppet/provider/user/user_role_add.rb +1 -1
  107. data/lib/puppet/provider/user/useradd.rb +22 -13
  108. data/lib/puppet/provider/user/windows_adsi.rb +4 -5
  109. data/lib/puppet/reference/indirection.rb +2 -2
  110. data/lib/puppet/reference/metaparameter.rb +1 -3
  111. data/lib/puppet/reference/providers.rb +1 -3
  112. data/lib/puppet/reference/type.rb +3 -9
  113. data/lib/puppet/reports.rb +1 -1
  114. data/lib/puppet/resource.rb +1 -1
  115. data/lib/puppet/resource/catalog.rb +1 -1
  116. data/lib/puppet/settings.rb +3 -3
  117. data/lib/puppet/settings/environment_conf.rb +1 -0
  118. data/lib/puppet/ssl/host.rb +1 -1
  119. data/lib/puppet/ssl/oids.rb +1 -1
  120. data/lib/puppet/transaction.rb +33 -11
  121. data/lib/puppet/transaction/report.rb +1 -1
  122. data/lib/puppet/type.rb +2 -4
  123. data/lib/puppet/type/exec.rb +7 -3
  124. data/lib/puppet/type/file.rb +1 -2
  125. data/lib/puppet/type/file/data_sync.rb +5 -1
  126. data/lib/puppet/type/group.rb +4 -2
  127. data/lib/puppet/type/notify.rb +3 -2
  128. data/lib/puppet/type/package.rb +10 -3
  129. data/lib/puppet/type/schedule.rb +1 -1
  130. data/lib/puppet/type/service.rb +1 -1
  131. data/lib/puppet/type/user.rb +4 -2
  132. data/lib/puppet/util.rb +35 -12
  133. data/lib/puppet/util/command_line/trollop.rb +1 -1
  134. data/lib/puppet/util/http_proxy.rb +8 -14
  135. data/lib/puppet/util/log.rb +2 -2
  136. data/lib/puppet/util/log/destinations.rb +2 -2
  137. data/lib/puppet/util/logging.rb +32 -20
  138. data/lib/puppet/util/metric.rb +2 -2
  139. data/lib/puppet/util/provider_features.rb +2 -4
  140. data/lib/puppet/util/rdoc.rb +1 -1
  141. data/lib/puppet/util/reference.rb +1 -1
  142. data/lib/puppet/util/resource_template.rb +1 -1
  143. data/lib/puppet/util/selinux.rb +3 -1
  144. data/lib/puppet/util/windows/adsi.rb +48 -18
  145. data/lib/puppet/util/windows/registry.rb +7 -5
  146. data/lib/puppet/vendor.rb +1 -1
  147. data/lib/puppet/version.rb +1 -1
  148. data/lib/puppet/x509/cert_provider.rb +13 -6
  149. data/locales/puppet.pot +199 -159
  150. data/man/man5/puppet.conf.5 +35 -5
  151. data/man/man8/puppet-agent.8 +1 -1
  152. data/man/man8/puppet-apply.8 +1 -1
  153. data/man/man8/puppet-catalog.8 +1 -1
  154. data/man/man8/puppet-config.8 +1 -1
  155. data/man/man8/puppet-describe.8 +1 -1
  156. data/man/man8/puppet-device.8 +1 -1
  157. data/man/man8/puppet-doc.8 +1 -1
  158. data/man/man8/puppet-epp.8 +1 -1
  159. data/man/man8/puppet-facts.8 +1 -1
  160. data/man/man8/puppet-filebucket.8 +1 -1
  161. data/man/man8/puppet-generate.8 +1 -1
  162. data/man/man8/puppet-help.8 +1 -1
  163. data/man/man8/puppet-key.8 +1 -1
  164. data/man/man8/puppet-lookup.8 +1 -1
  165. data/man/man8/puppet-man.8 +1 -1
  166. data/man/man8/puppet-module.8 +1 -1
  167. data/man/man8/puppet-node.8 +1 -1
  168. data/man/man8/puppet-parser.8 +1 -1
  169. data/man/man8/puppet-plugin.8 +1 -1
  170. data/man/man8/puppet-report.8 +1 -1
  171. data/man/man8/puppet-resource.8 +1 -1
  172. data/man/man8/puppet-script.8 +1 -1
  173. data/man/man8/puppet-ssl.8 +1 -1
  174. data/man/man8/puppet-status.8 +1 -1
  175. data/man/man8/puppet.8 +2 -2
  176. data/spec/fixtures/unit/provider/package/dnfmodule/dnf-module-list-installed.txt +11 -0
  177. data/spec/integration/configurer_spec.rb +52 -0
  178. data/spec/integration/type/notify_spec.rb +46 -0
  179. data/spec/lib/puppet/certificate_factory.rb +2 -2
  180. data/spec/spec_helper.rb +28 -0
  181. data/spec/unit/application/ssl_spec.rb +4 -7
  182. data/spec/unit/configurer_spec.rb +394 -398
  183. data/spec/unit/defaults_spec.rb +4 -4
  184. data/spec/unit/forge/forge_spec.rb +1 -3
  185. data/spec/unit/forge/repository_spec.rb +1 -3
  186. data/spec/unit/indirector/resource/ral_spec.rb +4 -4
  187. data/spec/unit/network/http/connection_spec.rb +119 -145
  188. data/spec/unit/parser/scope_spec.rb +10 -0
  189. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +8 -3
  190. data/spec/unit/pops/loaders/module_loaders_spec.rb +37 -0
  191. data/spec/unit/provider/exec_spec.rb +209 -0
  192. data/spec/unit/provider/package/dnfmodule_spec.rb +186 -0
  193. data/spec/unit/provider/package/dpkg_spec.rb +238 -78
  194. data/spec/unit/provider/package/pip_spec.rb +51 -6
  195. data/spec/unit/provider/package/portage_spec.rb +4 -4
  196. data/spec/unit/provider/package_targetable_spec.rb +60 -0
  197. data/spec/unit/provider/service/daemontools_spec.rb +24 -0
  198. data/spec/unit/provider/service/runit_spec.rb +24 -0
  199. data/spec/unit/provider/service/systemd_spec.rb +25 -25
  200. data/spec/unit/provider/user/hpux_spec.rb +2 -2
  201. data/spec/unit/provider/user/useradd_spec.rb +46 -0
  202. data/spec/unit/ssl/host_spec.rb +0 -5
  203. data/spec/unit/ssl/state_machine_spec.rb +0 -6
  204. data/spec/unit/transaction_spec.rb +46 -0
  205. data/spec/unit/type/exec_spec.rb +6 -12
  206. data/spec/unit/type/file/content_spec.rb +9 -3
  207. data/spec/unit/type/file_spec.rb +9 -4
  208. data/spec/unit/type/package_spec.rb +5 -0
  209. data/spec/unit/util/execution_spec.rb +16 -0
  210. data/spec/unit/util/http_proxy_spec.rb +118 -27
  211. data/spec/unit/util/log/destinations_spec.rb +7 -3
  212. data/spec/unit/util/log_spec.rb +0 -138
  213. data/spec/unit/util/logging_spec.rb +200 -0
  214. data/spec/unit/util/windows/adsi_spec.rb +51 -0
  215. data/spec/unit/x509/cert_provider_spec.rb +24 -4
  216. data/tasks/manpages.rake +1 -0
  217. metadata +12 -10
  218. data/lib/puppet/pops/loader/null_loader.rb +0 -60
  219. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +0 -24
  220. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +0 -24
  221. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +0 -24
@@ -44,13 +44,13 @@ describe Puppet::Type.type(:package).provider(:portage) do
44
44
  allow(@unslotted_provider).to receive(:qatom).and_return({:category=>"dev-lang", :pn=>"ruby", :pv=>nil, :pr=>nil, :slot=>nil, :pfx=>nil, :sfx=>nil})
45
45
  allow(@unslotted_provider.class).to receive(:emerge).with('--list-sets').and_return(package_sets)
46
46
  @slotted_provider = described_class.new(@slotted_resource)
47
- allow(@slotted_provider).to receive(:qatom).and_return({:category=>"dev-lang", :pn=>"ruby", :pv=>nil, :pr=>nil, :slot=>":2.1", :pfx=>nil, :sfx=>nil})
47
+ allow(@slotted_provider).to receive(:qatom).and_return({:category=>"dev-lang", :pn=>"ruby", :pv=>nil, :pr=>nil, :slot=>"2.1", :pfx=>nil, :sfx=>nil})
48
48
  allow(@slotted_provider.class).to receive(:emerge).with('--list-sets').and_return(package_sets)
49
49
  @versioned_provider = described_class.new(@versioned_resource)
50
50
  allow(@versioned_provider).to receive(:qatom).and_return({:category=>"dev-lang", :pn=>"ruby", :pv=>"1.9.3", :pr=>nil, :slot=>nil, :pfx=>"=", :sfx=>nil})
51
51
  allow(@versioned_provider.class).to receive(:emerge).with('--list-sets').and_return(package_sets)
52
52
  @versioned_slotted_provider = described_class.new(@versioned_slotted_resource)
53
- allow(@versioned_slotted_provider).to receive(:qatom).and_return({:category=>"dev-lang", :pn=>"ruby", :pv=>"1.9.3", :pr=>nil, :slot=>":1.9", :pfx=>"=", :sfx=>nil})
53
+ allow(@versioned_slotted_provider).to receive(:qatom).and_return({:category=>"dev-lang", :pn=>"ruby", :pv=>"1.9.3", :pr=>nil, :slot=>"1.9", :pfx=>"=", :sfx=>nil})
54
54
  allow(@versioned_slotted_provider.class).to receive(:emerge).with('--list-sets').and_return(package_sets)
55
55
  @set_provider = described_class.new(@set_resource)
56
56
  allow(@set_provider).to receive(:qatom).and_return({:category=>nil, :pn=>"@system", :pv=>nil, :pr=>nil, :slot=>nil, :pfx=>nil, :sfx=>nil})
@@ -180,7 +180,7 @@ describe Puppet::Type.type(:package).provider(:portage) do
180
180
  end
181
181
 
182
182
  it "can extract the slot from the package name" do
183
- expect(@slotted_provider.qatom[:slot]).to eq(':2.1')
183
+ expect(@slotted_provider.qatom[:slot]).to eq('2.1')
184
184
  end
185
185
 
186
186
  it "returns nil for as the slot when no slot is specified" do
@@ -196,7 +196,7 @@ describe Puppet::Type.type(:package).provider(:portage) do
196
196
  expect(@versioned_slotted_provider.qatom[:category]).to eq('dev-lang')
197
197
  expect(@versioned_slotted_provider.qatom[:pn]).to eq('ruby')
198
198
  expect(@versioned_slotted_provider.qatom[:pv]).to eq('1.9.3')
199
- expect(@versioned_slotted_provider.qatom[:slot]).to eq(':1.9')
199
+ expect(@versioned_slotted_provider.qatom[:slot]).to eq('1.9')
200
200
  end
201
201
 
202
202
  it "can handle search output with slots for unslotted packages" do
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+ require 'puppet'
3
+ require 'puppet/provider/package_targetable'
4
+ require 'puppet/provider/package/gem'
5
+
6
+ describe Puppet::Provider::Package::Targetable do
7
+ let(:provider) { Puppet::Type.type(:package).provider(:gem) }
8
+ let(:command) { '/opt/bin/gem' }
9
+
10
+ describe "when prefetching" do
11
+ context "with a package without a command attribute" do
12
+ let(:resource) { Puppet::Type.type(:package).new(:name => 'noo', :provider => 'gem', :ensure => :present) }
13
+ let(:catalog) { Puppet::Resource::Catalog.new }
14
+ let(:instance) { provider.new(resource) }
15
+ let(:packages) { { 'noo' => resource } }
16
+
17
+ it "should pass a command to the instances method of the provider" do
18
+ catalog.add_resource(resource)
19
+ expect(provider).to receive(:instances).with(nil).and_return([instance])
20
+ expect(provider.prefetch(packages)).to eq([nil]) # prefetch arbitrarily returns the array of commands for a provider in the catalog
21
+ end
22
+ end
23
+
24
+ context "with a package with a command attribute" do
25
+ let(:resource) { Puppet::Type.type(:package).new(:name => 'noo', :provider => 'gem', :ensure => :present) }
26
+ let(:resource_targeted) { Puppet::Type.type(:package).new(:name => 'yes', :provider => 'gem', :command => command, :ensure => :present) }
27
+ let(:catalog) { Puppet::Resource::Catalog.new }
28
+ let(:instance) { provider.new(resource) }
29
+ let(:instance_targeted) { provider.new(resource_targeted) }
30
+ let(:packages) { { 'noo' => resource, 'yes' => resource_targeted } }
31
+
32
+ it "should pass the command to the instances method of the provider" do
33
+ catalog.add_resource(resource)
34
+ catalog.add_resource(resource_targeted)
35
+ expect(provider).to receive(:instances).with(nil).and_return([instance])
36
+ expect(provider).to receive(:instances).with(command).and_return([instance_targeted]).once
37
+ expect(provider.prefetch(packages)).to eq([nil, command]) # prefetch arbitrarily returns the array of commands for a provider in the catalog
38
+ end
39
+ end
40
+ end
41
+
42
+ describe "when validating a command" do
43
+ context "with no command" do
44
+ it "report not functional" do
45
+ expect { provider.validate_command(nil) }.to raise_error(Puppet::Error, "Provider gem package command is not functional on this host")
46
+ end
47
+ end
48
+ context "with a missing command" do
49
+ it "report does not exist" do
50
+ expect { provider.validate_command(command) }.to raise_error(Puppet::Error, "Provider gem package command '#{command}' does not exist on this host")
51
+ end
52
+ end
53
+ context "with an existing command" do
54
+ it "validates" do
55
+ allow(File).to receive(:file?).with(command).and_return(true)
56
+ expect { provider.validate_command(command) }.not_to raise_error
57
+ end
58
+ end
59
+ end
60
+ end
@@ -163,4 +163,28 @@ describe 'Puppet::Type::Service::Provider::Daemontools',
163
163
  expect(@provider.status).to eq(:stopped)
164
164
  end
165
165
  end
166
+
167
+ context '.instances' do
168
+ before do
169
+ allow(provider_class).to receive(:defpath).and_return(path)
170
+ end
171
+
172
+ context 'when defpath is nil' do
173
+ let(:path) { nil }
174
+
175
+ it 'returns info message' do
176
+ expect(Puppet).to receive(:info).with(/daemontools is unsuitable because service directory is nil/)
177
+ provider_class.instances
178
+ end
179
+ end
180
+
181
+ context 'when defpath does not exist' do
182
+ let(:path) { '/inexistent_path' }
183
+
184
+ it 'returns notice about missing path' do
185
+ expect(Puppet).to receive(:notice).with(/Service path #{path} does not exist/)
186
+ provider_class.instances
187
+ end
188
+ end
189
+ end
166
190
  end
@@ -136,4 +136,28 @@ describe 'Puppet::Type::Service::Provider::Runit', unless: Puppet::Util::Platfor
136
136
  expect(@provider.status).to eq(:stopped)
137
137
  end
138
138
  end
139
+
140
+ context '.instances' do
141
+ before do
142
+ allow(provider_class).to receive(:defpath).and_return(path)
143
+ end
144
+
145
+ context 'when defpath is nil' do
146
+ let(:path) { nil }
147
+
148
+ it 'returns info message' do
149
+ expect(Puppet).to receive(:info).with(/runit is unsuitable because service directory is nil/)
150
+ provider_class.instances
151
+ end
152
+ end
153
+
154
+ context 'when defpath does not exist' do
155
+ let(:path) { '/inexistent_path' }
156
+
157
+ it 'returns notice about missing path' do
158
+ expect(Puppet).to receive(:notice).with(/Service path #{path} does not exist/)
159
+ provider_class.instances
160
+ end
161
+ end
162
+ end
139
163
  end
@@ -201,17 +201,17 @@ describe 'Puppet::Type::Service::Provider::Systemd', unless: Puppet::Util::Platf
201
201
 
202
202
  it "should start the service with systemctl start otherwise" do
203
203
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
204
- expect(provider).to receive(:systemctl).with(:unmask, 'sshd.service')
204
+ expect(provider).to receive(:systemctl).with(:unmask, '--', 'sshd.service')
205
205
  expect(provider).to receive(:daemon_reload?).and_return('no')
206
- expect(provider).to receive(:execute).with(['/bin/systemctl','start','sshd.service'], {:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
206
+ expect(provider).to receive(:execute).with(['/bin/systemctl','start', '--', 'sshd.service'], {:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
207
207
  provider.start
208
208
  end
209
209
 
210
210
  it "should show journald logs on failure" do
211
211
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
212
- expect(provider).to receive(:systemctl).with(:unmask, 'sshd.service')
212
+ expect(provider).to receive(:systemctl).with(:unmask, '--', 'sshd.service')
213
213
  expect(provider).to receive(:daemon_reload?).and_return('no')
214
- expect(provider).to receive(:execute).with(['/bin/systemctl','start','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
214
+ expect(provider).to receive(:execute).with(['/bin/systemctl','start', '--', 'sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
215
215
  .and_raise(Puppet::ExecutionFailure, "Failed to start sshd.service: Unit sshd.service failed to load: Invalid argument. See system logs and 'systemctl status sshd.service' for details.")
216
216
  journalctl_logs = <<-EOS
217
217
  -- Logs begin at Tue 2016-06-14 11:59:21 UTC, end at Tue 2016-06-14 21:45:02 UTC. --
@@ -233,13 +233,13 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
233
233
 
234
234
  it "should stop the service with systemctl stop otherwise" do
235
235
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
236
- expect(provider).to receive(:execute).with(['/bin/systemctl','stop','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
236
+ expect(provider).to receive(:execute).with(['/bin/systemctl','stop', '--', 'sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
237
237
  provider.stop
238
238
  end
239
239
 
240
240
  it "should show journald logs on failure" do
241
241
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
242
- expect(provider).to receive(:execute).with(['/bin/systemctl','stop','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
242
+ expect(provider).to receive(:execute).with(['/bin/systemctl','stop', '--', 'sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
243
243
  .and_raise(Puppet::ExecutionFailure, "Failed to stop sshd.service: Unit sshd.service failed to load: Invalid argument. See system logs and 'systemctl status sshd.service' for details.")
244
244
  journalctl_logs = <<-EOS
245
245
  -- Logs begin at Tue 2016-06-14 11:59:21 UTC, end at Tue 2016-06-14 21:45:02 UTC. --
@@ -255,13 +255,13 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
255
255
  describe "#daemon_reload?" do
256
256
  it "should skip the systemctl daemon_reload if not required by the service" do
257
257
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
258
- expect(provider).to receive(:execute).with(['/bin/systemctl','show','sshd.service','--property=NeedDaemonReload'], :failonfail => false).and_return("no")
258
+ expect(provider).to receive(:execute).with(['/bin/systemctl', 'show', '--property=NeedDaemonReload', '--', 'sshd.service'], :failonfail => false).and_return("no")
259
259
  provider.daemon_reload?
260
260
  end
261
261
  it "should run a systemctl daemon_reload if the service has been modified" do
262
262
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
263
- expect(provider).to receive(:execute).with(['/bin/systemctl','show','sshd.service','--property=NeedDaemonReload'], :failonfail => false).and_return("yes")
264
- expect(provider).to receive(:execute).with(['/bin/systemctl','daemon-reload'], :failonfail => false)
263
+ expect(provider).to receive(:execute).with(['/bin/systemctl', 'show', '--property=NeedDaemonReload', '--', 'sshd.service'], :failonfail => false).and_return("yes")
264
+ expect(provider).to receive(:execute).with(['/bin/systemctl', 'daemon-reload'], :failonfail => false)
265
265
  provider.daemon_reload?
266
266
  end
267
267
  end
@@ -269,42 +269,42 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
269
269
  describe "#enabled?" do
270
270
  it "should return :true if the service is enabled" do
271
271
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
272
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("enabled\n")
272
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'sshd.service'], :failonfail => false).and_return("enabled\n")
273
273
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
274
274
  expect(provider.enabled?).to eq(:true)
275
275
  end
276
276
 
277
277
  it "should return :true if the service is static" do
278
278
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
279
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("static\n")
279
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','--', 'sshd.service'], :failonfail => false).and_return("static\n")
280
280
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
281
281
  expect(provider.enabled?).to eq(:true)
282
282
  end
283
283
 
284
284
  it "should return :false if the service is disabled" do
285
285
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
286
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("disabled\n")
286
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'sshd.service'], :failonfail => false).and_return("disabled\n")
287
287
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(1)
288
288
  expect(provider.enabled?).to eq(:false)
289
289
  end
290
290
 
291
291
  it "should return :false if the service is indirect" do
292
292
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
293
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("indirect\n")
293
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'sshd.service'], :failonfail => false).and_return("indirect\n")
294
294
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
295
295
  expect(provider.enabled?).to eq(:false)
296
296
  end
297
297
 
298
298
  it "should return :false if the service is masked and the resource is attempting to be disabled" do
299
299
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service', :enable => false))
300
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("masked\n")
300
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'sshd.service'], :failonfail => false).and_return("masked\n")
301
301
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(1)
302
302
  expect(provider.enabled?).to eq(:false)
303
303
  end
304
304
 
305
305
  it "should return :mask if the service is masked and the resource is attempting to be masked" do
306
306
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service', :enable => 'mask'))
307
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("masked\n")
307
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled', '--', 'sshd.service'], :failonfail => false).and_return("masked\n")
308
308
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(1)
309
309
  expect(provider.enabled?).to eq(:mask)
310
310
  end
@@ -313,8 +313,8 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
313
313
  describe "#enable" do
314
314
  it "should run systemctl enable to enable a service" do
315
315
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
316
- expect(provider).to receive(:systemctl).with(:unmask, 'sshd.service')
317
- expect(provider).to receive(:systemctl).with(:enable, 'sshd.service')
316
+ expect(provider).to receive(:systemctl).with(:unmask, '--', 'sshd.service')
317
+ expect(provider).to receive(:systemctl).with(:enable, '--', 'sshd.service')
318
318
  provider.enable
319
319
  end
320
320
  end
@@ -322,7 +322,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
322
322
  describe "#disable" do
323
323
  it "should run systemctl disable to disable a service" do
324
324
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
325
- expect(provider).to receive(:systemctl).with(:disable, 'sshd.service')
325
+ expect(provider).to receive(:systemctl).with(:disable, '--', 'sshd.service')
326
326
  provider.disable
327
327
  end
328
328
  end
@@ -333,8 +333,8 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
333
333
  # :disable is the only call in the provider that uses a symbol instead of
334
334
  # a string.
335
335
  # This should be made consistent in the future and all tests updated.
336
- expect(provider).to receive(:systemctl).with(:disable, 'sshd.service')
337
- expect(provider).to receive(:systemctl).with(:mask, 'sshd.service')
336
+ expect(provider).to receive(:systemctl).with(:disable, '--', 'sshd.service')
337
+ expect(provider).to receive(:systemctl).with(:mask, '--', 'sshd.service')
338
338
  provider.mask
339
339
  end
340
340
  end
@@ -344,7 +344,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
344
344
  describe "#status" do
345
345
  it "should return running if if the command returns 0" do
346
346
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
347
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-active','sshd.service'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).and_return("active\n")
347
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-active', '--', 'sshd.service'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).and_return("active\n")
348
348
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
349
349
  expect(provider.status).to eq(:running)
350
350
  end
@@ -352,7 +352,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
352
352
  [-10,-1,3,10].each { |ec|
353
353
  it "should return stopped if the command returns something non-0" do
354
354
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
355
- expect(provider).to receive(:execute).with(['/bin/systemctl','is-active','sshd.service'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).and_return("inactive\n")
355
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-active', '--', 'sshd.service'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true).and_return("inactive\n")
356
356
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(ec)
357
357
  expect(provider.status).to eq(:stopped)
358
358
  end
@@ -371,7 +371,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
371
371
  it "should use the supplied restart command if specified" do
372
372
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :restart => '/bin/foo'))
373
373
  expect(provider).to receive(:daemon_reload?).and_return('no')
374
- expect(provider).to receive(:execute).with(['/bin/systemctl','restart','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true).never
374
+ expect(provider).to receive(:execute).with(['/bin/systemctl','restart', '--', 'sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true).never
375
375
  expect(provider).to receive(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
376
376
  provider.restart
377
377
  end
@@ -379,14 +379,14 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
379
379
  it "should restart the service with systemctl restart" do
380
380
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
381
381
  expect(provider).to receive(:daemon_reload?).and_return('no')
382
- expect(provider).to receive(:execute).with(['/bin/systemctl','restart','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
382
+ expect(provider).to receive(:execute).with(['/bin/systemctl','restart','--','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
383
383
  provider.restart
384
384
  end
385
385
 
386
386
  it "should show journald logs on failure" do
387
387
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
388
388
  expect(provider).to receive(:daemon_reload?).and_return('no')
389
- expect(provider).to receive(:execute).with(['/bin/systemctl','restart','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
389
+ expect(provider).to receive(:execute).with(['/bin/systemctl','restart','--','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
390
390
  .and_raise(Puppet::ExecutionFailure, "Failed to restart sshd.service: Unit sshd.service failed to load: Invalid argument. See system logs and 'systemctl status sshd.service' for details.")
391
391
  journalctl_logs = <<-EOS
392
392
  -- Logs begin at Tue 2016-06-14 11:59:21 UTC, end at Tue 2016-06-14 21:45:02 UTC. --
@@ -58,14 +58,14 @@ describe Puppet::Type.type(:user).provider(:hpuxuseradd),
58
58
  it "should add modprpw to modifycmd if Trusted System" do
59
59
  allow(resource).to receive(:allowdupe?).and_return(true)
60
60
  expect(provider).to receive(:exec_getprpw).with('root','-m uid').and_return('uid=0')
61
- expect(provider).to receive(:execute).with(['/usr/sam/lbin/usermod.sam', '-u', 1000, '-o', 'testuser', '-F', ';', '/usr/lbin/modprpw', '-v', '-l', 'testuser'], hash_including(custom_environment: {}))
61
+ expect(provider).to receive(:execute).with(['/usr/sam/lbin/usermod.sam', '-F', '-u', 1000, '-o', 'testuser', ';', '/usr/lbin/modprpw', '-v', '-l', 'testuser'], hash_including(custom_environment: {}))
62
62
  provider.uid = 1000
63
63
  end
64
64
 
65
65
  it "should not add modprpw if not Trusted System" do
66
66
  allow(resource).to receive(:allowdupe?).and_return(true)
67
67
  expect(provider).to receive(:exec_getprpw).with('root','-m uid').and_return('System is not trusted')
68
- expect(provider).to receive(:execute).with(['/usr/sam/lbin/usermod.sam', '-u', 1000, '-o', 'testuser', '-F'], hash_including(custom_environment: {}))
68
+ expect(provider).to receive(:execute).with(['/usr/sam/lbin/usermod.sam', '-F', '-u', 1000, '-o', 'testuser'], hash_including(custom_environment: {}))
69
69
  provider.uid = 1000
70
70
  end
71
71
  end
@@ -317,6 +317,52 @@ describe Puppet::Type.type(:user).provider(:useradd) do
317
317
  end
318
318
  end
319
319
 
320
+ describe "#comment" do
321
+ before { described_class.has_feature :libuser }
322
+
323
+ let(:content) { "myuser:x:x:x:local comment:x:x" }
324
+
325
+ it "should return the local comment string when forcelocal is true" do
326
+ resource[:forcelocal] = true
327
+ allow(File).to receive(:open).with('/etc/passwd').and_yield(content)
328
+ expect(provider.comment).to eq('local comment')
329
+ end
330
+
331
+ it "should fall back to nameservice comment string when forcelocal is false" do
332
+ resource[:forcelocal] = false
333
+ allow(provider).to receive(:get).with(:comment).and_return('remote comment')
334
+ expect(provider).not_to receive(:localcomment)
335
+ expect(provider.comment).to eq('remote comment')
336
+ end
337
+ end
338
+
339
+ describe "#finduser" do
340
+ before { allow(File).to receive(:open).with('/etc/passwd').and_yield(content) }
341
+
342
+ let(:content) { "sample_account:sample_password:sample_uid:sample_gid:sample_gecos:sample_directory:sample_shell" }
343
+ let(:output) do
344
+ {
345
+ account: 'sample_account',
346
+ password: 'sample_password',
347
+ uid: 'sample_uid',
348
+ gid: 'sample_gid',
349
+ gecos: 'sample_gecos',
350
+ directory: 'sample_directory',
351
+ shell: 'sample_shell',
352
+ }
353
+ end
354
+
355
+ [:account, :password, :uid, :gid, :gecos, :directory, :shell].each do |key|
356
+ it "finds an user by #{key} when asked" do
357
+ expect(provider.finduser(key, "sample_#{key}")).to eq(output)
358
+ end
359
+ end
360
+
361
+ it "returns false when specified key/value pair is not found" do
362
+ expect(provider.finduser(:account, 'invalid_account')).to eq(false)
363
+ end
364
+ end
365
+
320
366
  describe "#check_allow_dup" do
321
367
  it "should return an array with a flag if dup is allowed" do
322
368
  resource[:allowdupe] = :true
@@ -1,5 +1,4 @@
1
1
  require 'spec_helper'
2
- require 'webmock/rspec'
3
2
  require 'puppet/test_ca'
4
3
 
5
4
  require 'puppet/ssl/host'
@@ -308,10 +307,6 @@ describe Puppet::SSL::Host, if: !Puppet::Util::Platform.jruby? do
308
307
  allow(@host).to receive(:validate_certificate_with_key)
309
308
  allow(@host).to receive(:http_client).and_return(@http)
310
309
  allow(@host).to receive(:ssl_store).and_return(double("ssl store"))
311
-
312
- WebMock.disable_net_connect!
313
- allow_any_instance_of(Net::HTTP).to receive(:start)
314
- allow_any_instance_of(Net::HTTP).to receive(:finish)
315
310
  end
316
311
 
317
312
  let(:ca_cert_response) { @pki[:ca_bundle] }
@@ -1,5 +1,4 @@
1
1
  require 'spec_helper'
2
- require 'webmock/rspec'
3
2
  require 'puppet_spec/files'
4
3
 
5
4
  require 'puppet/ssl'
@@ -28,11 +27,6 @@ describe Puppet::SSL::StateMachine, unless: Puppet::Util::Platform.jruby? do
28
27
  let(:refused_message) { %r{Connection refused|No connection could be made because the target machine actively refused it} }
29
28
 
30
29
  before(:each) do
31
- WebMock.disable_net_connect!
32
-
33
- allow_any_instance_of(Net::HTTP).to receive(:start)
34
- allow_any_instance_of(Net::HTTP).to receive(:finish)
35
-
36
30
  allow(Kernel).to receive(:sleep)
37
31
  end
38
32
 
@@ -3,6 +3,7 @@ require 'matchers/include_in_order'
3
3
  require 'puppet_spec/compiler'
4
4
 
5
5
  require 'puppet/transaction'
6
+ require 'puppet/type/exec'
6
7
  require 'puppet/type/notify'
7
8
  require 'fileutils'
8
9
 
@@ -967,6 +968,51 @@ describe Puppet::Transaction do
967
968
  expect(times_send_log_with_skipping_called).to eq(3)
968
969
  end
969
970
  end
971
+
972
+ describe "failed dependency is depended on multiple times" do
973
+ it "notifies and warns the failed class dependency once" do
974
+ Puppet.settings[:merge_dependency_warnings] = true
975
+
976
+ command_string = File.expand_path('/my/command')
977
+ allow(Puppet::Util::Execution).to receive(:execute).with([command_string]).and_raise(Puppet::ExecutionFailure, "Failed")
978
+
979
+ # Exec['exec1'] is outside of a class, so it's warning is not subject to being coalesced.
980
+ times_send_log_with_skipping_called = 0
981
+ allow_any_instance_of(Puppet::Type::Exec).to receive(:send_log) {times_send_log_with_skipping_called += 1; nil}.with(:warning, "Skipping because of failed dependencies")
982
+
983
+ # Class['declared_class'] depends upon Class['required_class'] which contains a resource with a failure.
984
+ times_send_log_with_class_dependency_called = 0
985
+ allow_any_instance_of(Puppet::Type).to receive(:send_log) {times_send_log_with_class_dependency_called += 1; nil}.with(:notice, "Class dependency Exec[exec2] has failures: true")
986
+ times_send_log_with_class_skipping_called = 0
987
+ allow_any_instance_of(Puppet::Type).to receive(:send_log) {times_send_log_with_class_skipping_called += 1; nil}.with(:warning, "Skipping resources in class because of failed class dependencies")
988
+
989
+ apply_compiled_manifest(<<-MANIFEST)
990
+ class required_class {
991
+ exec { 'exec2':
992
+ command => '#{command_string}'
993
+ }
994
+ }
995
+ class declared_class {
996
+ require required_class
997
+ exec { 'exec3':
998
+ command => '#{command_string}'
999
+ }
1000
+ exec { 'exec4':
1001
+ command => '#{command_string}'
1002
+ }
1003
+ }
1004
+ exec { 'exec1':
1005
+ command => '#{command_string}',
1006
+ require => Exec['exec2']
1007
+ }
1008
+ include declared_class
1009
+ MANIFEST
1010
+
1011
+ expect(times_send_log_with_skipping_called).to eq(1)
1012
+ expect(times_send_log_with_class_dependency_called).to eq(1)
1013
+ expect(times_send_log_with_class_skipping_called).to eq(1)
1014
+ end
1015
+ end
970
1016
  end
971
1017
 
972
1018
  describe Puppet::Transaction, " when determining tags" do