puppet 4.0.0 → 4.1.0

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

Potentially problematic release.


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

Files changed (219) hide show
  1. checksums.yaml +4 -4
  2. data/ext/build_defaults.yaml +8 -35
  3. data/ext/debian/puppet.default +0 -5
  4. data/ext/debian/puppet.init +1 -15
  5. data/lib/hiera/puppet_function.rb +15 -4
  6. data/lib/puppet/application/agent.rb +5 -0
  7. data/lib/puppet/application/apply.rb +23 -2
  8. data/lib/puppet/application/device.rb +8 -3
  9. data/lib/puppet/application/master.rb +16 -5
  10. data/lib/puppet/configurer.rb +7 -5
  11. data/lib/puppet/defaults.rb +18 -0
  12. data/lib/puppet/environments.rb +1 -1
  13. data/lib/puppet/error.rb +27 -1
  14. data/lib/puppet/file_serving/metadata.rb +13 -8
  15. data/lib/puppet/file_serving/terminus_helper.rb +7 -8
  16. data/lib/puppet/file_system.rb +13 -0
  17. data/lib/puppet/file_system/file_impl.rb +4 -0
  18. data/lib/puppet/file_system/memory_impl.rb +4 -0
  19. data/lib/puppet/file_system/windows.rb +8 -0
  20. data/lib/puppet/functions.rb +33 -3
  21. data/lib/puppet/functions/defined.rb +130 -0
  22. data/lib/puppet/functions/regsubst.rb +1 -1
  23. data/lib/puppet/functions/split.rb +1 -1
  24. data/lib/puppet/indirector/catalog/compiler.rb +1 -1
  25. data/lib/puppet/indirector/facts/facter.rb +11 -0
  26. data/lib/puppet/loaders.rb +1 -0
  27. data/lib/puppet/node.rb +17 -1
  28. data/lib/puppet/node/environment.rb +4 -0
  29. data/lib/puppet/parser/ast/pops_bridge.rb +4 -0
  30. data/lib/puppet/parser/compiler.rb +9 -0
  31. data/lib/puppet/parser/functions/defined.rb +25 -1
  32. data/lib/puppet/parser/functions/file.rb +3 -1
  33. data/lib/puppet/parser/scope.rb +11 -2
  34. data/lib/puppet/parser/templatewrapper.rb +2 -1
  35. data/lib/puppet/pops.rb +4 -0
  36. data/lib/puppet/pops/evaluator/access_operator.rb +25 -5
  37. data/lib/puppet/pops/evaluator/closure.rb +28 -2
  38. data/lib/puppet/pops/evaluator/collector_transformer.rb +1 -11
  39. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +4 -0
  40. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +4 -0
  41. data/lib/puppet/pops/evaluator/compare_operator.rb +43 -0
  42. data/lib/puppet/pops/evaluator/epp_evaluator.rb +7 -2
  43. data/lib/puppet/pops/evaluator/evaluator_impl.rb +48 -14
  44. data/lib/puppet/pops/evaluator/runtime3_support.rb +10 -5
  45. data/lib/puppet/pops/functions/dispatch.rb +6 -1
  46. data/lib/puppet/pops/functions/dispatcher.rb +7 -1
  47. data/lib/puppet/pops/issue_reporter.rb +42 -16
  48. data/lib/puppet/pops/issues.rb +116 -2
  49. data/lib/puppet/pops/loader/loader.rb +11 -0
  50. data/lib/puppet/pops/loader/loader_paths.rb +67 -6
  51. data/lib/puppet/pops/loader/module_loaders.rb +19 -8
  52. data/lib/puppet/pops/loader/puppet_function_instantiator.rb +78 -0
  53. data/lib/puppet/pops/loaders.rb +6 -4
  54. data/lib/puppet/pops/migration/migration_checker.rb +54 -0
  55. data/lib/puppet/pops/model/factory.rb +5 -1
  56. data/lib/puppet/pops/model/model_label_provider.rb +2 -0
  57. data/lib/puppet/pops/model/model_meta.rb +5 -1
  58. data/lib/puppet/pops/parser/egrammar.ra +9 -10
  59. data/lib/puppet/pops/parser/eparser.rb +1061 -1047
  60. data/lib/puppet/pops/parser/epp_support.rb +18 -9
  61. data/lib/puppet/pops/parser/evaluating_parser.rb +7 -1
  62. data/lib/puppet/pops/parser/heredoc_support.rb +12 -11
  63. data/lib/puppet/pops/parser/interpolation_support.rb +7 -1
  64. data/lib/puppet/pops/parser/lexer2.rb +29 -12
  65. data/lib/puppet/pops/parser/lexer_support.rb +52 -23
  66. data/lib/puppet/pops/parser/parser_support.rb +11 -14
  67. data/lib/puppet/pops/parser/slurp_support.rb +22 -6
  68. data/lib/puppet/pops/types/type_calculator.rb +156 -55
  69. data/lib/puppet/pops/types/type_factory.rb +66 -13
  70. data/lib/puppet/pops/types/type_parser.rb +22 -13
  71. data/lib/puppet/pops/types/types.rb +23 -4
  72. data/lib/puppet/pops/types/types_meta.rb +13 -2
  73. data/lib/puppet/pops/validation.rb +25 -2
  74. data/lib/puppet/pops/validation/checker4_0.rb +63 -31
  75. data/lib/puppet/provider/group/windows_adsi.rb +8 -4
  76. data/lib/puppet/provider/mount/parsed.rb +145 -2
  77. data/lib/puppet/provider/package/apt.rb +1 -1
  78. data/lib/puppet/provider/package/pip.rb +11 -2
  79. data/lib/puppet/provider/package/pkgng.rb +134 -0
  80. data/lib/puppet/provider/package/portage.rb +1 -1
  81. data/lib/puppet/provider/package/ports.rb +0 -3
  82. data/lib/puppet/provider/package/windows/exe_package.rb +0 -1
  83. data/lib/puppet/provider/package/windows/msi_package.rb +0 -1
  84. data/lib/puppet/provider/package/zypper.rb +50 -15
  85. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +32 -7
  86. data/lib/puppet/provider/service/debian.rb +1 -1
  87. data/lib/puppet/provider/service/init.rb +7 -0
  88. data/lib/puppet/provider/user/openbsd.rb +1 -0
  89. data/lib/puppet/provider/user/windows_adsi.rb +45 -2
  90. data/lib/puppet/reference/indirection.rb +1 -1
  91. data/lib/puppet/resource.rb +1 -1
  92. data/lib/puppet/resource/catalog.rb +0 -4
  93. data/lib/puppet/settings.rb +19 -0
  94. data/lib/puppet/type/file.rb +1 -0
  95. data/lib/puppet/type/file/ensure.rb +1 -1
  96. data/lib/puppet/type/mount.rb +9 -1
  97. data/lib/puppet/type/scheduled_task.rb +13 -0
  98. data/lib/puppet/type/tidy.rb +3 -1
  99. data/lib/puppet/type/user.rb +32 -0
  100. data/lib/puppet/type/yumrepo.rb +5 -5
  101. data/lib/puppet/util/log.rb +50 -8
  102. data/lib/puppet/util/log/destinations.rb +23 -2
  103. data/lib/puppet/util/logging.rb +37 -1
  104. data/lib/puppet/util/run_mode.rb +1 -14
  105. data/lib/puppet/util/windows/adsi.rb +130 -58
  106. data/lib/puppet/version.rb +1 -1
  107. data/man/man5/puppet.conf.5 +48 -6
  108. data/man/man8/extlookup2hiera.8 +1 -1
  109. data/man/man8/puppet-agent.8 +4 -1
  110. data/man/man8/puppet-apply.8 +4 -1
  111. data/man/man8/puppet-ca.8 +1 -1
  112. data/man/man8/puppet-catalog.8 +1 -1
  113. data/man/man8/puppet-cert.8 +1 -1
  114. data/man/man8/puppet-certificate.8 +1 -1
  115. data/man/man8/puppet-certificate_request.8 +1 -1
  116. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  117. data/man/man8/puppet-config.8 +1 -1
  118. data/man/man8/puppet-describe.8 +1 -1
  119. data/man/man8/puppet-device.8 +6 -3
  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-file.8 +1 -1
  124. data/man/man8/puppet-filebucket.8 +1 -1
  125. data/man/man8/puppet-help.8 +1 -1
  126. data/man/man8/puppet-inspect.8 +1 -1
  127. data/man/man8/puppet-key.8 +1 -1
  128. data/man/man8/puppet-man.8 +1 -1
  129. data/man/man8/puppet-master.8 +4 -1
  130. data/man/man8/puppet-module.8 +1 -1
  131. data/man/man8/puppet-node.8 +1 -1
  132. data/man/man8/puppet-parser.8 +1 -1
  133. data/man/man8/puppet-plugin.8 +1 -1
  134. data/man/man8/puppet-report.8 +1 -1
  135. data/man/man8/puppet-resource.8 +1 -1
  136. data/man/man8/puppet-resource_type.8 +1 -1
  137. data/man/man8/puppet-status.8 +1 -1
  138. data/man/man8/puppet.8 +1 -1
  139. data/spec/fixtures/unit/data_providers/environments/production/lib/puppet/functions/environment/data.rb +3 -1
  140. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/functions/data.pp +6 -0
  141. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/lib/puppet/bindings/xyz/default.rb +9 -0
  142. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/manifests/init.pp +9 -0
  143. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcalled.pp +3 -0
  144. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller.pp +3 -0
  145. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller4.pp +3 -0
  146. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/callingpuppet.rb +5 -0
  147. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/functions/hello.pp +3 -0
  148. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/manifests/init.pp +3 -0
  149. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/metadata.json +10 -0
  150. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/hello.pp +3 -0
  151. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/subspace/hello.pp +3 -0
  152. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +1 -10
  153. data/spec/fixtures/unit/provider/mount/parsed/aix.filesystems +93 -85
  154. data/spec/fixtures/unit/provider/mount/parsed/aix.mount +11 -7
  155. data/spec/fixtures/unit/provider/package/pkgng/pkg.info +8 -0
  156. data/spec/fixtures/unit/provider/package/pkgng/pkg.query +1 -0
  157. data/spec/fixtures/unit/provider/package/pkgng/pkg.query_absent +1 -0
  158. data/spec/fixtures/unit/provider/package/pkgng/pkg.version +3 -0
  159. data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-empty.out +3 -0
  160. data/spec/integration/application/apply_spec.rb +49 -0
  161. data/spec/integration/faces/plugin_spec.rb +0 -4
  162. data/spec/integration/indirector/facts/facter_spec.rb +59 -0
  163. data/spec/integration/parser/compiler_spec.rb +850 -0
  164. data/spec/integration/parser/resource_expressions_spec.rb +3 -0
  165. data/spec/integration/parser/scope_spec.rb +26 -5
  166. data/spec/integration/transaction_spec.rb +1 -1
  167. data/spec/integration/type/file_spec.rb +318 -41
  168. data/spec/integration/util/windows/security_spec.rb +14 -5
  169. data/spec/lib/matchers/resource.rb +22 -1
  170. data/spec/lib/puppet_spec/matchers.rb +6 -4
  171. data/spec/unit/application/master_spec.rb +33 -7
  172. data/spec/unit/data_providers/function_data_provider_spec.rb +10 -1
  173. data/spec/unit/file_serving/metadata_spec.rb +1 -1
  174. data/spec/unit/file_serving/terminus_helper_spec.rb +2 -3
  175. data/spec/unit/file_system_spec.rb +38 -0
  176. data/spec/unit/functions/defined_spec.rb +289 -0
  177. data/spec/unit/functions/hiera_spec.rb +8 -6
  178. data/spec/unit/functions/regsubst_spec.rb +4 -0
  179. data/spec/unit/functions/split_spec.rb +8 -0
  180. data/spec/unit/functions4_spec.rb +97 -2
  181. data/spec/unit/indirector/facts/facter_spec.rb +7 -0
  182. data/spec/unit/node_spec.rb +6 -0
  183. data/spec/unit/parser/functions/file_spec.rb +7 -1
  184. data/spec/unit/parser/functions/template_spec.rb +1 -1
  185. data/spec/unit/parser/scope_spec.rb +2 -2
  186. data/spec/unit/parser/templatewrapper_spec.rb +1 -1
  187. data/spec/unit/pops/evaluator/access_ops_spec.rb +19 -0
  188. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +84 -18
  189. data/spec/unit/pops/evaluator/variables_spec.rb +1 -1
  190. data/spec/unit/pops/issues_spec.rb +16 -16
  191. data/spec/unit/pops/loaders/loaders_spec.rb +106 -48
  192. data/spec/unit/pops/migration_spec.rb +53 -0
  193. data/spec/unit/pops/parser/lexer2_spec.rb +142 -1
  194. data/spec/unit/pops/parser/parse_heredoc_spec.rb +26 -0
  195. data/spec/unit/pops/types/type_calculator_spec.rb +205 -12
  196. data/spec/unit/pops/validation_spec.rb +66 -0
  197. data/spec/unit/pops/validator/validator_spec.rb +1 -1
  198. data/spec/unit/provider/group/windows_adsi_spec.rb +57 -9
  199. data/spec/unit/provider/mount/parsed_spec.rb +31 -5
  200. data/spec/unit/provider/package/apt_spec.rb +5 -0
  201. data/spec/unit/provider/package/pip_spec.rb +9 -0
  202. data/spec/unit/provider/package/pkgng_spec.rb +172 -0
  203. data/spec/unit/provider/package/windows/exe_package_spec.rb +0 -1
  204. data/spec/unit/provider/package/windows/msi_package_spec.rb +0 -1
  205. data/spec/unit/provider/package/zypper_spec.rb +50 -19
  206. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +312 -70
  207. data/spec/unit/provider/service/base_spec.rb +38 -27
  208. data/spec/unit/provider/service/debian_spec.rb +8 -0
  209. data/spec/unit/provider/service/freebsd_spec.rb +1 -0
  210. data/spec/unit/provider/service/gentoo_spec.rb +1 -0
  211. data/spec/unit/provider/service/init_spec.rb +18 -0
  212. data/spec/unit/provider/service/openbsd_spec.rb +1 -0
  213. data/spec/unit/provider/service/redhat_spec.rb +1 -0
  214. data/spec/unit/provider/user/windows_adsi_spec.rb +134 -5
  215. data/spec/unit/settings_spec.rb +11 -0
  216. data/spec/unit/util/log_spec.rb +113 -0
  217. data/spec/unit/util/windows/adsi_spec.rb +135 -41
  218. data/spec/unit/util/windows/sid_spec.rb +0 -10
  219. metadata +48 -2
