puppet 5.5.6-x86-mingw32 → 5.5.7-x86-mingw32

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

Potentially problematic release.


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

Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -1
  3. data/Gemfile.lock +12 -12
  4. data/Rakefile +9 -0
  5. data/lib/puppet/application.rb +5 -0
  6. data/lib/puppet/application/apply.rb +1 -0
  7. data/lib/puppet/application/master.rb +9 -7
  8. data/lib/puppet/application/script.rb +1 -1
  9. data/lib/puppet/defaults.rb +51 -31
  10. data/lib/puppet/etc.rb +20 -0
  11. data/lib/puppet/file_serving/fileset.rb +1 -1
  12. data/lib/puppet/functions.rb +123 -0
  13. data/lib/puppet/functions/new.rb +37 -53
  14. data/lib/puppet/functions/warning.rb +1 -1
  15. data/lib/puppet/loaders.rb +1 -0
  16. data/lib/puppet/parser/functions.rb +3 -1
  17. data/lib/puppet/parser/functions/sprintf.rb +12 -1
  18. data/lib/puppet/pops/evaluator/runtime3_converter.rb +16 -0
  19. data/lib/puppet/pops/evaluator/runtime3_support.rb +3 -4
  20. data/lib/puppet/pops/issues.rb +8 -0
  21. data/lib/puppet/pops/loader/loader.rb +2 -2
  22. data/lib/puppet/pops/loader/loader_paths.rb +3 -1
  23. data/lib/puppet/pops/loader/module_loaders.rb +1 -1
  24. data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +62 -0
  25. data/lib/puppet/pops/loaders.rb +5 -21
  26. data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
  27. data/lib/puppet/pops/parser/lexer2.rb +1 -1
  28. data/lib/puppet/pops/validation/checker4_0.rb +31 -6
  29. data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -0
  30. data/lib/puppet/property/keyvalue.rb +70 -8
  31. data/lib/puppet/provider/aix_object.rb +483 -0
  32. data/lib/puppet/provider/exec.rb +54 -57
  33. data/lib/puppet/provider/group/aix.rb +40 -115
  34. data/lib/puppet/provider/group/pw.rb +4 -8
  35. data/lib/puppet/provider/group/windows_adsi.rb +7 -4
  36. data/lib/puppet/provider/nameservice.rb +1 -25
  37. data/lib/puppet/provider/nameservice/directoryservice.rb +5 -3
  38. data/lib/puppet/provider/package/portage.rb +2 -2
  39. data/lib/puppet/provider/package/windows.rb +2 -2
  40. data/lib/puppet/provider/package/windows/exe_package.rb +3 -10
  41. data/lib/puppet/provider/package/zypper.rb +1 -1
  42. data/lib/puppet/provider/service/launchd.rb +19 -3
  43. data/lib/puppet/provider/service/windows.rb +49 -40
  44. data/lib/puppet/provider/user/aix.rb +180 -246
  45. data/lib/puppet/provider/user/windows_adsi.rb +9 -1
  46. data/lib/puppet/resource/catalog.rb +1 -5
  47. data/lib/puppet/type/augeas.rb +1 -1
  48. data/lib/puppet/type/exec.rb +16 -14
  49. data/lib/puppet/type/file.rb +2 -2
  50. data/lib/puppet/type/file/source.rb +9 -5
  51. data/lib/puppet/type/group.rb +65 -23
  52. data/lib/puppet/type/k5login.rb +2 -2
  53. data/lib/puppet/type/notify.rb +1 -1
  54. data/lib/puppet/type/package.rb +3 -6
  55. data/lib/puppet/type/resources.rb +12 -2
  56. data/lib/puppet/type/schedule.rb +8 -1
  57. data/lib/puppet/type/selboolean.rb +2 -2
  58. data/lib/puppet/type/selmodule.rb +3 -4
  59. data/lib/puppet/type/service.rb +2 -5
  60. data/lib/puppet/type/tidy.rb +1 -1
  61. data/lib/puppet/type/user.rb +15 -20
  62. data/lib/puppet/type/yumrepo.rb +2 -2
  63. data/lib/puppet/type/zone.rb +2 -2
  64. data/lib/puppet/util.rb +7 -3
  65. data/lib/puppet/util/execution.rb +15 -1
  66. data/lib/puppet/util/posix.rb +15 -0
  67. data/lib/puppet/util/storage.rb +12 -0
  68. data/lib/puppet/util/windows.rb +4 -2
  69. data/lib/puppet/util/windows/adsi.rb +235 -205
  70. data/lib/puppet/util/windows/process.rb +23 -3
  71. data/lib/puppet/util/windows/security.rb +14 -0
  72. data/lib/puppet/util/windows/service.rb +977 -0
  73. data/lib/puppet/util/windows/user.rb +3 -5
  74. data/lib/puppet/version.rb +1 -1
  75. data/locales/ja/puppet.po +705 -374
  76. data/locales/puppet.pot +485 -261
  77. data/man/man5/puppet.conf.5 +36 -15
  78. data/man/man8/puppet-agent.8 +1 -1
  79. data/man/man8/puppet-apply.8 +1 -1
  80. data/man/man8/puppet-ca.8 +1 -1
  81. data/man/man8/puppet-catalog.8 +1 -1
  82. data/man/man8/puppet-cert.8 +1 -1
  83. data/man/man8/puppet-certificate.8 +1 -1
  84. data/man/man8/puppet-certificate_request.8 +1 -1
  85. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  86. data/man/man8/puppet-config.8 +1 -1
  87. data/man/man8/puppet-describe.8 +1 -1
  88. data/man/man8/puppet-device.8 +1 -1
  89. data/man/man8/puppet-doc.8 +1 -1
  90. data/man/man8/puppet-epp.8 +1 -1
  91. data/man/man8/puppet-facts.8 +1 -1
  92. data/man/man8/puppet-filebucket.8 +1 -1
  93. data/man/man8/puppet-generate.8 +1 -1
  94. data/man/man8/puppet-help.8 +1 -1
  95. data/man/man8/puppet-key.8 +1 -1
  96. data/man/man8/puppet-lookup.8 +1 -1
  97. data/man/man8/puppet-man.8 +1 -1
  98. data/man/man8/puppet-master.8 +1 -1
  99. data/man/man8/puppet-module.8 +1 -1
  100. data/man/man8/puppet-node.8 +1 -1
  101. data/man/man8/puppet-parser.8 +1 -1
  102. data/man/man8/puppet-plugin.8 +1 -1
  103. data/man/man8/puppet-report.8 +1 -1
  104. data/man/man8/puppet-resource.8 +1 -1
  105. data/man/man8/puppet-script.8 +1 -1
  106. data/man/man8/puppet-status.8 +1 -1
  107. data/man/man8/puppet.8 +2 -2
  108. data/spec/fixtures/unit/provider/aix_object/aix_colon_list_real_world_input.out +1 -0
  109. data/spec/fixtures/unit/provider/aix_object/aix_colon_list_real_world_output.out +1 -0
  110. data/spec/fixtures/unit/provider/user/aix/aix_passwd_file.out +32 -0
  111. data/spec/integration/parser/collection_spec.rb +4 -8
  112. data/spec/integration/provider/service/windows_spec.rb +5 -5
  113. data/spec/integration/type/file_spec.rb +6 -6
  114. data/spec/integration/util/windows/adsi_spec.rb +6 -5
  115. data/spec/integration/util/windows/security_spec.rb +10 -7
  116. data/spec/integration/util/windows/user_spec.rb +37 -17
  117. data/spec/spec_helper.rb +0 -1
  118. data/spec/unit/application/apply_spec.rb +41 -2
  119. data/spec/unit/application/master_spec.rb +7 -0
  120. data/spec/unit/application_spec.rb +21 -3
  121. data/spec/unit/defaults_spec.rb +20 -0
  122. data/spec/unit/etc_spec.rb +25 -0
  123. data/spec/unit/file_serving/fileset_spec.rb +11 -11
  124. data/spec/unit/gettext/config_spec.rb +1 -1
  125. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +6 -6
  126. data/spec/unit/pops/loaders/loaders_spec.rb +40 -7
  127. data/spec/unit/pops/parser/parse_heredoc_spec.rb +16 -0
  128. data/spec/unit/pops/validator/validator_spec.rb +129 -10
  129. data/spec/unit/property/keyvalue_spec.rb +97 -6
  130. data/spec/unit/provider/aix_object_spec.rb +805 -0
  131. data/spec/unit/provider/group/aix_spec.rb +57 -0
  132. data/spec/unit/provider/group/pw_spec.rb +0 -6
  133. data/spec/unit/provider/group/windows_adsi_spec.rb +34 -35
  134. data/spec/unit/provider/nameservice/directoryservice_spec.rb +2 -2
  135. data/spec/unit/provider/package/windows/exe_package_spec.rb +3 -3
  136. data/spec/unit/provider/package/windows_spec.rb +4 -4
  137. data/spec/unit/provider/service/launchd_spec.rb +19 -0
  138. data/spec/unit/provider/service/windows_spec.rb +71 -78
  139. data/spec/unit/provider/user/aix_spec.rb +162 -116
  140. data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
  141. data/spec/unit/resource/catalog_spec.rb +2 -2
  142. data/spec/unit/ssl/certificate_authority_spec.rb +0 -1
  143. data/spec/unit/type/group_spec.rb +111 -13
  144. data/spec/unit/type/resources_spec.rb +18 -0
  145. data/spec/unit/util/execution_spec.rb +77 -0
  146. data/spec/unit/util/posix_spec.rb +28 -0
  147. data/spec/unit/util/storage_spec.rb +107 -0
  148. data/spec/unit/util/windows/adsi_spec.rb +108 -13
  149. data/spec/unit/util/windows/service_spec.rb +669 -0
  150. metadata +17 -5
  151. data/lib/puppet/provider/aixobject.rb +0 -392
  152. data/spec/unit/provider/aixobject_spec.rb +0 -101
