puppet 6.4.5-x64-mingw32 → 6.5.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 (329) hide show
  1. checksums.yaml +4 -4
  2. data/CODEOWNERS +10 -10
  3. data/Gemfile +6 -6
  4. data/Gemfile.lock +46 -52
  5. data/ext/build_defaults.yaml +0 -1
  6. data/ext/project_data.yaml +3 -3
  7. data/ext/regexp_nodes/regexp_nodes.rb +4 -4
  8. data/ext/solaris/smf/puppet.xml +0 -2
  9. data/ext/windows/eventlog/Rakefile +32 -0
  10. data/ext/windows/eventlog/puppetres.dll +0 -0
  11. data/ext/windows/eventlog/puppetres.mc +18 -0
  12. data/ext/windows/service/daemon.rb +8 -38
  13. data/install.rb +24 -6
  14. data/lib/puppet.rb +3 -1
  15. data/lib/puppet/application.rb +1 -1
  16. data/lib/puppet/application/agent.rb +11 -34
  17. data/lib/puppet/application/apply.rb +6 -6
  18. data/lib/puppet/application/describe.rb +9 -3
  19. data/lib/puppet/application/device.rb +4 -14
  20. data/lib/puppet/application/doc.rb +1 -1
  21. data/lib/puppet/application/lookup.rb +2 -2
  22. data/lib/puppet/application/resource.rb +4 -4
  23. data/lib/puppet/application/script.rb +2 -2
  24. data/lib/puppet/application/ssl.rb +10 -9
  25. data/lib/puppet/configurer.rb +30 -86
  26. data/lib/puppet/configurer/downloader.rb +6 -2
  27. data/lib/puppet/defaults.rb +50 -44
  28. data/lib/puppet/error.rb +14 -9
  29. data/lib/puppet/face/catalog.rb +20 -1
  30. data/lib/puppet/face/config.rb +48 -10
  31. data/lib/puppet/face/facts.rb +1 -1
  32. data/lib/puppet/face/help.rb +1 -1
  33. data/lib/puppet/face/module/list.rb +5 -5
  34. data/lib/puppet/face/module/search.rb +1 -1
  35. data/lib/puppet/face/module/uninstall.rb +1 -1
  36. data/lib/puppet/face/module/upgrade.rb +1 -1
  37. data/lib/puppet/face/parser.rb +48 -9
  38. data/lib/puppet/face/plugin.rb +2 -9
  39. data/lib/puppet/file_serving/http_metadata.rb +1 -1
  40. data/lib/puppet/file_system.rb +12 -2
  41. data/lib/puppet/file_system/file_impl.rb +6 -3
  42. data/lib/puppet/file_system/memory_file.rb +1 -1
  43. data/lib/puppet/file_system/posix.rb +2 -3
  44. data/lib/puppet/forge.rb +3 -3
  45. data/lib/puppet/functions.rb +2 -1
  46. data/lib/puppet/functions/camelcase.rb +2 -2
  47. data/lib/puppet/functions/epp.rb +4 -4
  48. data/lib/puppet/functions/find_file.rb +9 -9
  49. data/lib/puppet/functions/inline_epp.rb +5 -5
  50. data/lib/puppet/functions/regsubst.rb +6 -8
  51. data/lib/puppet/gettext/module_translations.rb +1 -1
  52. data/lib/puppet/graph/rb_tree_map.rb +2 -2
  53. data/lib/puppet/graph/simple_graph.rb +3 -4
  54. data/lib/puppet/indirector/catalog/compiler.rb +5 -11
  55. data/lib/puppet/indirector/file_bucket_file/file.rb +1 -1
  56. data/lib/puppet/indirector/hiera.rb +0 -2
  57. data/lib/puppet/indirector/resource/ral.rb +3 -1
  58. data/lib/puppet/indirector/resource/validator.rb +1 -1
  59. data/lib/puppet/interface.rb +1 -2
  60. data/lib/puppet/loaders.rb +1 -0
  61. data/lib/puppet/metatype/manager.rb +1 -1
  62. data/lib/puppet/module.rb +1 -1
  63. data/lib/puppet/module/task.rb +4 -20
  64. data/lib/puppet/module_tool/applications/installer.rb +1 -1
  65. data/lib/puppet/module_tool/applications/uninstaller.rb +3 -3
  66. data/lib/puppet/module_tool/metadata.rb +1 -1
  67. data/lib/puppet/module_tool/shared_behaviors.rb +4 -4
  68. data/lib/puppet/module_tool/tar/mini.rb +2 -12
  69. data/lib/puppet/network/http/api/indirected_routes.rb +11 -12
  70. data/lib/puppet/network/http/connection.rb +12 -10
  71. data/lib/puppet/network/http/factory.rb +11 -1
  72. data/lib/puppet/network/http/pool.rb +0 -2
  73. data/lib/puppet/network/http/site.rb +1 -1
  74. data/lib/puppet/network/resolver.rb +2 -2
  75. data/lib/puppet/node/environment.rb +2 -4
  76. data/lib/puppet/pal/pal_impl.rb +2 -2
  77. data/lib/puppet/parser/ast.rb +1 -1
  78. data/lib/puppet/parser/ast/resourceparam.rb +1 -1
  79. data/lib/puppet/parser/functions.rb +1 -1
  80. data/lib/puppet/parser/functions/epp.rb +3 -3
  81. data/lib/puppet/parser/functions/fail.rb +8 -1
  82. data/lib/puppet/parser/functions/inline_epp.rb +5 -5
  83. data/lib/puppet/parser/scope.rb +7 -8
  84. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +1 -1
  85. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +1 -1
  86. data/lib/puppet/pops/evaluator/external_syntax_support.rb +2 -3
  87. data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -4
  88. data/lib/puppet/pops/loader/null_loader.rb +60 -0
  89. data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +6 -4
  90. data/lib/puppet/pops/loader/task_instantiator.rb +0 -4
  91. data/lib/puppet/pops/loaders.rb +1 -1
  92. data/lib/puppet/pops/lookup/hiera_config.rb +0 -1
  93. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  94. data/lib/puppet/pops/merge_strategy.rb +18 -22
  95. data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
  96. data/lib/puppet/pops/parser/interpolation_support.rb +4 -4
  97. data/lib/puppet/pops/parser/locator.rb +1 -1
  98. data/lib/puppet/pops/parser/pn_parser.rb +16 -17
  99. data/lib/puppet/pops/puppet_stack.rb +49 -51
  100. data/lib/puppet/pops/types/p_sensitive_type.rb +1 -1
  101. data/lib/puppet/pops/types/string_converter.rb +10 -10
  102. data/lib/puppet/pops/types/types.rb +6 -5
  103. data/lib/puppet/property.rb +1 -1
  104. data/lib/puppet/property/ensure.rb +1 -1
  105. data/lib/puppet/provider/exec.rb +2 -6
  106. data/lib/puppet/provider/file/posix.rb +0 -5
  107. data/lib/puppet/provider/nameservice.rb +3 -10
  108. data/lib/puppet/provider/nameservice/directoryservice.rb +1 -1
  109. data/lib/puppet/provider/nameservice/pw.rb +2 -2
  110. data/lib/puppet/provider/package.rb +0 -2
  111. data/lib/puppet/provider/package/apt.rb +1 -5
  112. data/lib/puppet/provider/package/dnf.rb +1 -1
  113. data/lib/puppet/provider/package/dpkg.rb +18 -34
  114. data/lib/puppet/provider/package/openbsd.rb +1 -1
  115. data/lib/puppet/provider/package/pip.rb +13 -37
  116. data/lib/puppet/provider/package/portage.rb +4 -4
  117. data/lib/puppet/provider/package/puppet_gem.rb +1 -1
  118. data/lib/puppet/provider/package/rpm.rb +18 -56
  119. data/lib/puppet/provider/package/windows/package.rb +1 -1
  120. data/lib/puppet/provider/package/yum.rb +5 -9
  121. data/lib/puppet/provider/package_targetable.rb +4 -7
  122. data/lib/puppet/provider/parsedfile.rb +1 -1
  123. data/lib/puppet/provider/service/daemontools.rb +9 -9
  124. data/lib/puppet/provider/service/launchd.rb +5 -20
  125. data/lib/puppet/provider/service/openbsd.rb +1 -1
  126. data/lib/puppet/provider/service/rcng.rb +2 -2
  127. data/lib/puppet/provider/service/runit.rb +8 -2
  128. data/lib/puppet/provider/service/systemd.rb +19 -14
  129. data/lib/puppet/provider/service/windows.rb +0 -8
  130. data/lib/puppet/provider/user/directoryservice.rb +1 -1
  131. data/lib/puppet/provider/user/hpux.rb +1 -1
  132. data/lib/puppet/provider/user/pw.rb +3 -12
  133. data/lib/puppet/provider/user/user_role_add.rb +1 -5
  134. data/lib/puppet/provider/user/useradd.rb +20 -45
  135. data/lib/puppet/provider/user/windows_adsi.rb +5 -4
  136. data/lib/puppet/reference/configuration.rb +3 -3
  137. data/lib/puppet/reference/indirection.rb +2 -2
  138. data/lib/puppet/reference/metaparameter.rb +3 -1
  139. data/lib/puppet/reference/providers.rb +3 -1
  140. data/lib/puppet/reference/type.rb +9 -3
  141. data/lib/puppet/reports.rb +1 -1
  142. data/lib/puppet/resource.rb +1 -18
  143. data/lib/puppet/resource/catalog.rb +1 -1
  144. data/lib/puppet/rest/routes.rb +30 -17
  145. data/lib/puppet/settings.rb +3 -43
  146. data/lib/puppet/settings/environment_conf.rb +0 -1
  147. data/lib/puppet/ssl/certificate_request.rb +12 -2
  148. data/lib/puppet/ssl/host.rb +2 -2
  149. data/lib/puppet/ssl/oids.rb +1 -1
  150. data/lib/puppet/ssl/ssl_provider.rb +11 -5
  151. data/lib/puppet/ssl/state_machine.rb +102 -98
  152. data/lib/puppet/test/test_helper.rb +1 -0
  153. data/lib/puppet/transaction.rb +11 -33
  154. data/lib/puppet/transaction/report.rb +1 -1
  155. data/lib/puppet/type.rb +4 -2
  156. data/lib/puppet/type/exec.rb +17 -23
  157. data/lib/puppet/type/file.rb +39 -11
  158. data/lib/puppet/type/file/data_sync.rb +1 -5
  159. data/lib/puppet/type/group.rb +2 -4
  160. data/lib/puppet/type/notify.rb +3 -4
  161. data/lib/puppet/type/package.rb +3 -20
  162. data/lib/puppet/type/schedule.rb +1 -1
  163. data/lib/puppet/type/service.rb +3 -8
  164. data/lib/puppet/type/user.rb +2 -4
  165. data/lib/puppet/util.rb +29 -39
  166. data/lib/puppet/util/command_line/trollop.rb +1 -1
  167. data/lib/puppet/util/execution.rb +3 -4
  168. data/lib/puppet/util/http_proxy.rb +19 -27
  169. data/lib/puppet/util/log.rb +2 -2
  170. data/lib/puppet/util/log/destinations.rb +2 -2
  171. data/lib/puppet/util/logging.rb +20 -32
  172. data/lib/puppet/util/metric.rb +2 -2
  173. data/lib/puppet/util/monkey_patches.rb +33 -0
  174. data/lib/puppet/util/pidlock.rb +2 -3
  175. data/lib/puppet/util/provider_features.rb +4 -2
  176. data/lib/puppet/util/rdoc.rb +1 -1
  177. data/lib/puppet/util/reference.rb +1 -1
  178. data/lib/puppet/util/resource_template.rb +1 -1
  179. data/lib/puppet/util/selinux.rb +2 -8
  180. data/lib/puppet/util/skip_tags.rb +4 -0
  181. data/lib/puppet/util/windows/adsi.rb +18 -48
  182. data/lib/puppet/util/windows/process.rb +8 -8
  183. data/lib/puppet/util/windows/registry.rb +5 -7
  184. data/lib/puppet/util/windows/security.rb +0 -2
  185. data/lib/puppet/util/windows/service.rb +4 -149
  186. data/lib/puppet/util/windows/sid.rb +0 -1
  187. data/lib/puppet/vendor.rb +1 -1
  188. data/lib/puppet/version.rb +1 -1
  189. data/lib/puppet/x509/cert_provider.rb +81 -24
  190. data/locales/puppet.pot +462 -482
  191. data/man/man5/puppet.conf.5 +43 -44
  192. data/man/man8/puppet-agent.8 +1 -1
  193. data/man/man8/puppet-apply.8 +3 -3
  194. data/man/man8/puppet-catalog.8 +31 -3
  195. data/man/man8/puppet-config.8 +1 -1
  196. data/man/man8/puppet-describe.8 +1 -1
  197. data/man/man8/puppet-device.8 +1 -1
  198. data/man/man8/puppet-doc.8 +1 -1
  199. data/man/man8/puppet-epp.8 +1 -1
  200. data/man/man8/puppet-facts.8 +1 -1
  201. data/man/man8/puppet-filebucket.8 +1 -1
  202. data/man/man8/puppet-generate.8 +1 -1
  203. data/man/man8/puppet-help.8 +1 -1
  204. data/man/man8/puppet-key.8 +1 -1
  205. data/man/man8/puppet-lookup.8 +1 -1
  206. data/man/man8/puppet-man.8 +1 -1
  207. data/man/man8/puppet-module.8 +1 -1
  208. data/man/man8/puppet-node.8 +1 -1
  209. data/man/man8/puppet-parser.8 +1 -1
  210. data/man/man8/puppet-plugin.8 +1 -1
  211. data/man/man8/puppet-report.8 +1 -1
  212. data/man/man8/puppet-resource.8 +1 -1
  213. data/man/man8/puppet-script.8 +1 -1
  214. data/man/man8/puppet-ssl.8 +1 -1
  215. data/man/man8/puppet-status.8 +1 -1
  216. data/man/man8/puppet.8 +3 -3
  217. data/spec/fixtures/ssl/127.0.0.1-key.pem +56 -56
  218. data/spec/fixtures/ssl/127.0.0.1.pem +27 -27
  219. data/spec/fixtures/ssl/bad-basic-constraints.pem +32 -32
  220. data/spec/fixtures/ssl/bad-int-basic-constraints.pem +30 -30
  221. data/spec/fixtures/ssl/ca.pem +30 -30
  222. data/spec/fixtures/ssl/crl.pem +15 -15
  223. data/spec/fixtures/ssl/ec-key.pem +18 -0
  224. data/spec/fixtures/ssl/ec.pem +40 -0
  225. data/spec/fixtures/ssl/encrypted-ec-key.pem +21 -0
  226. data/spec/fixtures/ssl/encrypted-key.pem +57 -57
  227. data/spec/fixtures/ssl/intermediate-agent-crl.pem +16 -16
  228. data/spec/fixtures/ssl/intermediate-agent.pem +33 -33
  229. data/spec/fixtures/ssl/intermediate-crl.pem +17 -17
  230. data/spec/fixtures/ssl/intermediate.pem +31 -31
  231. data/spec/fixtures/ssl/pluto-key.pem +56 -56
  232. data/spec/fixtures/ssl/pluto.pem +28 -28
  233. data/spec/fixtures/ssl/request-key.pem +56 -56
  234. data/spec/fixtures/ssl/request.pem +24 -24
  235. data/spec/fixtures/ssl/revoked-key.pem +56 -56
  236. data/spec/fixtures/ssl/revoked.pem +25 -25
  237. data/spec/fixtures/ssl/signed-key.pem +56 -56
  238. data/spec/fixtures/ssl/signed.pem +25 -25
  239. data/spec/fixtures/ssl/tampered-cert.pem +27 -27
  240. data/spec/fixtures/ssl/tampered-csr.pem +24 -24
  241. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/func_with_syntax_error.rb +9 -0
  242. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +24 -0
  243. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +24 -0
  244. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +24 -0
  245. data/spec/integration/configurer_spec.rb +0 -52
  246. data/spec/integration/provider/service/init_spec.rb +1 -0
  247. data/spec/integration/provider/service/systemd_spec.rb +5 -8
  248. data/spec/integration/type/file_spec.rb +38 -28
  249. data/spec/integration/util/execution_spec.rb +0 -27
  250. data/spec/lib/puppet/certificate_factory.rb +2 -2
  251. data/spec/lib/puppet/test_ca.rb +17 -4
  252. data/spec/lib/puppet_spec/fixtures.rb +4 -0
  253. data/spec/spec_helper.rb +0 -28
  254. data/spec/unit/application/agent_spec.rb +34 -67
  255. data/spec/unit/application/device_spec.rb +1 -27
  256. data/spec/unit/application/ssl_spec.rb +60 -35
  257. data/spec/unit/configurer_spec.rb +399 -395
  258. data/spec/unit/defaults_spec.rb +4 -4
  259. data/spec/unit/face/facts_spec.rb +0 -9
  260. data/spec/unit/face/parser_spec.rb +69 -22
  261. data/spec/unit/face/plugin_spec.rb +0 -8
  262. data/spec/unit/file_system_spec.rb +30 -1
  263. data/spec/unit/forge/forge_spec.rb +3 -1
  264. data/spec/unit/forge/repository_spec.rb +3 -1
  265. data/spec/unit/indirector/catalog/compiler_spec.rb +5 -62
  266. data/spec/unit/indirector/resource/ral_spec.rb +4 -4
  267. data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
  268. data/spec/unit/network/http/api/indirected_routes_spec.rb +10 -25
  269. data/spec/unit/network/http/connection_spec.rb +145 -119
  270. data/spec/unit/network/http/factory_spec.rb +5 -27
  271. data/spec/unit/parser/scope_spec.rb +0 -10
  272. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +3 -8
  273. data/spec/unit/pops/loaders/loaders_spec.rb +4 -0
  274. data/spec/unit/pops/loaders/module_loaders_spec.rb +0 -37
  275. data/spec/unit/pops/types/types_spec.rb +27 -0
  276. data/spec/unit/provider/exec_spec.rb +0 -209
  277. data/spec/unit/provider/package/aptrpm_spec.rb +1 -1
  278. data/spec/unit/provider/package/dnf_spec.rb +0 -7
  279. data/spec/unit/provider/package/dpkg_spec.rb +80 -240
  280. data/spec/unit/provider/package/pip_spec.rb +8 -61
  281. data/spec/unit/provider/package/portage_spec.rb +4 -4
  282. data/spec/unit/provider/package/rpm_spec.rb +16 -150
  283. data/spec/unit/provider/package/yum_spec.rb +0 -7
  284. data/spec/unit/provider/service/daemontools_spec.rb +0 -24
  285. data/spec/unit/provider/service/launchd_spec.rb +0 -28
  286. data/spec/unit/provider/service/runit_spec.rb +0 -24
  287. data/spec/unit/provider/service/systemd_spec.rb +25 -39
  288. data/spec/unit/provider/service/windows_spec.rb +0 -20
  289. data/spec/unit/provider/user/hpux_spec.rb +2 -2
  290. data/spec/unit/provider/user/pw_spec.rb +0 -37
  291. data/spec/unit/provider/user/useradd_spec.rb +0 -88
  292. data/spec/unit/resource_spec.rb +1 -26
  293. data/spec/unit/ssl/host_spec.rb +5 -0
  294. data/spec/unit/ssl/ssl_provider_spec.rb +36 -11
  295. data/spec/unit/ssl/state_machine_spec.rb +233 -158
  296. data/spec/unit/transaction_spec.rb +0 -64
  297. data/spec/unit/type/exec_spec.rb +12 -15
  298. data/spec/unit/type/file/content_spec.rb +3 -9
  299. data/spec/unit/type/file/source_spec.rb +4 -4
  300. data/spec/unit/type/file_spec.rb +15 -11
  301. data/spec/unit/type/package_spec.rb +0 -5
  302. data/spec/unit/type/schedule_spec.rb +1 -3
  303. data/spec/unit/type/service_spec.rb +0 -16
  304. data/spec/unit/util/execution_spec.rb +0 -16
  305. data/spec/unit/util/http_proxy_spec.rb +21 -151
  306. data/spec/unit/util/ldap/manager_spec.rb +0 -15
  307. data/spec/unit/util/log/destinations_spec.rb +3 -7
  308. data/spec/unit/util/log_spec.rb +138 -0
  309. data/spec/unit/util/logging_spec.rb +0 -200
  310. data/spec/unit/util/pidlock_spec.rb +0 -26
  311. data/spec/unit/util/skip_tags_spec.rb +14 -0
  312. data/spec/unit/util/windows/adsi_spec.rb +0 -51
  313. data/spec/unit/util/windows/service_spec.rb +0 -9
  314. data/spec/unit/util_spec.rb +10 -0
  315. data/spec/unit/x509/cert_provider_spec.rb +82 -43
  316. data/tasks/generate_cert_fixtures.rake +13 -1
  317. data/tasks/manpages.rake +0 -1
  318. metadata +28 -22
  319. data/ext/cert_inspector +0 -140
  320. data/ext/envpuppet +0 -139
  321. data/ext/envpuppet.bat +0 -14
  322. data/ext/puppet-test +0 -476
  323. data/ext/pure_ruby_dsl/dsl_test.rb +0 -7
  324. data/ext/upload_facts.rb +0 -119
  325. data/lib/puppet/provider/package/dnfmodule.rb +0 -87
  326. data/spec/fixtures/unit/provider/package/dnfmodule/dnf-module-list-installed.txt +0 -11
  327. data/spec/integration/type/notify_spec.rb +0 -46
  328. data/spec/unit/provider/package/dnfmodule_spec.rb +0 -186
  329. data/spec/unit/provider/package_targetable_spec.rb +0 -60