@@ -189,39 +189,50 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
189
189
  end
190
190
 
191
191
  describe "when given a set of groups to which to add the user" do
192
+ let(:existing_groups) { ['group2','group3'] }
193
+ let(:group_sids) { existing_groups.each_with_index.map{|n,i| stub(:Name => n, :objectSID => [i])} }
194
+
192
195
  let(:groups_to_set) { 'group1,group2' }
196
+ let(:desired_sids) { groups_to_set.split(',').each_with_index.map{|n,i| stub(:Name => n, :objectSID => [i-1])} }
193
197
 
194
198
  before(:each) do
195
- Puppet::Util::Windows::SID.stubs(:octet_string_to_sid_object).returns(sid)
196
- user.expects(:groups).returns ['group2', 'group3']
199
+ user.expects(:group_sids).returns(group_sids.map {|s| s.objectSID})
197
200
  end
198
201
 
199
202
  describe "if membership is specified as inclusive" do
200
203
  it "should add the user to those groups, and remove it from groups not in the list" do
201
- group1 = stub 'group1'
202
- group1.expects(:Add).with("WinNT://testcomputername/#{username},user")
204
+ Puppet::Util::Windows::ADSI::User.expects(:name_sid_hash).returns(Hash[ desired_sids.map { |s| [s.objectSID.to_s, s.objectSID] }])
205
+ user.expects(:add_group_sids).with([-1])
206
+ user.expects(:remove_group_sids).with([1])
203
207
 