@@ -92,6 +92,24 @@ describe resources do
92
92
  user.stubs(:retrieve_resource).returns Puppet::Resource.new("user", user_hash[:name], :parameters => user_hash)
93
93
  expect(res.user_check(user)).to be_falsey
94
94
  end
95
+
96
+ it "should not purge Windows system users" do
97
+ res = Puppet::Type.type(:resources).new :name => :user, :purge => true
98
+ res.catalog = Puppet::Resource::Catalog.new
99
+ user_hash = {:name => 'Administrator', :uid => 'S-1-5-21-12345-500'}
100
+ user = Puppet::Type.type(:user).new(user_hash)
101
+ user.stubs(:retrieve_resource).returns Puppet::Resource.new("user", user_hash[:name], :parameters => user_hash)
102
+ expect(res.user_check(user)).to be_falsey
103
+ end
104
+
105
+ it "should not purge Windows system users" do
106
+ res = Puppet::Type.type(:resources).new :name => :user, :purge => true
107
+ res.catalog = Puppet::Resource::Catalog.new
108
+ user_hash = {:name => 'other', :uid => 'S-1-5-21-12345-1001'}
109
+ user = Puppet::Type.type(:user).new(user_hash)
110
+ user.stubs(:retrieve_resource).returns Puppet::Resource.new("user", user_hash[:name], :parameters => user_hash)
111
+ expect(res.user_check(user)).to be_truthy
112
+ end
95
113
  end