@@ -163,28 +163,4 @@ 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
190
166
  end
@@ -127,8 +127,6 @@ 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
-
132
130
  it "should call any explicit 'start' command" do
133
131
  resource[:start] = "/bin/false"
134
132
  expect(subject).to receive(:texecute).with(:start, ["/bin/false"], true)
@@ -136,7 +134,6 @@ describe 'Puppet::Type::Service::Provider::Launchd', unless: Puppet::Util::Platf
136
134
  end
137
135
 
138
136
  it "should look for the relevant plist once" do
139
- allow(provider).to receive(:launchctl).with(:list).and_return(services)
140
137
  expect(subject).to receive(:plist_from_label).and_return([joblabel, {}]).once
141
138
  expect(subject).to receive(:enabled?).and_return(:true)
142
139
  expect(subject).to receive(:execute).with([:launchctl, :load, "-w", joblabel])
@@ -144,7 +141,6 @@ describe 'Puppet::Type::Service::Provider::Launchd', unless: Puppet::Util::Platf
144
141
  end
145
142
 
146
143
  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)
148
144
  expect(subject).to receive(:plist_from_label).and_return([joblabel, {}])
149
145
  expect(subject).to receive(:enabled?).and_return(:true)
150
146
  expect(subject).to receive(:execute).with([:launchctl, :load, "-w", joblabel]).once