204
- group3 = stub 'group1'
205
- group3.expects(:Remove).with("WinNT://testcomputername/#{username},user")
208
+ user.set_groups(groups_to_set, false)
209
+ end
206
210
 
207
- Puppet::Util::Windows::ADSI.expects(:sid_uri).with(sid).returns("WinNT://testcomputername/#{username},user").twice
208
- Puppet::Util::Windows::ADSI.expects(:connect).with('WinNT://./group1,group').returns group1
209
- Puppet::Util::Windows::ADSI.expects(:connect).with('WinNT://./group3,group').returns group3
211
+ it "should remove all users from a group if desired is empty" do
212
+ Puppet::Util::Windows::ADSI::User.expects(:name_sid_hash).returns({})
213
+ user.expects(:add_group_sids).never
214
+ user.expects(:remove_group_sids).with([0], [1])
210
215
 
211
- user.set_groups(groups_to_set, false)
216
+ user.set_groups('', false)
212
217
  end
213
218
  end
214
219
 
215
220
  describe "if membership is specified as minimum" do
216
221
  it "should add the user to the specified groups without affecting its other memberships" do
217
- group1 = stub 'group1'
218
- group1.expects(:Add).with("WinNT://testcomputername/#{username},user")
219
-
220
- Puppet::Util::Windows::ADSI.expects(:sid_uri).with(sid).returns("WinNT://testcomputername/#{username},user")
221
- Puppet::Util::Windows::ADSI.expects(:connect).with('WinNT://./group1,group').returns group1
222
+ Puppet::Util::Windows::ADSI::User.expects(:name_sid_hash).returns(Hash[ desired_sids.map { |s| [s.objectSID.to_s, s.objectSID] }])
223
+ user.expects(:add_group_sids).with([-1])
224
+ user.expects(:remove_group_sids).never
222
225
 