96
114
 
97
115
  %w(FreeBSD OpenBSD).each do |os|
@@ -119,6 +119,17 @@ describe Puppet::Util::Execution do
119
119
  call_exec_posix("/bin/echo 'foo' ; \n /bin/echo 'bar' ;", {:uid => 50, :gid => 55}, @stdin, @stdout, @stderr)
120
120
  end
121
121
 
122
+ context 'cwd option' do
123
+ let(:cwd) { 'cwd' }
124
+
125
+ it 'should run the command in the specified working directory' do
126
+ Dir.expects(:chdir).with(cwd)
127
+ Kernel.expects(:exec).with('test command')
128
+
129
+ call_exec_posix('test command', { :cwd => cwd }, @stdin, @stdout, @stderr)
130
+ end
131
+ end
132
+
122
133
  it "should return the pid of the child process" do
123
134
  expect(call_exec_posix('test command', {}, @stdin, @stdout, @stderr)).to eq(pid)
124
135
  end
@@ -144,6 +155,42 @@ describe Puppet::Util::Execution do
144
155
  call_exec_windows('test command', {}, @stdin, @stdout, @stderr)
145
156
  end
146
157
 
158
+ context 'cwd option' do
159
+ let(:cwd) { 'cwd' }
160
+ it "should execute the command in the specified working directory" do
161
+ Dir.expects(:chdir).with(cwd).yields
162
+ Process.expects(:create).with(
163
+ :command_line => "test command",
164
+ :startup_info => {
165
+ :stdin => @stdin,
166
+ :stdout => @stdout,
167
+ :stderr => @stderr
168
+ },
169
+ :close_handles => false
170
+ )
171
+
172
+ call_exec_windows('test command', { :cwd => cwd }, @stdin, @stdout, @stderr)
173
+ end
174
+ end
175
+
176
+ context 'suppress_window option' do
177
+ let(:cwd) { 'cwd' }
178
+ it "should execute the command in the specified working directory" do
179
+ Process.expects(:create).with(
180
+ :command_line => "test command",
181
+ :startup_info => {
182
+ :stdin => @stdin,
183
+ :stdout => @stdout,
184
+ :stderr => @stderr
185
+ },
186
+ :close_handles => false,
187
+ :creation_flags => Puppet::Util::Windows::Process::CREATE_NO_WINDOW
188
+ )
189
+
190
+ call_exec_windows('test command', { :suppress_window => true }, @stdin, @stdout, @stderr)
191
+ end
192
+ end
193
+
147
194
  it "should return the process info of the child process" do
