puppet 6.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +20 -20
  4. data/Guardfile.example +76 -0
  5. data/LICENSE +189 -4
  6. data/README.md +3 -3
  7. data/Rakefile +5 -2
  8. data/ext/solaris/smf/svc-puppetd +8 -1
  9. data/ext/solaris/smf/svc-puppetmasterd +8 -1
  10. data/lib/puppet/application/apply.rb +100 -59
  11. data/lib/puppet/application/cert.rb +4 -114
  12. data/lib/puppet/application/device.rb +48 -32
  13. data/lib/puppet/application/script.rb +1 -1
  14. data/lib/puppet/application/ssl.rb +135 -51
  15. data/lib/puppet/application.rb +5 -0
  16. data/lib/puppet/configurer.rb +2 -3
  17. data/lib/puppet/defaults.rb +33 -49
  18. data/lib/puppet/etc.rb +20 -0
  19. data/lib/puppet/face/config.rb +3 -3
  20. data/lib/puppet/face/key.rb +1 -1
  21. data/lib/puppet/face/node/clean.rb +0 -1
  22. data/lib/puppet/feature/base.rb +1 -1
  23. data/lib/puppet/file_bucket/dipper.rb +1 -1
  24. data/lib/puppet/file_serving/fileset.rb +1 -1
  25. data/lib/puppet/functions/abs.rb +1 -1
  26. data/lib/puppet/functions/new.rb +1 -1
  27. data/lib/puppet/module/task.rb +29 -38
  28. data/lib/puppet/pal/catalog_compiler.rb +96 -0
  29. data/lib/puppet/pal/compiler.rb +221 -0
  30. data/lib/puppet/pal/function_signature.rb +52 -0
  31. data/lib/puppet/pal/json_catalog_encoder.rb +67 -0
  32. data/lib/puppet/pal/pal_api.rb +15 -0
  33. data/lib/puppet/pal/pal_impl.rb +523 -0
  34. data/lib/puppet/pal/plan_signature.rb +71 -0
  35. data/lib/puppet/pal/script_compiler.rb +71 -0
  36. data/lib/puppet/pal/task_signature.rb +58 -0
  37. data/lib/puppet/parser/catalog_compiler.rb +24 -0
  38. data/lib/puppet/parser/compiler.rb +3 -1
  39. data/lib/puppet/parser/functions/generate.rb +7 -6
  40. data/lib/puppet/plugins/configuration.rb +5 -1
  41. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +3 -1
  42. data/lib/puppet/pops/evaluator/deferred_resolver.rb +3 -0
  43. data/lib/puppet/pops/evaluator/evaluator_impl.rb +5 -1
  44. data/lib/puppet/pops/evaluator/external_syntax_support.rb +3 -3
  45. data/lib/puppet/pops/evaluator/runtime3_converter.rb +2 -2
  46. data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +19 -10
  47. data/lib/puppet/pops/loader/task_instantiator.rb +13 -70
  48. data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
  49. data/lib/puppet/pops/parser/lexer2.rb +1 -1
  50. data/lib/puppet/pops/pcore.rb +10 -33
  51. data/lib/puppet/pops/serialization/to_data_converter.rb +9 -1
  52. data/lib/puppet/pops/serialization.rb +1 -0
  53. data/lib/puppet/pops/types/p_timespan_type.rb +2 -2
  54. data/lib/puppet/pops/types/string_converter.rb +18 -4
  55. data/lib/puppet/pops/validation/checker4_0.rb +17 -2
  56. data/lib/puppet/provider/exec.rb +59 -57
  57. data/lib/puppet/provider/group/aix.rb +18 -2
  58. data/lib/puppet/provider/group/windows_adsi.rb +7 -3
  59. data/lib/puppet/provider/nameservice.rb +1 -25
  60. data/lib/puppet/provider/package/dnf.rb +2 -0
  61. data/lib/puppet/provider/package/pkgng.rb +37 -21
  62. data/lib/puppet/provider/package/portage.rb +2 -2
  63. data/lib/puppet/provider/package/windows/exe_package.rb +16 -10
  64. data/lib/puppet/provider/package/windows/msi_package.rb +8 -0
  65. data/lib/puppet/provider/package/windows/package.rb +9 -1
  66. data/lib/puppet/provider/package/windows.rb +2 -2
  67. data/lib/puppet/provider/package/yum.rb +1 -1
  68. data/lib/puppet/provider/parsedfile.rb +25 -4
  69. data/lib/puppet/provider/service/launchd.rb +19 -3
  70. data/lib/puppet/provider/service/smf.rb +54 -0
  71. data/lib/puppet/provider/service/systemd.rb +19 -0
  72. data/lib/puppet/provider/service/upstart.rb +1 -0
  73. data/lib/puppet/provider/service/windows.rb +22 -5
  74. data/lib/puppet/provider/user/aix.rb +48 -2
  75. data/lib/puppet/provider/user/useradd.rb +2 -10
  76. data/lib/puppet/provider/user/windows_adsi.rb +9 -1
  77. data/lib/puppet/resource/catalog.rb +1 -5
  78. data/lib/puppet/resource.rb +3 -1
  79. data/lib/puppet/ssl/host.rb +26 -16
  80. data/lib/puppet/syntax_checkers/epp.rb +34 -0
  81. data/lib/puppet/syntax_checkers/pp.rb +34 -0
  82. data/lib/puppet/transaction/event_manager.rb +13 -1
  83. data/lib/puppet/transaction/persistence.rb +1 -1
  84. data/lib/puppet/transaction/resource_harness.rb +3 -1
  85. data/lib/puppet/type/group.rb +29 -1
  86. data/lib/puppet/type/package.rb +5 -1
  87. data/lib/puppet/type/resources.rb +12 -2
  88. data/lib/puppet/type/schedule.rb +7 -0
  89. data/lib/puppet/type/service.rb +12 -0
  90. data/lib/puppet/type/user.rb +5 -2
  91. data/lib/puppet/type.rb +6 -0
  92. data/lib/puppet/util/command_line.rb +2 -3
  93. data/lib/puppet/util/execution.rb +15 -1
  94. data/lib/puppet/util/filetype.rb +56 -8
  95. data/lib/puppet/util/log/destinations.rb +3 -2
  96. data/lib/puppet/util/logging.rb +3 -2
  97. data/lib/puppet/util/posix.rb +15 -0
  98. data/lib/puppet/util/selinux.rb +1 -1
  99. data/lib/puppet/util/storage.rb +12 -0
  100. data/lib/puppet/util/windows/adsi.rb +79 -2
  101. data/lib/puppet/util/windows/api_types.rb +1 -1
  102. data/lib/puppet/util/windows/process.rb +23 -3
  103. data/lib/puppet/util/windows/registry.rb +29 -5
  104. data/lib/puppet/util/windows/security.rb +14 -0
  105. data/lib/puppet/util/windows/service.rb +294 -74
  106. data/lib/puppet/util/windows/user.rb +3 -5
  107. data/lib/puppet/util.rb +7 -3
  108. data/lib/puppet/version.rb +1 -1
  109. data/lib/puppet.rb +1 -0
  110. data/lib/puppet_pal.rb +5 -1099
  111. data/locales/ja/puppet.po +952 -986
  112. data/locales/puppet.pot +592 -347
  113. data/man/man5/puppet.conf.5 +26 -31
  114. data/man/man8/puppet-agent.8 +1 -1
  115. data/man/man8/puppet-apply.8 +1 -1
  116. data/man/man8/puppet-catalog.8 +1 -1
  117. data/man/man8/puppet-config.8 +4 -4
  118. data/man/man8/puppet-describe.8 +1 -1
  119. data/man/man8/puppet-device.8 +23 -19
  120. data/man/man8/puppet-doc.8 +1 -1
  121. data/man/man8/puppet-epp.8 +1 -1
  122. data/man/man8/puppet-facts.8 +1 -1
  123. data/man/man8/puppet-filebucket.8 +1 -1
  124. data/man/man8/puppet-generate.8 +1 -1
  125. data/man/man8/puppet-help.8 +1 -1
  126. data/man/man8/puppet-key.8 +2 -2
  127. data/man/man8/puppet-lookup.8 +1 -1
  128. data/man/man8/puppet-man.8 +1 -1
  129. data/man/man8/puppet-module.8 +1 -1
  130. data/man/man8/puppet-node.8 +1 -1
  131. data/man/man8/puppet-parser.8 +1 -1
  132. data/man/man8/puppet-plugin.8 +1 -1
  133. data/man/man8/puppet-report.8 +1 -1
  134. data/man/man8/puppet-resource.8 +1 -1
  135. data/man/man8/puppet-script.8 +1 -1
  136. data/man/man8/puppet-ssl.8 +26 -3
  137. data/man/man8/puppet-status.8 +1 -1
  138. data/man/man8/puppet.8 +2 -2
  139. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/bad_func_load.rb +11 -0
  140. data/spec/fixtures/unit/provider/package/pkgng/pkg.query +7 -1
  141. data/spec/fixtures/unit/provider/package/pkgng/pkg.query.zsh +1 -0
  142. data/spec/fixtures/unit/provider/service/smf/svcs_fmri.out +6 -0
  143. data/spec/fixtures/unit/provider/service/smf/svcs_multiple_fmris.out +13 -0
  144. data/spec/integration/application/apply_spec.rb +4 -1
  145. data/spec/integration/parser/collection_spec.rb +4 -8
  146. data/spec/integration/provider/service/windows_spec.rb +5 -5
  147. data/spec/integration/ssl/key_spec.rb +0 -4
  148. data/spec/integration/transaction_spec.rb +559 -0
  149. data/spec/integration/type/file_spec.rb +6 -6
  150. data/spec/integration/util/windows/registry_spec.rb +39 -0
  151. data/spec/integration/util/windows/security_spec.rb +10 -7
  152. data/spec/integration/util/windows/user_spec.rb +37 -17
  153. data/spec/lib/puppet/test_ca.rb +1 -1
  154. data/spec/spec_helper.rb +1 -1
  155. data/spec/unit/agent_spec.rb +2 -2
  156. data/spec/unit/application/apply_spec.rb +55 -2
  157. data/spec/unit/application/device_spec.rb +10 -7
  158. data/spec/unit/application/face_base_spec.rb +1 -1
  159. data/spec/unit/application/lookup_spec.rb +2 -1
  160. data/spec/unit/application/ssl_spec.rb +178 -109
  161. data/spec/unit/application_spec.rb +29 -11
  162. data/spec/unit/configurer/downloader_spec.rb +1 -1
  163. data/spec/unit/configurer_spec.rb +16 -5
  164. data/spec/unit/etc_spec.rb +25 -0
  165. data/spec/unit/face/node_spec.rb +1 -3
  166. data/spec/unit/face/parser_spec.rb +15 -0
  167. data/spec/unit/file_serving/fileset_spec.rb +11 -11
  168. data/spec/unit/functions/logging_spec.rb +10 -3
  169. data/spec/unit/indirector/catalog/json_spec.rb +9 -3
  170. data/spec/unit/indirector/yaml_spec.rb +1 -1
  171. data/spec/unit/network/http/connection_spec.rb +2 -2
  172. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +36 -0
  173. data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +22 -4
  174. data/spec/unit/pops/loaders/loader_spec.rb +9 -17
  175. data/spec/unit/pops/loaders/loaders_spec.rb +48 -0
  176. data/spec/unit/pops/loaders/module_loaders_spec.rb +7 -7
  177. data/spec/unit/pops/parser/parse_heredoc_spec.rb +16 -0
  178. data/spec/unit/pops/serialization/to_from_hr_spec.rb +9 -0
  179. data/spec/unit/pops/types/p_timespan_type_spec.rb +22 -0
  180. data/spec/unit/pops/types/p_timestamp_type_spec.rb +19 -0
  181. data/spec/unit/pops/types/string_converter_spec.rb +25 -1
  182. data/spec/unit/pops/types/task_spec.rb +42 -116
  183. data/spec/unit/pops/validator/validator_spec.rb +24 -10
  184. data/spec/unit/provider/exec/posix_spec.rb +24 -0
  185. data/spec/unit/provider/group/aix_spec.rb +20 -6
  186. data/spec/unit/provider/group/ldap_spec.rb +22 -25
  187. data/spec/unit/provider/group/pw_spec.rb +7 -10
  188. data/spec/unit/provider/group/windows_adsi_spec.rb +42 -33
  189. data/spec/unit/provider/nameservice/directoryservice_spec.rb +97 -103
  190. data/spec/unit/provider/package/aix_spec.rb +5 -8
  191. data/spec/unit/provider/package/apt_spec.rb +3 -6
  192. data/spec/unit/provider/package/dnf_spec.rb +38 -25
  193. data/spec/unit/provider/package/dpkg_spec.rb +18 -21
  194. data/spec/unit/provider/package/freebsd_spec.rb +4 -7
  195. data/spec/unit/provider/package/gem_spec.rb +41 -41
  196. data/spec/unit/provider/package/hpux_spec.rb +7 -10
  197. data/spec/unit/provider/package/macports_spec.rb +13 -15
  198. data/spec/unit/provider/package/nim_spec.rb +3 -10
  199. data/spec/unit/provider/package/openbsd_spec.rb +14 -17
  200. data/spec/unit/provider/package/pip3_spec.rb +3 -6
  201. data/spec/unit/provider/package/pip_spec.rb +45 -49
  202. data/spec/unit/provider/package/pkgin_spec.rb +13 -18
  203. data/spec/unit/provider/package/pkgng_spec.rb +32 -27
  204. data/spec/unit/provider/package/puppet_gem_spec.rb +6 -9
  205. data/spec/unit/provider/package/tdnf_spec.rb +9 -12
  206. data/spec/unit/provider/package/windows/exe_package_spec.rb +3 -3
  207. data/spec/unit/provider/package/windows_spec.rb +4 -4
  208. data/spec/unit/provider/package/yum_spec.rb +30 -16
  209. data/spec/unit/provider/package/zypper_spec.rb +17 -19
  210. data/spec/unit/provider/service/bsd_spec.rb +7 -9
  211. data/spec/unit/provider/service/daemontools_spec.rb +12 -16
  212. data/spec/unit/provider/service/debian_spec.rb +6 -10
  213. data/spec/unit/provider/service/freebsd_spec.rb +2 -2
  214. data/spec/unit/provider/service/launchd_spec.rb +19 -0
  215. data/spec/unit/provider/service/openbsd_spec.rb +13 -17
  216. data/spec/unit/provider/service/rcng_spec.rb +2 -4
  217. data/spec/unit/provider/service/redhat_spec.rb +12 -11
  218. data/spec/unit/provider/service/runit_spec.rb +7 -14
  219. data/spec/unit/provider/service/smf_spec.rb +77 -13
  220. data/spec/unit/provider/service/src_spec.rb +11 -16
  221. data/spec/unit/provider/service/systemd_spec.rb +39 -1
  222. data/spec/unit/provider/service/windows_spec.rb +39 -7
  223. data/spec/unit/provider/user/aix_spec.rb +43 -2
  224. data/spec/unit/provider/user/hpux_spec.rb +3 -5
  225. data/spec/unit/provider/user/ldap_spec.rb +29 -32
  226. data/spec/unit/provider/user/pw_spec.rb +10 -13
  227. data/spec/unit/provider/user/useradd_spec.rb +2 -2
  228. data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
  229. data/spec/unit/puppet_pal_2pec.rb +6 -6
  230. data/spec/unit/puppet_pal_catalog_spec.rb +58 -0
  231. data/spec/unit/resource/catalog_spec.rb +2 -2
  232. data/spec/unit/resource_spec.rb +31 -0
  233. data/spec/unit/ssl/host_spec.rb +22 -1
  234. data/spec/unit/ssl/key_spec.rb +2 -4
  235. data/spec/unit/task_spec.rb +50 -5
  236. data/spec/unit/transaction/event_manager_spec.rb +12 -1
  237. data/spec/unit/transaction/persistence_spec.rb +4 -4
  238. data/spec/unit/transaction/resource_harness_spec.rb +18 -0
  239. data/spec/unit/type/group_spec.rb +11 -3
  240. data/spec/unit/type/resources_spec.rb +18 -0
  241. data/spec/unit/type/service_spec.rb +27 -1
  242. data/spec/unit/util/execution_spec.rb +77 -0
  243. data/spec/unit/util/filetype_spec.rb +13 -5
  244. data/spec/unit/util/log/destinations_spec.rb +10 -0
  245. data/spec/unit/util/logging_spec.rb +58 -41
  246. data/spec/unit/util/monkey_patches_spec.rb +18 -5
  247. data/spec/unit/util/posix_spec.rb +28 -0
  248. data/spec/unit/util/selinux_spec.rb +4 -0
  249. data/spec/unit/util/storage_spec.rb +107 -0
  250. data/spec/unit/util/suidmanager_spec.rb +1 -3
  251. data/spec/unit/util/windows/adsi_spec.rb +95 -0
  252. data/spec/unit/util/windows/service_spec.rb +377 -131
  253. metadata +24 -11
  254. data/ext/autotest/Rakefile +0 -8
  255. data/ext/autotest/config +0 -43
  256. data/ext/autotest/readme.rst +0 -16
  257. data/spec/fixtures/unit/provider/package/pkgng/pkg.info +0 -7
  258. data/spec/fixtures/unit/provider/package/pkgng/pkg.query_absent +0 -1
  259. data/spec/watchr.rb +0 -137