223
226
  user.set_groups(groups_to_set, true)
224
227
  end
228
+
229
+ it "should do nothing if desired is empty" do
230
+ Puppet::Util::Windows::ADSI::User.expects(:name_sid_hash).returns({})
231
+ user.expects(:remove_group_sids).never
232
+ user.expects(:add_group_sids).never
233
+
234
+ user.set_groups('', true)
235
+ end
225
236
  end
226
237
  end
227
238
  end
@@ -270,42 +281,125 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
270
281
  expect(group.members).to match(names)
271
282
  end
272
283
 
273
- it "should be able to add a list of users to a group" do
274
- names = ['DOMAIN\user1', 'user2']
275
- sids = [
276
- stub(:account => 'user1', :domain => 'DOMAIN'),
277
- stub(:account => 'user2', :domain => 'testcomputername'),
278
- stub(:account => 'user3', :domain => 'DOMAIN2'),
279
- ]
284
+ context "calling .set_members" do
285
+ it "should set the members of a group to only desired_members when inclusive" do
286
+ names = ['DOMAIN\user1', 'user2']
287
+ sids = [
288
+ stub(:account => 'user1', :domain => 'DOMAIN'),
289
+ stub(:account => 'user2', :domain => 'testcomputername'),
290
+ stub(:account => 'user3', :domain => 'DOMAIN2'),
291
+ ]
280
292
 
281
- # use stubbed objectSid on member to return stubbed SID
282
- Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([0]).returns(sids[0])
283
- Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([1]).returns(sids[1])
293
+ # use stubbed objectSid on member to return stubbed SID
294
+ Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([0]).returns(sids[0])
295
+ Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([1]).returns(sids[1])
284
296
 
285
- Puppet::Util::Windows::SID.expects(:name_to_sid_object).with('user2').returns(sids[1])
286
- Puppet::Util::Windows::SID.expects(:name_to_sid_object).with('DOMAIN2\user3').returns(sids[2])
297
+ Puppet::Util::Windows::SID.expects(:name_to_sid_object).with('user2').returns(sids[1])
298
+ Puppet::Util::Windows::SID.expects(:name_to_sid_object).with('DOMAIN2\user3').returns(sids[2])
287
299
 