148
195
  expect(call_exec_windows('test command', {}, @stdin, @stdout, @stderr)).to eq(proc_info_stub)
149
196
  end
@@ -219,6 +266,36 @@ describe Puppet::Util::Execution do
219
266
  end
220
267
  end
221
268
 
269
+ describe "cwd option" do
270
+ def expect_cwd_to_be(cwd)
271
+ Puppet::Util::Execution.expects(executor).with(
272
+ anything,
273
+ has_entries(:cwd => cwd),
274
+ anything,
275
+ anything,
276
+ anything
277
+ ).returns(rval)
278
+ end
279
+
280
+ it 'should raise an ArgumentError if the specified working directory does not exist' do
281
+ cwd = 'cwd'
282
+ Puppet::FileSystem.stubs(:directory?).with(cwd).returns(false)
283
+
284
+ expect {
285
+ Puppet::Util::Execution.execute('test command', cwd: cwd)
286
+ }.to raise_error do |error|
287
+ expect(error).to be_a(ArgumentError)
288
+ expect(error.message).to match(cwd)
289
+ end
290
+ end
291
+
292
+ it "should set the cwd to the user-specified one" do
293
+ Puppet::FileSystem.stubs(:directory?).with('cwd').returns(true)
294
+ expect_cwd_to_be('cwd')
295
+ Puppet::Util::Execution.execute('test command', cwd: 'cwd')
296
+ end
297
+ end
298
+
222
299
  describe "on POSIX", :if => Puppet.features.posix? do
223
300
  describe "when squelch is not set" do
224
301
  it "should set stdout to a pipe" do
@@ -12,6 +12,34 @@ describe Puppet::Util::POSIX do
12
12
  @posix = PosixTest.new
13
13
  end
14
14
 
15
+ describe '.groups_of' do
16
+ let(:mock_groups) do
17
+ [
18
+ ['group1', ['user1', 'user2']],
19
+ ['group2', ['user2']],
20
+ ['group1', ['user1', 'user2']],
21
+ ['group3', ['user1']],
22
+ ['group4', ['user2']]
23
+ ].map do |(name, members)|
24
+ group_struct = stub("Group #{name}")
25
+ group_struct.stubs(:name).returns(name)
26
+ group_struct.stubs(:mem).returns(members)
27
+
28
+ group_struct
29
+ end
30
+ end
31
+
32
+ before(:each) do
33
+ Puppet::Etc.stubs(:group).multiple_yields(*mock_groups)
34
+ end
35
+
36
+ it 'returns the groups of the given user' do
37
+ expect(Puppet::Util::POSIX.groups_of('user1')).to eql(
38
+ ['group1', 'group3']
39
+ )
40
+ end
41
+ end
42
+
15
43
  [:group, :gr].each do |name|
16
44
  it "should return :gid as the field for #{name}" do
17
45
  expect(@posix.idfield(name)).to eq(:gid)