@@ -248,30 +244,6 @@ describe 'Puppet::Type::Service::Provider::Launchd', unless: Puppet::Util::Platf
248
244
  end
249
245
  end
250
246
 
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
-
275
247
  [[10, "10.6"], [13, "10.9"]].each do |kernel, version|
276
248
  describe "when enabling the service on OS X #{version}" do
277
249
  it "should write to the global launchd overrides file once" do
@@ -136,28 +136,4 @@ 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
163
139
  end
@@ -120,20 +120,6 @@ 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
-
137
123
  it "should not be the default provider on ubuntu14.04" do
138
124
  allow(Facter).to receive(:value).with(:osfamily).and_return(:debian)
139
125
  allow(Facter).to receive(:value).with(:operatingsystem).and_return(:ubuntu)
@@ -201,17 +187,17 @@ describe 'Puppet::Type::Service::Provider::Systemd', unless: Puppet::Util::Platf
201
187
 
202
188
  it "should start the service with systemctl start otherwise" do
203
189
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
204
- expect(provider).to receive(:systemctl).with(:unmask, '--', 'sshd.service')
190
+ expect(provider).to receive(:systemctl).with(:unmask, 'sshd.service')
205
191
  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})
192
+ expect(provider).to receive(:execute).with(['/bin/systemctl','start','sshd.service'], {:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
207
193
  provider.start
208
194
  end
209
195
 
210
196
  it "should show journald logs on failure" do
211
197
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
212
- expect(provider).to receive(:systemctl).with(:unmask, '--', 'sshd.service')
198
+ expect(provider).to receive(:systemctl).with(:unmask, 'sshd.service')
213
199
  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})