288
- Puppet::Util::Windows::ADSI.expects(:sid_uri).with(sids[0]).returns("WinNT://DOMAIN/user1,user")
289
- Puppet::Util::Windows::ADSI.expects(:sid_uri).with(sids[2]).returns("WinNT://DOMAIN2/user3,user")
300
+ Puppet::Util::Windows::ADSI.expects(:sid_uri).with(sids[0]).returns("WinNT://DOMAIN/user1,user")
301
+ Puppet::Util::Windows::ADSI.expects(:sid_uri).with(sids[2]).returns("WinNT://DOMAIN2/user3,user")
290
302
 
291
- members = names.each_with_index.map{|n,i| stub(:Name => n, :objectSID => [i])}
292
- adsi_group.expects(:Members).returns members
303
+ members = names.each_with_index.map{|n,i| stub(:Name => n, :objectSID => [i])}
304
+ adsi_group.expects(:Members).returns members
293
305
 
294
- adsi_group.expects(:Remove).with('WinNT://DOMAIN/user1,user')
295
- adsi_group.expects(:Add).with('WinNT://DOMAIN2/user3,user')
306
+ adsi_group.expects(:Remove).with('WinNT://DOMAIN/user1,user')
307
+ adsi_group.expects(:Add).with('WinNT://DOMAIN2/user3,user')
296
308
 
297
- group.set_members(['user2', 'DOMAIN2\user3'])
298
- end
309
+ group.set_members(['user2', 'DOMAIN2\user3'])
310
+ end
299
311
 
300
- it "should raise an error when a username does not resolve to a SID" do
301
- expect {
302
- adsi_group.expects(:Members).returns []
303
- group.set_members(['foobar'])
304
- }.to raise_error(Puppet::Error, /Could not resolve username: foobar/)
312
+ it "should add the desired_members to an existing group when not inclusive" do
313
+ names = ['DOMAIN\user1', 'user2']
314
+ sids = [
315
+ stub(:account => 'user1', :domain => 'DOMAIN'),
316
+ stub(:account => 'user2', :domain => 'testcomputername'),
317
+ stub(:account => 'user3', :domain => 'DOMAIN2'),
318
+ ]
319
+
320
+ # use stubbed objectSid on member to return stubbed SID
321
+ Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([0]).returns(sids[0])
322
+ Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([1]).returns(sids[1])
323
+
324
+ Puppet::Util::Windows::SID.expects(:name_to_sid_object).with('user2').returns(sids[1])
325
+ Puppet::Util::Windows::SID.expects(:name_to_sid_object).with('DOMAIN2\user3').returns(sids[2])
326
+
327
+ Puppet::Util::Windows::ADSI.expects(:sid_uri).with(sids[2]).returns("WinNT://DOMAIN2/user3,user")
328
+
329
+ members = names.each_with_index.map{|n,i| stub(:Name => n, :objectSID => [i])}
330
+ adsi_group.expects(:Members).returns members
331
+
332
+ adsi_group.expects(:Remove).with('WinNT://DOMAIN/user1,user').never
333
+
334
+ adsi_group.expects(:Add).with('WinNT://DOMAIN2/user3,user')
335
+
336
+ group.set_members(['user2', 'DOMAIN2\user3'],false)
337
+ end
338
+
339
+ it "should return immediately when desired_members is nil" do
340
+ adsi_group.expects(:Members).never
341
+
342
+ adsi_group.expects(:Remove).never
343
+ adsi_group.expects(:Add).never
344
+
345
+ group.set_members(nil)
346
+ end
347
+
348
+ it "should remove all members when desired_members is empty and inclusive" do
349
+ names = ['DOMAIN\user1', 'user2']
350
+ sids = [
351
+ stub(:account => 'user1', :domain => 'DOMAIN'),
352
+ stub(:account => 'user2', :domain => 'testcomputername')
353
+ ]
354
+
355
+ # use stubbed objectSid on member to return stubbed SID
356
+ Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([0]).returns(sids[0])
357
+ Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([1]).returns(sids[1])
358
+
359
+ Puppet::Util::Windows::ADSI.expects(:sid_uri).with(sids[0]).returns("WinNT://DOMAIN/user1,user")
360
+ Puppet::Util::Windows::ADSI.expects(:sid_uri).with(sids[1]).returns("WinNT://testcomputername/user2,user")
361
+
362
+ members = names.each_with_index.map{|n,i| stub(:Name => n, :objectSID => [i])}
363
+ adsi_group.expects(:Members).returns members
364
+
365
+ adsi_group.expects(:Remove).with('WinNT://DOMAIN/user1,user')
366
+ adsi_group.expects(:Remove).with('WinNT://testcomputername/user2,user')
367
+
368
+ group.set_members([])
369
+ end
370
+
371
+ it "should do nothing when desired_members is empty and not inclusive" do
372
+ names = ['DOMAIN\user1', 'user2']
373
+ sids = [
374
+ stub(:account => 'user1', :domain => 'DOMAIN'),
375
+ stub(:account => 'user2', :domain => 'testcomputername')
376
+ ]
377
+ # use stubbed objectSid on member to return stubbed SID
378
+ Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([0]).returns(sids[0])
379
+ Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([1]).returns(sids[1])
380
+
381
+ members = names.each_with_index.map{|n,i| stub(:Name => n, :objectSID => [i])}
382
+ adsi_group.expects(:Members).returns members
383
+
384
+ adsi_group.expects(:Remove).never
385
+ adsi_group.expects(:Add).never
386
+
387
+ group.set_members([],false)
388
+ end
389
+
390
+ it "should raise an error when a username does not resolve to a SID" do
391
+ expect {
392
+ adsi_group.expects(:Members).returns []
393
+ group.set_members(['foobar'])
394
+ }.to raise_error(Puppet::Error, /Could not resolve name: foobar/)
395
+ end
305
396
  end