@@ -213,5 +213,112 @@ describe Puppet::Util::Storage do
213
213
 
214
214
  expect(Puppet::Util::Storage.state).to eq({:yayness=>{}})
215
215
  end
216
+
217
+ it "expires entries with a :checked older than statettl seconds ago" do
218
+ Puppet[:statettl] = '1d'
219
+ recent_checked = Time.now
220
+ stale_checked = Time.now - (Puppet[:statettl] + 1)
221
+ Puppet::Util::Storage.cache(:yayness)[:checked] = recent_checked
222
+ Puppet::Util::Storage.cache(:stale)[:checked] = stale_checked
223
+ expect(Puppet::Util::Storage.state).to eq(
224
+ {
225
+ :yayness => {
226
+ :checked => recent_checked
227
+ },
228
+ :stale => {
229
+ :checked => stale_checked
230
+ }
231
+ }
232
+ )
233
+
234
+ Puppet::Util::Storage.store
235
+ Puppet::Util::Storage.clear
236
+
237
+ expect(Puppet::Util::Storage.state).to eq({})
238
+
239
+ Puppet::Util::Storage.load
240
+
241
+ expect(Puppet::Util::Storage.state).to eq(
242
+ {
243
+ :yayness => {
244
+ :checked => recent_checked
245
+ }
246
+ }
247
+ )
248
+ end
249
+
250
+
251
+ it "does not expire entries when statettl is 0" do
252
+ Puppet[:statettl] = '0'
253
+ recent_checked = Time.now
254
+ older_checked = Time.now - 10_000_000
255
+ Puppet::Util::Storage.cache(:yayness)[:checked] = recent_checked
256
+ Puppet::Util::Storage.cache(:older)[:checked] = older_checked
257
+ expect(Puppet::Util::Storage.state).to eq(
258
+ {
259
+ :yayness => {
260
+ :checked => recent_checked
261
+ },
262
+ :older => {
263
+ :checked => older_checked
264
+ }
265
+ }
266
+ )
267
+
268
+ Puppet::Util::Storage.store
269
+ Puppet::Util::Storage.clear
270
+
271
+ expect(Puppet::Util::Storage.state).to eq({})
272
+
273
+ Puppet::Util::Storage.load
274
+
275
+ expect(Puppet::Util::Storage.state).to eq(
276
+ {
277
+ :yayness => {
278
+ :checked => recent_checked
279
+ },
280
+ :older => {
281
+ :checked => older_checked
282
+ }
283
+ }
284
+ )
285
+ end
286
+
287
+
288
+ it "does not expire entries when statettl is 'unlimited'" do
289
+ Puppet[:statettl] = 'unlimited'
290
+ recent_checked = Time.now
291
+ older_checked = Time.now - 10_000_000
292
+ Puppet::Util::Storage.cache(:yayness)[:checked] = recent_checked
293
+ Puppet::Util::Storage.cache(:older)[:checked] = older_checked
294
+ expect(Puppet::Util::Storage.state).to eq(
295
+ {
296
+ :yayness => {
297
+ :checked => recent_checked
298
+ },
299
+ :older => {
300
+ :checked => older_checked
301
+ }
302
+ }
303
+ )
304
+
305
+ Puppet::Util::Storage.store
306
+ Puppet::Util::Storage.clear
307
+
308
+ expect(Puppet::Util::Storage.state).to eq({})
309
+
310
+ Puppet::Util::Storage.load
311
+
312
+ expect(Puppet::Util::Storage.state).to eq(
313
+ {
314
+ :yayness => {
315
+ :checked => recent_checked
316
+ },
317
+ :older => {
318
+ :checked => older_checked
319
+ }
320
+ }
321
+ )
322
+ end
216
323
  end
217
324
  end
@@ -102,7 +102,7 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
102
102
  user = Puppet::Util::Windows::ADSI::User.create(username)
103
103
 
104
104
  expect(user).to be_a(Puppet::Util::Windows::ADSI::User)
105
- expect(user.native_user).to eq(adsi_user)
105
+ expect(user.native_object).to eq(adsi_user)
106
106
  end
107
107
 
108
108
  it "should be able to check the existence of a user" do
@@ -152,10 +152,10 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
152
152
  wmi_users = [stub('WMI', :name => name)]