@@ -143,13 +143,12 @@ describe 'The Task Type' do
143
143
  expect(task_t.instance?(task)).to be_truthy
144
144
  expect(task.name).to eq('testmodule::hello')
145
145
  expect(task._pcore_type).to eq(task_t)
146
- expect(task.supports_noop).to eql(true)
147
- expect(task.puppet_task_version).to eql(1)
148
- expect(task.implementations).to eql([{"name" => "hello.rb", "path" => "#{modules_dir}/testmodule/tasks/hello.rb", "requirements" => []}])
146
+ expect(task.metadata['supports_noop']).to eql(true)
147
+ expect(task.metadata['puppet_task_version']).to eql(1)
148
+ expect(task.files).to eql([{"name" => "hello.rb", "path" => "#{modules_dir}/testmodule/tasks/hello.rb"}])
149
149
 
150
- tp = task.parameters
151
- expect(tp['message']['description']).to eql('the message')
152
- expect(tp['message']['type']).to be_a(Puppet::Pops::Types::PStringType)
150
+ expect(task.metadata['parameters']['message']['description']).to eql('the message')
151
+ expect(task.parameters['message']).to be_a(Puppet::Pops::Types::PStringType)
153
152
  end
154
153
  end
155
154
 
@@ -157,8 +156,7 @@ describe 'The Task Type' do
157
156
  compile do