200
+ expect(provider).to receive(:execute).with(['/bin/systemctl','start','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
215
201
  .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
202
  journalctl_logs = <<-EOS
217
203
  -- Logs begin at Tue 2016-06-14 11:59:21 UTC, end at Tue 2016-06-14 21:45:02 UTC. --
@@ -233,13 +219,13 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
233
219
 
234
220
  it "should stop the service with systemctl stop otherwise" do
235
221
  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)
222
+ expect(provider).to receive(:execute).with(['/bin/systemctl','stop','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
237
223
  provider.stop
238
224
  end
239
225
 
240
226
  it "should show journald logs on failure" do
241
227
  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})
228
+ expect(provider).to receive(:execute).with(['/bin/systemctl','stop','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
243
229
  .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
230
  journalctl_logs = <<-EOS
245
231
  -- Logs begin at Tue 2016-06-14 11:59:21 UTC, end at Tue 2016-06-14 21:45:02 UTC. --
@@ -255,13 +241,13 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
255
241
  describe "#daemon_reload?" do
256
242
  it "should skip the systemctl daemon_reload if not required by the service" do
257
243
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
258
- expect(provider).to receive(:execute).with(['/bin/systemctl', 'show', '--property=NeedDaemonReload', '--', 'sshd.service'], :failonfail => false).and_return("no")
244
+ expect(provider).to receive(:execute).with(['/bin/systemctl','show','sshd.service','--property=NeedDaemonReload'], :failonfail => false).and_return("no")
259
245
  provider.daemon_reload?
260
246
  end
261
247
  it "should run a systemctl daemon_reload if the service has been modified" do
262
248
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
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)
249
+ expect(provider).to receive(:execute).with(['/bin/systemctl','show','sshd.service','--property=NeedDaemonReload'], :failonfail => false).and_return("yes")
250
+ expect(provider).to receive(:execute).with(['/bin/systemctl','daemon-reload'], :failonfail => false)
265
251
  provider.daemon_reload?
266
252
  end
267
253
  end
@@ -269,42 +255,42 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
269
255
  describe "#enabled?" do
270
256
  it "should return :true if the service is enabled" do
271
257
  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")
258
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("enabled\n")
273
259
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
274
260
  expect(provider.enabled?).to eq(:true)
275
261
  end
276
262
 
277
263
  it "should return :true if the service is static" do
278
264
  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")
265
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("static\n")
280
266
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
281
267
  expect(provider.enabled?).to eq(:true)
282
268
  end
283
269
 
284
270
  it "should return :false if the service is disabled" do
285
271
  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")
272
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("disabled\n")
287
273
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(1)
288
274
  expect(provider.enabled?).to eq(:false)
289
275
  end
290
276
 
291
277
  it "should return :false if the service is indirect" do
292
278
  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")
279
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("indirect\n")
294
280
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
295
281
  expect(provider.enabled?).to eq(:false)
296
282
  end
297
283
 
298
284
  it "should return :false if the service is masked and the resource is attempting to be disabled" do
299
285
  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")
286
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("masked\n")
301
287
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(1)
302
288
  expect(provider.enabled?).to eq(:false)
303
289
  end
304
290
 
305
291
  it "should return :mask if the service is masked and the resource is attempting to be masked" do
306
292
  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")
293
+ expect(provider).to receive(:execute).with(['/bin/systemctl','is-enabled','sshd.service'], :failonfail => false).and_return("masked\n")
308
294
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(1)
309
295
  expect(provider.enabled?).to eq(:mask)
310
296
  end
@@ -313,8 +299,8 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
313
299
  describe "#enable" do
314
300
  it "should run systemctl enable to enable a service" do
315
301
  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')
302
+ expect(provider).to receive(:systemctl).with(:unmask, 'sshd.service')
303
+ expect(provider).to receive(:systemctl).with(:enable, 'sshd.service')
318
304
  provider.enable
319
305
  end
320
306
  end
@@ -322,7 +308,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
322
308
  describe "#disable" do
323
309
  it "should run systemctl disable to disable a service" do
324
310
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
325
- expect(provider).to receive(:systemctl).with(:disable, '--', 'sshd.service')
311
+ expect(provider).to receive(:systemctl).with(:disable, 'sshd.service')
326
312
  provider.disable
327
313
  end
328
314
  end
@@ -333,8 +319,8 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
333
319
  # :disable is the only call in the provider that uses a symbol instead of
334
320
  # a string.
335
321
  # 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')
322
+ expect(provider).to receive(:systemctl).with(:disable, 'sshd.service')
323
+ expect(provider).to receive(:systemctl).with(:mask, 'sshd.service')
338
324
  provider.mask
339
325
  end
340
326
  end
@@ -344,7 +330,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
344
330
  describe "#status" do
345
331
  it "should return running if if the command returns 0" do
346
332
  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")
333
+ 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
334
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(0)
349
335
  expect(provider.status).to eq(:running)
350
336
  end
@@ -352,7 +338,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
352
338
  [-10,-1,3,10].each { |ec|
353
339
  it "should return stopped if the command returns something non-0" do
354
340
  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")
341
+ 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
342
  allow($CHILD_STATUS).to receive(:exitstatus).and_return(ec)
357
343
  expect(provider.status).to eq(:stopped)
358
344
  end
@@ -371,7 +357,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
371
357
  it "should use the supplied restart command if specified" do
372
358
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :restart => '/bin/foo'))
373
359
  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
360
+ expect(provider).to receive(:execute).with(['/bin/systemctl','restart','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true).never
375
361
  expect(provider).to receive(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
376
362
  provider.restart
377
363
  end
@@ -379,14 +365,14 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
379
365
  it "should restart the service with systemctl restart" do
380
366
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
381
367
  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)
368
+ expect(provider).to receive(:execute).with(['/bin/systemctl','restart','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
383
369
  provider.restart
384
370
  end
385
371
 
386
372
  it "should show journald logs on failure" do
387
373
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
388
374
  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})
375
+ expect(provider).to receive(:execute).with(['/bin/systemctl','restart','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
390
376
  .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
377
  journalctl_logs = <<-EOS
392
378
  -- Logs begin at Tue 2016-06-14 11:59:21 UTC, end at Tue 2016-06-14 21:45:02 UTC. --
@@ -150,11 +150,6 @@ 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
-
158
153
  it "should report a service with a startup type of disabled as false" do
159
154
  expect(service_util).to receive(:service_start_type).with(name).and_return(:SERVICE_DISABLED)
160
155
  expect(provider.enabled?).to eq(:false)
@@ -220,19 +215,4 @@ describe 'Puppet::Type::Service::Provider::Windows',
220
215
  }.to raise_error(Puppet::Error, /Cannot enable #{name}/)
221
216
  end
222
217
  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
238
218
  end
@@ -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', '-F', '-u', 1000, '-o', 'testuser', ';', '/usr/lbin/modprpw', '-v', '-l', 'testuser'], hash_including(custom_environment: {}))
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: {}))
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', '-F', '-u', 1000, '-o', 'testuser'], hash_including(custom_environment: {}))
68
+ expect(provider).to receive(:execute).with(['/usr/sam/lbin/usermod.sam', '-u', 1000, '-o', 'testuser', '-F'], hash_including(custom_environment: {}))
69
69
  provider.uid = 1000
70
70
  end
71
71
  end
@@ -1,5 +1,4 @@
1
1
  require 'spec_helper'
2
- require 'open3'
3
2
 
4
3
  RSpec::Matchers.define_negated_matcher :excluding, :include
5
4
 
@@ -82,23 +81,6 @@ describe Puppet::Type.type(:user).provider(:pw) do
82
81
  provider.create
83
82
  end
84
83
 
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
-
102
84
  it "should use -s with the correct argument when the shell property is set" do
103
85
  resource[:shell] = "/bin/sh"
104
86
  expect(provider).to receive(:execute).with(include("-s").and(include("/bin/sh")), kind_of(Hash))
@@ -227,24 +209,5 @@ describe Puppet::Type.type(:user).provider(:pw) do
227
209
  expect(provider).to receive(:execute).with(include("-u").and(include(54321)), hash_including(custom_environment: {}))
228
210
  provider.uid = 54321
229
211
  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
249
212
  end
250
213
  end
@@ -44,27 +44,6 @@ 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
-
68
47
  it "should add -g when no gid is specified and group already exists" do
69
48
  allow(Puppet::Util).to receive(:gid).and_return(true)
70
49
  resource[:ensure] = :present
@@ -186,27 +165,6 @@ describe Puppet::Type.type(:user).provider(:useradd) do
186
165
  end
187
166
  end
188
167
 
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
-
210
168
  describe '#modify' do
211
169
  describe "on systems with the libuser and forcelocal=false" do
212
170
  before do
@@ -317,52 +275,6 @@ describe Puppet::Type.type(:user).provider(:useradd) do
317
275
  end
318
276
  end
319
277
 
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
-
366
278
  describe "#check_allow_dup" do
367
279
  it "should return an array with a flag if dup is allowed" do
368
280
  resource[:allowdupe] = :true