153
153
  Puppet::Util::Windows::ADSI.expects(:execquery).with('select name from win32_useraccount where localaccount = "TRUE"').returns(wmi_users)
154
154
 
155
- native_user = stub('IADsUser')
155
+ native_object = stub('IADsUser')
156
156
  homedir = "C:\\Users\\#{name}"
157
- native_user.expects(:Get).with('HomeDirectory').returns(homedir)
158
- Puppet::Util::Windows::ADSI.expects(:connect).with("WinNT://./#{name},user").returns(native_user)
157
+ native_object.expects(:Get).with('HomeDirectory').returns(homedir)
158
+ Puppet::Util::Windows::ADSI.expects(:connect).with("WinNT://./#{name},user").returns(native_object)
159
159
 
160
160
  users = Puppet::Util::Windows::ADSI::User.to_a
161
161
  expect(users.length).to eq(1)
@@ -264,6 +264,101 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
264
264
  end
265
265
  end
266
266
  end
267
+
268
+ describe 'userflags' do
269
+ # Avoid having to type out the constant everytime we want to
270
+ # retrieve a userflag's value.
271
+ def ads_userflags(flag)
272
+ Puppet::Util::Windows::ADSI::User::ADS_USERFLAGS[flag]
273
+ end
274
+
275
+ before(:each) do
276
+ userflags = [
277
+ :ADS_UF_SCRIPT,
278
+ :ADS_UF_ACCOUNTDISABLE,
279
+ :ADS_UF_HOMEDIR_REQUIRED,
280
+ :ADS_UF_LOCKOUT
281
+ ].inject(0) do |flags, flag|
282
+ flags | ads_userflags(flag)
283
+ end
284
+
285
+ user.stubs(:[]).with('UserFlags').returns(userflags)
286
+ end
287
+
288
+ describe '#userflag_set?' do
289
+ it 'returns true if the specified userflag is set' do
290
+ expect(user.userflag_set?(:ADS_UF_SCRIPT)).to be true
291
+ end
292
+
293
+ it 'returns false if the specified userflag is not set' do
294
+ expect(user.userflag_set?(:ADS_UF_PASSWD_NOTREQD)).to be false
295
+ end
296
+
297
+ it 'returns false if the specified userflag is an unrecognized userflag' do
298
+ expect(user.userflag_set?(:ADS_UF_UNRECOGNIZED_FLAG)).to be false
299
+ end
300
+ end
301
+
302
+ shared_examples 'set/unset common tests' do |method|
303
+ it 'raises an ArgumentError for any unrecognized userflags' do
304
+ unrecognized_flags = [
305
+ :ADS_UF_UNRECOGNIZED_FLAG_ONE,
306
+ :ADS_UF_UNRECOGNIZED_FLAG_TWO
307
+ ]
308
+ input_flags = unrecognized_flags + [
309
+ :ADS_UF_PASSWORD_EXPIRED,
310
+ :ADS_UF_DONT_EXPIRE_PASSWD
311
+ ]
312
+
313
+ expect { user.send(method, *input_flags) }.to raise_error(
314
+ ArgumentError, /#{unrecognized_flags.join(', ')}/
315
+ )
316
+ end
317
+
318
+ it 'noops if no userflags are passed-in' do
319
+ user.expects(:[]=).never
320
+ user.expects(:commit).never
321
+
322
+ user.send(method)
323
+ end
324
+ end
325
+
326
+ describe '#set_userflags' do
327
+ include_examples 'set/unset common tests', :set_userflags
328
+
329
+ it 'should add the passed-in flags to the current set of userflags' do
330
+ input_flags = [
331
+ :ADS_UF_PASSWORD_EXPIRED,
332
+ :ADS_UF_DONT_EXPIRE_PASSWD
333
+ ]
334
+
335
+ userflags = user['UserFlags']
336
+ expected_userflags = userflags | ads_userflags(input_flags[0]) | ads_userflags(input_flags[1])
337
+
338
+ user.expects(:[]=).with('UserFlags', expected_userflags)
339
+
340
+ user.set_userflags(*input_flags)
341
+ end
342
+ end
343
+
344
+ describe '#unset_userflags' do
345
+ include_examples 'set/unset common tests', :unset_userflags
346
+
347
+ it 'should remove the passed-in flags from the current set of userflags' do
348
+ input_flags = [
349
+ :ADS_UF_SCRIPT,
350
+ :ADS_UF_ACCOUNTDISABLE
351
+ ]
352
+
353
+ # ADS_UF_HOMEDIR_REQUIRED and ADS_UF_LOCKOUT should be the only flags set.
354
+ expected_userflags = 0 | ads_userflags(:ADS_UF_HOMEDIR_REQUIRED) | ads_userflags(:ADS_UF_LOCKOUT)
355
+
356
+ user.expects(:[]=).with('UserFlags', expected_userflags)
357
+
358
+ user.unset_userflags(*input_flags)
359
+ end
360
+ end
361
+ end
267
362
  end