158
157
  task = module_loader.load(:task, 'testmodule::non_data')
159
158
  expect(task_t.instance?(task)).to be_truthy
160
- tp = task.parameters
161
- expect(tp['arg']['type']).to be_a(Puppet::Pops::Types::PHashType)
159
+ expect(task.parameters['arg']).to be_a(Puppet::Pops::Types::PHashType)
162
160
  end
163
161
  end
164
162
 
@@ -173,7 +171,9 @@ describe 'The Task Type' do
173
171
 
174
172
  it 'fails to load the task' do
175
173
  compile do
176
- expect { module_loader.load(:task, 'testmodule') }.to raise_error(ArgumentError, /No source besides task metadata was found/)
174
+ expect {
175
+ module_loader.load(:task, 'testmodule')
176
+ }.to raise_error(Puppet::Module::Task::InvalidTask, /No source besides task metadata was found/)
177
177
  end
178
178
  end
179
179
  end
@@ -192,7 +192,9 @@ describe 'The Task Type' do
192
192
 
193
193
  it "fails if metadata doesn't specify implementations" do
194
194
  compile do
195
- expect { module_loader.load(:task, 'testmodule') }.to raise_error(ArgumentError, /Multiple executables were found .*/)
195
+ expect {
196
+ module_loader.load(:task, 'testmodule')
197
+ }.to raise_error(Puppet::Module::Task::InvalidTask, /Multiple executables were found .*/)
196
198
  end