306
397
 
307
398
  it "should generate the correct URI" do
308
399
  Puppet::Util::Windows::ADSI.stubs(:sid_uri_safe).returns(nil)
400
+ adsi_group.expects(:objectSID).returns([0])
401
+ Socket.expects(:gethostname).returns('testcomputername')
402
+ Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([0]).returns(stub(:account => groupname,:domain => 'testcomputername'))
309
403
  expect(group.uri).to eq("WinNT://./#{groupname},group")
310
404
  end
311
405
  end
@@ -381,7 +475,7 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
381
475
  end
382
476
 
383
477
  it "should warn on 2003" do
384
- connection.expects(:Delete).raises(RuntimeError,
478
+ connection.expects(:Delete).raises(WIN32OLERuntimeError,
385
479
  "Delete (WIN32OLERuntimeError)
386
480
  OLE error code:80041010 in SWbemServicesEx
387
481
  Invalid class
@@ -13,16 +13,6 @@ describe "Puppet::Util::Windows::SID", :if => Puppet.features.microsoft_windows?
13
13
  let(:unknown_name) { 'chewbacca' }
14
14
 
15
15
  context "#octet_string_to_sid_object" do
16
- it "should properly convert an array of bytes for the local Administrator SID" do
17
- host = '.'
18
- username = 'Administrator'
19
- admin = WIN32OLE.connect("WinNT://#{host}/#{username},user")
20
- converted = subject.octet_string_to_sid_object(admin.objectSID)
21
-
22
- expect(converted).to eq(Win32::Security::SID.new(username, host))
23
- expect(converted).to be_an_instance_of Win32::Security::SID
24
- end
25
-
26
16
  it "should properly convert an array of bytes for a well-known SID" do
27
17
  bytes = [1, 1, 0, 0, 0, 0, 0, 5, 18, 0, 0, 0]
28
18
  converted = subject.octet_string_to_sid_object(bytes)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-08 00:00:00.000000000 Z
11
+ date: 2015-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: facter
@@ -238,6 +238,7 @@ files:
238
238
  - lib/puppet/forge/repository.rb
239
239
  - lib/puppet/functions.rb
240
240
  - lib/puppet/functions/assert_type.rb
241
+ - lib/puppet/functions/defined.rb
241
242
  - lib/puppet/functions/each.rb
242
243
  - lib/puppet/functions/epp.rb
243
244
  - lib/puppet/functions/filter.rb
@@ -579,6 +580,7 @@ files:
579
580
  - lib/puppet/pops/loader/loader_paths.rb
580
581
  - lib/puppet/pops/loader/module_loaders.rb
581
582
  - lib/puppet/pops/loader/null_loader.rb
583
+ - lib/puppet/pops/loader/puppet_function_instantiator.rb
582
584
  - lib/puppet/pops/loader/ruby_function_instantiator.rb
583
585
  - lib/puppet/pops/loader/simple_environment_loader.rb
584
586
  - lib/puppet/pops/loader/static_loader.rb
@@ -586,6 +588,7 @@ files:
586
588
  - lib/puppet/pops/loaders.rb
587
589
  - lib/puppet/pops/lookup.rb
588
590
  - lib/puppet/pops/merge_strategy.rb
591
+ - lib/puppet/pops/migration/migration_checker.rb
589
592
  - lib/puppet/pops/model/ast_transformer.rb
590
593
  - lib/puppet/pops/model/factory.rb
591
594
  - lib/puppet/pops/model/model.rb
@@ -687,6 +690,7 @@ files:
687
690
  - lib/puppet/provider/package/pkg.rb
688
691
  - lib/puppet/provider/package/pkgdmg.rb
689
692
  - lib/puppet/provider/package/pkgin.rb
693
+ - lib/puppet/provider/package/pkgng.rb
690
694
  - lib/puppet/provider/package/pkgutil.rb
691
695
  - lib/puppet/provider/package/portage.rb
692
696
  - lib/puppet/provider/package/ports.rb
@@ -1452,6 +1456,9 @@ files:
1452
1456
  - spec/fixtures/unit/data_providers/environments/production/modules/abc/lib/puppet/bindings/abc/default.rb
1453
1457
  - spec/fixtures/unit/data_providers/environments/production/modules/abc/lib/puppet/functions/abc/data.rb
1454
1458
  - spec/fixtures/unit/data_providers/environments/production/modules/abc/manifests/init.pp
1459
+ - spec/fixtures/unit/data_providers/environments/production/modules/xyz/functions/data.pp
1460
+ - spec/fixtures/unit/data_providers/environments/production/modules/xyz/lib/puppet/bindings/xyz/default.rb
1461
+ - spec/fixtures/unit/data_providers/environments/production/modules/xyz/manifests/init.pp
1455
1462
  - spec/fixtures/unit/data_providers/environments/sample/environment.conf
1456
1463
  - spec/fixtures/unit/data_providers/environments/sample/manifests/site.pp
1457
1464
  - spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet/bindings/dataprovider/default.rb
@@ -1534,9 +1541,18 @@ files:
1534
1541
  - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/callee.rb
1535
1542
  - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/callee_ws.rb
1536
1543
  - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/metadata.json
1544
+ - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcalled.pp
1545
+ - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller.pp
1546
+ - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller4.pp
1537
1547
  - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/caller.rb
1538
1548
  - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/caller_ws.rb
1549
+ - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/callingpuppet.rb
1539
1550
  - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/metadata.json
1551
+ - spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/functions/hello.pp
1552
+ - spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/manifests/init.pp
1553
+ - spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/metadata.json
1554
+ - spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/hello.pp
1555
+ - spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/subspace/hello.pp
1540
1556
  - spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/modulea/rb_func_a.rb
1541
1557
  - spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/rb_func_a.rb
1542
1558
  - spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/manifests/init.pp
@@ -1628,11 +1644,16 @@ files:
1628
1644
  - spec/fixtures/unit/provider/package/pkg/incomplete
1629
1645
  - spec/fixtures/unit/provider/package/pkg/solaris11
1630
1646
  - spec/fixtures/unit/provider/package/pkg/unknown_status
1647
+ - spec/fixtures/unit/provider/package/pkgng/pkg.info
1648
+ - spec/fixtures/unit/provider/package/pkgng/pkg.query
1649
+ - spec/fixtures/unit/provider/package/pkgng/pkg.query_absent
1650
+ - spec/fixtures/unit/provider/package/pkgng/pkg.version
1631
1651
  - spec/fixtures/unit/provider/package/sun/dummy.server
1632
1652
  - spec/fixtures/unit/provider/package/sun/simple
1633
1653
  - spec/fixtures/unit/provider/package/yum/yum-check-update-multiline.txt
1634
1654
  - spec/fixtures/unit/provider/package/yum/yum-check-update-simple.txt
1635
1655
  - spec/fixtures/unit/provider/package/zypper/zypper-list-updates-SLES11sp1.out
1656
+ - spec/fixtures/unit/provider/package/zypper/zypper-list-updates-empty.out
1636
1657
  - spec/fixtures/unit/provider/parsedfile/simple.txt
1637
1658
  - spec/fixtures/unit/provider/service/gentoo/rc_update_show
1638
1659
  - spec/fixtures/unit/provider/service/openbsd/rcctl_getall
@@ -1866,6 +1887,7 @@ files:
1866
1887
  - spec/unit/forge/repository_spec.rb
1867
1888
  - spec/unit/forge_spec.rb
1868
1889
  - spec/unit/functions/assert_type_spec.rb
1890
+ - spec/unit/functions/defined_spec.rb
1869
1891
  - spec/unit/functions/each_spec.rb
1870
1892
  - spec/unit/functions/epp_spec.rb
1871
1893
  - spec/unit/functions/filter_spec.rb
@@ -2103,6 +2125,7 @@ files:
2103
2125
  - spec/unit/pops/loaders/loaders_spec.rb
2104
2126
  - spec/unit/pops/loaders/module_loaders_spec.rb
2105
2127
  - spec/unit/pops/loaders/static_loader_spec.rb
2128
+ - spec/unit/pops/migration_spec.rb
2106
2129
  - spec/unit/pops/model/model_spec.rb
2107
2130
  - spec/unit/pops/parser/epp_parser_spec.rb
2108
2131
  - spec/unit/pops/parser/evaluating_parser_spec.rb
@@ -2123,6 +2146,7 @@ files:
2123
2146
  - spec/unit/pops/types/type_factory_spec.rb
2124
2147
  - spec/unit/pops/types/type_parser_spec.rb
2125
2148
  - spec/unit/pops/utils_spec.rb
2149
+ - spec/unit/pops/validation_spec.rb
2126
2150
  - spec/unit/pops/validator/validator_spec.rb
2127
2151
  - spec/unit/pops/visitor_spec.rb
2128
2152
  - spec/unit/property/boolean_spec.rb
@@ -2177,6 +2201,7 @@ files:
2177
2201
  - spec/unit/provider/package/pkg_spec.rb
2178
2202
  - spec/unit/provider/package/pkgdmg_spec.rb
2179
2203
  - spec/unit/provider/package/pkgin_spec.rb
2204
+ - spec/unit/provider/package/pkgng_spec.rb
2180
2205
  - spec/unit/provider/package/pkgutil_spec.rb
2181
2206
  - spec/unit/provider/package/portage_spec.rb
2182
2207
  - spec/unit/provider/package/puppet_gem_spec.rb
@@ -2488,6 +2513,9 @@ test_files:
2488
2513
  - spec/fixtures/unit/data_providers/environments/production/modules/abc/lib/puppet/bindings/abc/default.rb
2489
2514
  - spec/fixtures/unit/data_providers/environments/production/modules/abc/lib/puppet/functions/abc/data.rb
2490
2515
  - spec/fixtures/unit/data_providers/environments/production/modules/abc/manifests/init.pp
2516
+ - spec/fixtures/unit/data_providers/environments/production/modules/xyz/functions/data.pp
2517
+ - spec/fixtures/unit/data_providers/environments/production/modules/xyz/lib/puppet/bindings/xyz/default.rb
2518
+ - spec/fixtures/unit/data_providers/environments/production/modules/xyz/manifests/init.pp
2491
2519
  - spec/fixtures/unit/data_providers/environments/sample/environment.conf
2492
2520
  - spec/fixtures/unit/data_providers/environments/sample/manifests/site.pp
2493
2521
  - spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet/bindings/dataprovider/default.rb
@@ -2570,9 +2598,18 @@ test_files:
2570
2598
  - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/callee.rb
2571
2599
  - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/callee_ws.rb
2572
2600
  - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/metadata.json
2601
+ - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcalled.pp
2602
+ - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller.pp
2603
+ - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller4.pp
2573
2604
  - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/caller.rb
2574
2605
  - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/caller_ws.rb
2606
+ - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/callingpuppet.rb
2575
2607
  - spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/metadata.json
2608
+ - spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/functions/hello.pp
2609
+ - spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/manifests/init.pp
2610
+ - spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/metadata.json
2611
+ - spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/hello.pp
2612
+ - spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/subspace/hello.pp
2576
2613
  - spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/modulea/rb_func_a.rb
2577
2614
  - spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/rb_func_a.rb
2578
2615
  - spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/manifests/init.pp
@@ -2664,11 +2701,16 @@ test_files:
2664
2701
  - spec/fixtures/unit/provider/package/pkg/incomplete
2665
2702
  - spec/fixtures/unit/provider/package/pkg/solaris11
2666
2703
  - spec/fixtures/unit/provider/package/pkg/unknown_status
2704
+ - spec/fixtures/unit/provider/package/pkgng/pkg.info
2705
+ - spec/fixtures/unit/provider/package/pkgng/pkg.query
2706
+ - spec/fixtures/unit/provider/package/pkgng/pkg.query_absent
2707
+ - spec/fixtures/unit/provider/package/pkgng/pkg.version
2667
2708
  - spec/fixtures/unit/provider/package/sun/dummy.server
2668
2709
  - spec/fixtures/unit/provider/package/sun/simple
2669
2710
  - spec/fixtures/unit/provider/package/yum/yum-check-update-multiline.txt
2670
2711
  - spec/fixtures/unit/provider/package/yum/yum-check-update-simple.txt
2671
2712
  - spec/fixtures/unit/provider/package/zypper/zypper-list-updates-SLES11sp1.out
2713
+ - spec/fixtures/unit/provider/package/zypper/zypper-list-updates-empty.out
2672
2714
  - spec/fixtures/unit/provider/parsedfile/simple.txt
2673
2715
  - spec/fixtures/unit/provider/service/gentoo/rc_update_show
2674
2716
  - spec/fixtures/unit/provider/service/openbsd/rcctl_getall
@@ -2902,6 +2944,7 @@ test_files:
2902
2944
  - spec/unit/forge/repository_spec.rb
2903
2945
  - spec/unit/forge_spec.rb
2904
2946
  - spec/unit/functions/assert_type_spec.rb
2947
+ - spec/unit/functions/defined_spec.rb
2905
2948
  - spec/unit/functions/each_spec.rb
2906
2949
  - spec/unit/functions/epp_spec.rb
2907
2950
  - spec/unit/functions/filter_spec.rb
@@ -3139,6 +3182,7 @@ test_files:
3139
3182
  - spec/unit/pops/loaders/loaders_spec.rb
3140
3183
  - spec/unit/pops/loaders/module_loaders_spec.rb
3141
3184
  - spec/unit/pops/loaders/static_loader_spec.rb
3185
+ - spec/unit/pops/migration_spec.rb
3142
3186
  - spec/unit/pops/model/model_spec.rb
3143
3187
  - spec/unit/pops/parser/epp_parser_spec.rb
3144
3188
  - spec/unit/pops/parser/evaluating_parser_spec.rb
@@ -3159,6 +3203,7 @@ test_files:
3159
3203
  - spec/unit/pops/types/type_factory_spec.rb
3160
3204
  - spec/unit/pops/types/type_parser_spec.rb
3161
3205
  - spec/unit/pops/utils_spec.rb
3206
+ - spec/unit/pops/validation_spec.rb
3162
3207
  - spec/unit/pops/validator/validator_spec.rb
3163
3208
  - spec/unit/pops/visitor_spec.rb
3164
3209
  - spec/unit/property/boolean_spec.rb
@@ -3213,6 +3258,7 @@ test_files:
3213
3258
  - spec/unit/provider/package/pkg_spec.rb
3214
3259
  - spec/unit/provider/package/pkgdmg_spec.rb
3215
3260
  - spec/unit/provider/package/pkgin_spec.rb
3261
+ - spec/unit/provider/package/pkgng_spec.rb
3216
3262
  - spec/unit/provider/package/pkgutil_spec.rb
3217
3263
  - spec/unit/provider/package/portage_spec.rb
3218
3264
  - spec/unit/provider/package/puppet_gem_spec.rb