268
363
  end
269
364
 
@@ -338,7 +433,7 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
338
433
  adsi_group.expects(:Remove).with('WinNT://DOMAIN/user1,user')
339
434
  adsi_group.expects(:Add).with('WinNT://DOMAIN2/user3,user')
340
435
 
341
- group.set_members(['user2', 'DOMAIN2\user3'])
436
+ group.set_members('user2,DOMAIN2\user3')
342
437
  end
343
438
 
344
439
  it "should add the desired_members to an existing group when not inclusive" do
@@ -365,7 +460,7 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
365
460
 
366
461
  adsi_group.expects(:Add).with('WinNT://DOMAIN2/user3,user')
367
462
 
368
- group.set_members(['user2', 'DOMAIN2\user3'],false)
463
+ group.set_members('user2,DOMAIN2\user3',false)
369
464
  end
370
465
 
371
466
  it "should return immediately when desired_members is nil" do
@@ -397,7 +492,7 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
397
492
  adsi_group.expects(:Remove).with('WinNT://DOMAIN/user1,user')
398
493
  adsi_group.expects(:Remove).with('WinNT://testcomputername/user2,user')
399
494
 
400
- group.set_members([])
495
+ group.set_members('')
401
496
  end
402
497
 
403
498
  it "should do nothing when desired_members is empty and not inclusive" do
@@ -416,13 +511,13 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
416
511
  adsi_group.expects(:Remove).never
417
512
  adsi_group.expects(:Add).never
418
513
 
419
- group.set_members([],false)
514
+ group.set_members('',false)
420
515
  end
421
516
 
422
517
  it "should raise an error when a username does not resolve to a SID" do
423
518
  expect {
424
519
  adsi_group.expects(:Members).returns []
425
- group.set_members(['foobar'])
520
+ group.set_members('foobar')
426
521
  }.to raise_error(Puppet::Error, /Could not resolve name: foobar/)
427
522
  end
428
523
  end
@@ -457,7 +552,7 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
457
552
  group = Puppet::Util::Windows::ADSI::Group.create(groupname)
458
553
 
459
554
  expect(group).to be_a(Puppet::Util::Windows::ADSI::Group)
460
- expect(group.native_group).to eq(adsi_group)
555
+ expect(group.native_object).to eq(adsi_group)
461
556
  end
462
557
 
463
558
  it "should be able to confirm the existence of a group" do
@@ -502,10 +597,10 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
502
597
  wmi_groups = [stub('WMI', :name => name)]
503
598
  Puppet::Util::Windows::ADSI.expects(:execquery).with('select name from win32_group where localaccount = "TRUE"').returns(wmi_groups)
504
599
 
505
- native_group = stub('IADsGroup')
600
+ native_object = stub('IADsGroup')
506
601
  Puppet::Util::Windows::SID.expects(:octet_string_to_principal).with([]).returns(stub(:domain_account => '.\Administrator'))
507
- native_group.expects(:Members).returns([stub(:Name => 'Administrator', :objectSID => [], :ole_respond_to? => true)])
508
- Puppet::Util::Windows::ADSI.expects(:connect).with("WinNT://./#{name},group").returns(native_group)
602
+ native_object.expects(:Members).returns([stub(:Name => 'Administrator', :objectSID => [], :ole_respond_to? => true)])
603
+ Puppet::Util::Windows::ADSI.expects(:connect).with("WinNT://./#{name},group").returns(native_object)
509
604
 
510
605
  groups = Puppet::Util::Windows::ADSI::Group.to_a
511
606
  expect(groups.length).to eq(1)