197
199
  end
198
200
 
@@ -204,9 +206,13 @@ describe 'The Task Type' do
204
206
  compile do
205
207
  task = module_loader.load(:task, 'testmodule')
206
208
  expect(task_t.instance?(task)).to be_truthy
207
- expect(task.implementations).to eql([
208
- {"name" => "init.sh", "path" => "#{modules_dir}/testmodule/tasks/init.sh", "requirements" => ['shell']},
209
- {"name" => "init.ps1", "path" => "#{modules_dir}/testmodule/tasks/init.ps1", "requirements" => ['powershell']}
209
+ expect(task.files).to eql([
210
+ {"name" => "init.sh", "path" => "#{modules_dir}/testmodule/tasks/init.sh"},
211
+ {"name" => "init.ps1", "path" => "#{modules_dir}/testmodule/tasks/init.ps1"}
212
+ ])
213
+ expect(task.metadata['implementations']).to eql([
214
+ {"name" => "init.sh", "requirements" => ['shell']},
215
+ {"name" => "init.ps1", "requirements" => ['powershell']}
210
216
  ])
211
217
  end
212
218
  end
@@ -218,21 +224,11 @@ describe 'The Task Type' do
218
224
  compile do
219
225
  task = module_loader.load(:task, 'testmodule')
220
226
  expect(task_t.instance?(task)).to be_truthy
221
- expect(task.implementations).to eql([
222
- {"name" => "init.ps1", "path" => "#{modules_dir}/testmodule/tasks/init.ps1", "requirements" => ['powershell']}
227
+ expect(task.files).to eql([
228
+ {"name" => "init.ps1", "path" => "#{modules_dir}/testmodule/tasks/init.ps1"}
223
229
  ])
224
- end
225
- end
226
-
227
- it "adds an empty requirements list if one is not specified" do
228
- impls = [{'name' => 'init.ps1'}]
229
- metadata.replace({'implementations' => impls}.to_json)
230
-
231
- compile do
232
- task = module_loader.load(:task, 'testmodule')
233
- expect(task_t.instance?(task)).to be_truthy
234
- expect(task.implementations).to eql([
235
- {"name" => "init.ps1", "path" => "#{modules_dir}/testmodule/tasks/init.ps1", "requirements" => []}
230
+ expect(task.metadata['implementations']).to eql([
231
+ {"name" => "init.ps1", "requirements" => ['powershell']}
236
232
  ])
237
233
  end
238
234
  end
@@ -244,7 +240,9 @@ describe 'The Task Type' do
244
240
  metadata.replace({'implementations' => impls}.to_json)
245
241
 
246
242
  compile do
247
- expect { module_loader.load(:task, 'testmodule') }.to raise_error(ArgumentError, /Task metadata for task testmodule specifies missing implementation init\.rb/)
243
+ expect {
244
+ module_loader.load(:task, 'testmodule')
245
+ }.to raise_error(Puppet::Module::Task::InvalidTask, /Task metadata for task testmodule specifies missing implementation init\.rb/)
248
246
  end
249
247
  end
250
248
 
@@ -252,7 +250,9 @@ describe 'The Task Type' do
252
250
  metadata.replace({'implementations' => {'init.rb' => []}}.to_json)
253
251
 
254
252
  compile do
255
- expect { module_loader.load(:task, 'testmodule') }.to raise_error(Puppet::ParseError, /Task initializer has wrong type/)
253
+ expect {
254
+ module_loader.load(:task, 'testmodule')
255
+ }.to raise_error(Puppet::Module::Task::InvalidMetadata, /Task metadata for task testmodule does not specify implementations as an array/)
256
256
  end
257
257
  end
258
258
  end
@@ -283,16 +283,18 @@ describe 'The Task Type' do
283
283
 
284
284
  compile do
285
285
  task = module_loader.load(:task, 'testmodule::bar')
286
- expect(task.implementations).to eql([
287
- {'name' => 'foo.sh', 'path' => "#{modules_dir}/testmodule/tasks/foo.sh", 'requirements' => ['shell']},
288
- {'name' => 'foo.ps1', 'path' => "#{modules_dir}/testmodule/tasks/foo.ps1", 'requirements' => ['powershell']},
286
+ expect(task.files).to eql([
287
+ {'name' => 'foo.sh', 'path' => "#{modules_dir}/testmodule/tasks/foo.sh"},
288
+ {'name' => 'foo.ps1', 'path' => "#{modules_dir}/testmodule/tasks/foo.ps1"},
289
289
  ])
290
290
  end
291
291
  end
292
292
 
293
293
  it 'fails to load the task if it has no implementations section and no associated executables' do
294
294
  compile do
295
- expect { module_loader.load(:task, 'testmodule::bar') }.to raise_error(ArgumentError, /No source besides task metadata was found/)
295
+ expect {
296
+ module_loader.load(:task, 'testmodule::bar')
297
+ }.to raise_error(Puppet::Module::Task::InvalidTask, /No source besides task metadata was found/)
296
298
  end
297
299
  end
298
300
 
@@ -327,9 +329,9 @@ describe 'The Task Type' do
327
329
  compile do
328
330
  task = module_loader.load(:task, 'testmodule')
329
331
  expect(task_t.instance?(task)).to be_truthy
330
- expect(task.implementations).to eql([{"name" => "init.sh", "path" => "#{modules_dir}/testmodule/tasks/init.sh", "requirements" => []}])
331
- expect(task.parameters).to be_a(Hash)
332
- expect(task.parameters['message']['type']).to be_a(Puppet::Pops::Types::PStringType)
332
+ expect(task.files).to eql([{"name" => "init.sh", "path" => "#{modules_dir}/testmodule/tasks/init.sh"}])
333
+ expect(task.metadata['parameters']).to be_a(Hash)
334
+ expect(task.parameters['message']).to be_a(Puppet::Pops::Types::PStringType)
333
335
  end
334
336
  end
335
337
  end
@@ -358,9 +360,9 @@ describe 'The Task Type' do
358
360
  compile do
359
361
  task = module_loader.load(:task, 'testmodule::hello')
360
362
  expect(task_t.instance?(task)).to be_truthy
361
- expect(task.implementations).to eql([{"name" => "hello.sh", "path" => "#{modules_dir}/testmodule/tasks/hello.sh", "requirements" => []}])
362
- expect(task.parameters).to be_a(Hash)
363
- expect(task.parameters['message']['type']).to be_a(Puppet::Pops::Types::PStringType)
363
+ expect(task.files).to eql([{"name" => "hello.sh", "path" => "#{modules_dir}/testmodule/tasks/hello.sh"}])
364
+ expect(task.metadata['parameters']).to be_a(Hash)
365
+ expect(task.parameters['message']).to be_a(Puppet::Pops::Types::PStringType)
364
366
  end
365
367
  end
366
368
  end
@@ -383,31 +385,6 @@ describe 'The Task Type' do
383
385
  end
384
386
  end
385
387
 
386
- context 'that has a malformed top-level entry' do
387
- let(:testmodule) {
388
- {
389
- 'tasks' => {
390
- 'hello' => 'echo hello',
391
- 'hello.json' => <<-JSON
392
- {
393
- "supports_nop": true,
394
- "parameters": {
395
- "message": { "type": "String" }
396
- }
397
- }
398
- JSON
399
- }
400
- }
401
- }
402
-
403
- it 'fails with unrecognized key error' do
404
- compile do
405
- expect{module_loader.load(:task, 'testmodule::hello')}.to raise_error(
406
- /Failed to load metadata for task testmodule::hello:.*unrecognized key 'supports_nop'/)
407
- end
408
- end
409
- end
410
-
411
388
  context 'that has no parameters' do
412
389
  let(:testmodule) {
413
390
  {
@@ -421,58 +398,7 @@ describe 'The Task Type' do
421
398
  compile do
422
399
  task = module_loader.load(:task, 'testmodule::hello')
423
400
  expect(task_t.instance?(task)).to be_truthy
424
- expect(task.parameters).to be_nil
425
- end
426
- end
427
- end
428
-
429
- context 'that has a malformed parameter name' do
430
- let(:testmodule) {
431
- {
432
- 'tasks' => {
433
- 'hello' => 'echo hello',
434
- 'hello.json' => <<-JSON
435
- {
436
- "supports_noop": true,
437
- "parameters": {
438
- "Message": { "type": "String" }
439
- }
440
- }
441
- JSON
442
- }
443
- }
444
- }
445
-
446
- it 'fails with pattern mismatch error' do
447
- compile do
448
- expect{module_loader.load(:task, 'testmodule::hello')}.to raise_error(
449
- /entry 'parameters' key of entry 'Message' expects a match for Pattern\[\/\\A\[a-z\]\[a-z0-9_\]\*\\z\/\], got 'Message'/)
450
- end
451
- end
452
- end
453
-
454
- context 'that has a puppet_task_version that is a string' do
455
- let(:testmodule) {
456
- {
457
- 'tasks' => {
458
- 'hello' => 'echo hello',
459
- 'hello.json' => <<-JSON
460
- {
461
- "puppet_task_version": "1",
462
- "supports_noop": true,
463
- "parameters": {
464
- "message": { "type": "String" }
465
- }
466
- }
467
- JSON
468
- }
469
- }
470
- }
471
-
472
- it 'fails with type mismatch error' do
473
- compile do
474
- expect{module_loader.load(:task, 'testmodule::hello')}.to raise_error(
475
- /entry 'puppet_task_version' expects an Integer value, got String/)
401
+ expect(task.metadata['parameters']).to be_nil
476
402
  end
477
403
  end
478
404
  end
@@ -23,7 +23,11 @@ describe "validating 4x" do
23
23
 
24
24
  def with_environment(environment, env_params = {})
25
25
  override_env = environment
26
- override_env = environment.override_with(env_params) if env_params.count > 0
26
+ override_env = environment.override_with({
27
+ modulepath: env_params[:modulepath] || environment.full_modulepath,
28
+ manifest: env_params[:manifest] || environment.manifest,
29
+ config_version: env_params[:config_version] || environment.config_version
30
+ }) if env_params.count > 0
27
31
  Puppet.override(current_environment: override_env) do
28
32
  yield
29
33
  end
@@ -72,15 +76,6 @@ describe "validating 4x" do
72
76
  end
73
77
  end
74
78
 
75
- it 'should not raise error for legal definition locations' do
76
- with_environment(environment, :manifest => 'a/manifest/file.pp') do
77
- expect(validate(parse('function aaa::bbb() {}', 'path/aaa/manifests/bbb.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
78
- expect(validate(parse('class aaa() {}', 'path/aaa/manifests/init.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
79
- expect(validate(parse('function aaa::bbB::ccc() {}', 'path/aaa/manifests/bBb.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
80
- expect(validate(parse('function aaa::bbb::ccc() {}', 'path/aaa/manifests/bbb/CCC.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
81
- end
82
- end
83
-
84
79
  it 'should not raise error for definitions inside initial --manifest file' do
85
80
  with_environment(environment, :manifest => 'a/manifest/file.pp') do
86
81
  expect(validate(parse('class aaa() {}', 'a/manifest/file.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
@@ -100,6 +95,13 @@ describe "validating 4x" do
100
95
  end
101
96
  end
102
97
 
98
+ it 'should not raise error for empty files in modulepath' do
99
+ with_environment(environment) do
100
+ expect(validate(parse('', 'path/aaa/manifests/init.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_TOP_CONSTRUCT_LOCATION)
101
+ expect(validate(parse('#this is a comment', 'path/aaa/manifests/init.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_TOP_CONSTRUCT_LOCATION)
102
+ end
103
+ end
104
+
103
105
  it 'should raise error if the file is in the modulepath but is not well formed' do
104
106
  with_environment(environment) do
105
107
  expect(validate(parse('class aaa::bbb::ccc() {}', 'path/manifest/aaa/bbb.pp'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
@@ -113,6 +115,18 @@ describe "validating 4x" do
113
115
  end
114
116
  end
115
117
 
118
+ it 'should not raise error when one modulepath is a substring of another' do
119
+ with_environment(environment, modulepath: ['path', 'pathplus']) do
120
+ expect(validate(parse('class aaa::ccc() {}', 'pathplus/aaa/manifests/ccc.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
121
+ end
122
+ end
123
+
124
+ it 'should not raise error when a modulepath ends with a file separator' do
125
+ with_environment(environment, modulepath: ['path/']) do
126
+ expect(validate(parse('class aaa::ccc() {}', 'pathplus/aaa/manifests/ccc.pp'))).not_to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_LOCATION)
127
+ end
128
+ end
129
+
116
130
  it 'should raise error for illegal type names' do
117
131
  expect(validate(parse('type ::Aaa = Any'))).to have_issue(Puppet::Pops::Issues::ILLEGAL_DEFINITION_NAME)
118
132
  end
@@ -117,6 +117,30 @@ describe Puppet::Type.type(:exec).provider(:posix), :if => Puppet.features.posix
117
117
  expect(@logs.map {|l| "#{l.level}: #{l.message}" }).to eq(["warning: Overriding environment setting 'WHATEVER' with '/foo'"])
118
118
  end
119
119
 
120
+ it "should warn when setting an empty environment variable" do
121
+ provider.resource[:environment] = ['WHATEVER=']
122
+ command = make_exe
123
+
124
+ Puppet::Util::Execution.expects(:execute).with(command, instance_of(Hash)).returns(Puppet::Util::Execution::ProcessOutput.new('', 0))
125
+
126
+ provider.run(command)
127
+
128
+ expect(@logs.map(&:to_s).join).to match(/Empty environment setting 'WHATEVER'\n\s+\(file & line not available\)/m)
129
+ end
130
+
131
+ it "should warn when setting an empty environment variable (within a manifest)" do
132
+ provider.resource[:environment] = ['WHATEVER=']
133
+ provider.resource.file = '/tmp/foobar'
134
+ provider.resource.line = 42
135
+ command = make_exe
136
+
137
+ Puppet::Util::Execution.expects(:execute).with(command, instance_of(Hash)).returns(Puppet::Util::Execution::ProcessOutput.new('', 0))
138
+
139
+ provider.run(command)
140
+
141
+ expect(@logs.map(&:to_s).join).to match(/Empty environment setting 'WHATEVER'\n\s+\(file: \/tmp\/foobar, line: 42\)/m)
142
+ end
143
+
120
144
  it "should set umask before execution if umask parameter is in use" do
121
145
  provider.resource[:umask] = '0027'
122
146
  Puppet::Util.expects(:withumask).with(0027)
@@ -63,14 +63,28 @@ describe 'Puppet::Type::Group::Provider::Aix' do
63
63
  end
64
64
 
65
65
  describe '.members_to_users' do
66
- it 'returns the members property as-is if it is not an Array' do
67
- expect(provider_class.members_to_users('members'))
68
- .to eql('members')
66
+ context 'when auth_membership == true' do
67
+ before(:each) do
68
+ resource[:auth_membership] = true
69
+ end
70
+
71
+ it 'returns only the passed-in members' do
72
+ expect(provider_class.members_to_users(provider, ['user1', 'user2']))
73
+ .to eql('user1,user2')
74
+ end
69
75
  end
70
76
 
71
- it 'returns the members property as a comma-separated string if it is an Array' do
72
- expect(provider_class.members_to_users(['user1', 'user2']))
73
- .to eql('user1,user2')
77
+ context 'when auth_membership == false' do
78
+ before(:each) do
79
+ resource[:auth_membership] = false
80
+
81
+ provider.stubs(:members).returns(['user3', 'user1'])
82
+ end
83
+
84
+ it 'adds the passed-in members to the current list of members, filtering out any duplicates' do
85
+ expect(provider_class.members_to_users(provider, ['user1', 'user2']))
86
+ .to eql('user1,user2,user3')
87
+ end
74
88
  end
75
89
  end
76
90
  end
@@ -1,54 +1,51 @@
1
- #! /usr/bin/env ruby
2
1
  require 'spec_helper'
3
2
 
4
- provider_class = Puppet::Type.type(:group).provider(:ldap)
5
-
6
- describe provider_class do
3
+ describe Puppet::Type.type(:group).provider(:ldap) do
7
4
  it "should have the Ldap provider class as its baseclass" do
8
- expect(provider_class.superclass).to equal(Puppet::Provider::Ldap)
5
+ expect(described_class.superclass).to equal(Puppet::Provider::Ldap)
9
6
  end
10
7
 
11
8
  it "should manage :posixGroup objectclass" do
12
- expect(provider_class.manager.objectclasses).to eq([:posixGroup])
9
+ expect(described_class.manager.objectclasses).to eq([:posixGroup])
13
10
  end
14
11
 
15
12
  it "should use 'ou=Groups' as its relative base" do
16
- expect(provider_class.manager.location).to eq("ou=Groups")
13
+ expect(described_class.manager.location).to eq("ou=Groups")
17
14
  end
18
15
 
19
16
  it "should use :cn as its rdn" do
20
- expect(provider_class.manager.rdn).to eq(:cn)
17
+ expect(described_class.manager.rdn).to eq(:cn)
21
18
  end
22
19
 
23
20
  it "should map :name to 'cn'" do
24
- expect(provider_class.manager.ldap_name(:name)).to eq('cn')
21
+ expect(described_class.manager.ldap_name(:name)).to eq('cn')
25
22
  end
26
23
 
27
24
  it "should map :gid to 'gidNumber'" do
28
- expect(provider_class.manager.ldap_name(:gid)).to eq('gidNumber')
25
+ expect(described_class.manager.ldap_name(:gid)).to eq('gidNumber')
29
26
  end
30
27
 
31
28
  it "should map :members to 'memberUid', to be used by the user ldap provider" do
32
- expect(provider_class.manager.ldap_name(:members)).to eq('memberUid')
29
+ expect(described_class.manager.ldap_name(:members)).to eq('memberUid')
33
30
  end
34
31
 
35
32
  describe "when being created" do
36
33
  before do
37
34
  # So we don't try to actually talk to ldap
38
35
  @connection = mock 'connection'
39
- provider_class.manager.stubs(:connect).yields @connection
36
+ described_class.manager.stubs(:connect).yields @connection
40
37
  end
41
38
 
42
39
  describe "with no gid specified" do
43
40
  it "should pick the first available GID after the largest existing GID" do
44
41
  low = {:name=>["luke"], :gid=>["600"]}
45
42
  high = {:name=>["testing"], :gid=>["640"]}
46
- provider_class.manager.expects(:search).returns([low, high])
43
+ described_class.manager.expects(:search).returns([low, high])
47
44
 
48
45
  resource = stub 'resource', :should => %w{whatever}
49
46
  resource.stubs(:should).with(:gid).returns nil
50
47
  resource.stubs(:should).with(:ensure).returns :present
51
- instance = provider_class.new(:name => "luke", :ensure => :absent)
48
+ instance = described_class.new(:name => "luke", :ensure => :absent)
52
49
  instance.stubs(:resource).returns resource
53
50
 
54
51
  @connection.expects(:add).with { |dn, attrs| attrs["gidNumber"] == ["641"] }
@@ -58,12 +55,12 @@ describe provider_class do
58
55
  end
59
56
 
60
57
  it "should pick '501' as its GID if no groups are found" do
61
- provider_class.manager.expects(:search).returns nil
58
+ described_class.manager.expects(:search).returns nil
62
59
 
63
60
  resource = stub 'resource', :should => %w{whatever}
64
61
  resource.stubs(:should).with(:gid).returns nil
65
62
  resource.stubs(:should).with(:ensure).returns :present
66
- instance = provider_class.new(:name => "luke", :ensure => :absent)
63
+ instance = described_class.new(:name => "luke", :ensure => :absent)
67
64
  instance.stubs(:resource).returns resource
68
65
 
69
66
  @connection.expects(:add).with { |dn, attrs| attrs["gidNumber"] == ["501"] }
@@ -75,27 +72,27 @@ describe provider_class do
75
72
  end
76
73
 
77
74
  it "should have a method for converting group names to GIDs" do
78
- expect(provider_class).to respond_to(:name2id)
75
+ expect(described_class).to respond_to(:name2id)
79
76
  end
80
77
 
81
78
  describe "when converting from a group name to GID" do
82
79
  it "should use the ldap manager to look up the GID" do
83
- provider_class.manager.expects(:search).with("cn=foo")
84
- provider_class.name2id("foo")
80
+ described_class.manager.expects(:search).with("cn=foo")
81
+ described_class.name2id("foo")
85
82
  end
86
83
 
87
84
  it "should return nil if no group is found" do
88
- provider_class.manager.expects(:search).with("cn=foo").returns nil
89
- expect(provider_class.name2id("foo")).to be_nil
90
- provider_class.manager.expects(:search).with("cn=bar").returns []
91
- expect(provider_class.name2id("bar")).to be_nil
85
+ described_class.manager.expects(:search).with("cn=foo").returns nil
86
+ expect(described_class.name2id("foo")).to be_nil
87
+ described_class.manager.expects(:search).with("cn=bar").returns []
88
+ expect(described_class.name2id("bar")).to be_nil
92
89
  end
93
90
 
94
91
  # We shouldn't ever actually have more than one gid, but it doesn't hurt
95
92
  # to test for the possibility.
96
93
  it "should return the first gid from the first returned group" do
97
- provider_class.manager.expects(:search).with("cn=foo").returns [{:name => "foo", :gid => [10, 11]}, {:name => :bar, :gid => [20, 21]}]
98
- expect(provider_class.name2id("foo")).to eq(10)
94
+ described_class.manager.expects(:search).with("cn=foo").returns [{:name => "foo", :gid => [10, 11]}, {:name => :bar, :gid => [20, 21]}]
95
+ expect(described_class.name2id("foo")).to eq(10)
99
96
  end
100
97
  end
101
98
  end
@@ -1,9 +1,6 @@
1
- #! /usr/bin/env ruby
2
1
  require 'spec_helper'
3
2
 
4
- provider_class = Puppet::Type.type(:group).provider(:pw)
5
-
6
- describe provider_class do
3
+ describe Puppet::Type.type(:group).provider(:pw) do
7
4
  let :resource do
8
5
  Puppet::Type.type(:group).new(:name => "testgroup", :provider => :pw)
9
6
  end
@@ -20,8 +17,8 @@ describe provider_class do
20
17
  end
21
18
 
22
19
  it "should run pw with no additional flags when no properties are given" do
23
- expect(provider.addcmd).to eq([provider_class.command(:pw), "groupadd", "testgroup"])
24
- provider.expects(:execute).with([provider_class.command(:pw), "groupadd", "testgroup"], kind_of(Hash))
20
+ expect(provider.addcmd).to eq([described_class.command(:pw), "groupadd", "testgroup"])
21
+ provider.expects(:execute).with([described_class.command(:pw), "groupadd", "testgroup"], kind_of(Hash))
25
22
  provider.create
26
23
  end
27
24
 
@@ -53,16 +50,16 @@ describe provider_class do
53
50
  describe "when deleting groups" do
54
51
  it "should run pw with no additional flags" do
55
52
  provider.expects(:exists?).returns true
56
- expect(provider.deletecmd).to eq([provider_class.command(:pw), "groupdel", "testgroup"])
57
- provider.expects(:execute).with([provider_class.command(:pw), "groupdel", "testgroup"], has_entry(:custom_environment, {}))
53
+ expect(provider.deletecmd).to eq([described_class.command(:pw), "groupdel", "testgroup"])
54
+ provider.expects(:execute).with([described_class.command(:pw), "groupdel", "testgroup"], has_entry(:custom_environment, {}))
58
55
  provider.delete
59
56
  end
60
57
  end
61
58
 
62
59
  describe "when modifying groups" do
63
60
  it "should run pw with the correct arguments" do
64
- expect(provider.modifycmd("gid", 12345)).to eq([provider_class.command(:pw), "groupmod", "testgroup", "-g", 12345])
65
- provider.expects(:execute).with([provider_class.command(:pw), "groupmod", "testgroup", "-g", 12345], has_entry(:custom_environment, {}))
61
+ expect(provider.modifycmd("gid", 12345)).to eq([described_class.command(:pw), "groupmod", "testgroup", "-g", 12345])
62
+ provider.expects(:execute).with([described_class.command(:pw), "groupmod", "testgroup", "-g", 12345], has_entry(:custom_environment, {}))
66
63
  provider.gid = 12345
67
64
  end
68
65