puppet 4.10.10-x86-mingw32 → 4.10.11-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 (84) hide show
  1. data/CONTRIBUTING.md +15 -15
  2. data/Gemfile +3 -0
  3. data/README.md +11 -11
  4. data/ext/project_data.yaml +4 -2
  5. data/lib/puppet/application/agent.rb +1 -3
  6. data/lib/puppet/application/apply.rb +1 -3
  7. data/lib/puppet/application/cert.rb +6 -1
  8. data/lib/puppet/application/lookup.rb +11 -1
  9. data/lib/puppet/configurer.rb +17 -4
  10. data/lib/puppet/environments.rb +1 -1
  11. data/lib/puppet/functions/map.rb +1 -1
  12. data/lib/puppet/indirector/indirection.rb +3 -3
  13. data/lib/puppet/indirector/request.rb +6 -2
  14. data/lib/puppet/network/http/connection.rb +8 -0
  15. data/lib/puppet/parser/functions/new.rb +29 -44
  16. data/lib/puppet/parser/functions/return.rb +22 -1
  17. data/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
  18. data/lib/puppet/provider/group/windows_adsi.rb +4 -7
  19. data/lib/puppet/provider/package/dnf.rb +1 -1
  20. data/lib/puppet/provider/service/systemd.rb +1 -1
  21. data/lib/puppet/provider/user/aix.rb +1 -1
  22. data/lib/puppet/provider/user/windows_adsi.rb +1 -1
  23. data/lib/puppet/reference/configuration.rb +2 -0
  24. data/lib/puppet/type/tidy.rb +8 -1
  25. data/lib/puppet/type/user.rb +34 -3
  26. data/lib/puppet/util/reference.rb +2 -9
  27. data/lib/puppet/util/windows/adsi.rb +28 -31
  28. data/lib/puppet/util/windows/file.rb +61 -9
  29. data/lib/puppet/util/windows/principal.rb +9 -7
  30. data/lib/puppet/util/windows/sid.rb +60 -7
  31. data/lib/puppet/version.rb +1 -1
  32. data/locales/puppet.pot +79 -11
  33. data/man/man5/puppet.conf.5 +6 -8
  34. data/man/man8/extlookup2hiera.8 +1 -1
  35. data/man/man8/puppet-agent.8 +1 -1
  36. data/man/man8/puppet-apply.8 +1 -1
  37. data/man/man8/puppet-ca.8 +1 -1
  38. data/man/man8/puppet-catalog.8 +1 -1
  39. data/man/man8/puppet-cert.8 +1 -1
  40. data/man/man8/puppet-certificate.8 +1 -1
  41. data/man/man8/puppet-certificate_request.8 +1 -1
  42. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  43. data/man/man8/puppet-config.8 +1 -1
  44. data/man/man8/puppet-describe.8 +1 -1
  45. data/man/man8/puppet-device.8 +1 -1
  46. data/man/man8/puppet-doc.8 +1 -1
  47. data/man/man8/puppet-epp.8 +1 -1
  48. data/man/man8/puppet-facts.8 +1 -1
  49. data/man/man8/puppet-file.8 +1 -1
  50. data/man/man8/puppet-filebucket.8 +1 -1
  51. data/man/man8/puppet-generate.8 +1 -1
  52. data/man/man8/puppet-help.8 +1 -1
  53. data/man/man8/puppet-inspect.8 +1 -1
  54. data/man/man8/puppet-key.8 +1 -1
  55. data/man/man8/puppet-lookup.8 +1 -1
  56. data/man/man8/puppet-man.8 +1 -1
  57. data/man/man8/puppet-master.8 +1 -1
  58. data/man/man8/puppet-module.8 +1 -1
  59. data/man/man8/puppet-node.8 +1 -1
  60. data/man/man8/puppet-parser.8 +1 -1
  61. data/man/man8/puppet-plugin.8 +1 -1
  62. data/man/man8/puppet-report.8 +1 -1
  63. data/man/man8/puppet-resource.8 +1 -1
  64. data/man/man8/puppet-resource_type.8 +1 -1
  65. data/man/man8/puppet-status.8 +1 -1
  66. data/man/man8/puppet.8 +2 -2
  67. data/spec/integration/application/lookup_spec.rb +21 -0
  68. data/spec/integration/parser/pcore_resource_spec.rb +1 -1
  69. data/spec/integration/util/windows/adsi_spec.rb +86 -1
  70. data/spec/integration/util/windows/principal_spec.rb +10 -1
  71. data/spec/unit/application/agent_spec.rb +0 -9
  72. data/spec/unit/application/apply_spec.rb +0 -9
  73. data/spec/unit/application/cert_spec.rb +40 -1
  74. data/spec/unit/configurer_spec.rb +14 -0
  75. data/spec/unit/indirector/indirection_spec.rb +24 -2
  76. data/spec/unit/provider/group/windows_adsi_spec.rb +79 -22
  77. data/spec/unit/provider/service/systemd_spec.rb +1 -1
  78. data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
  79. data/spec/unit/type/tidy_spec.rb +14 -0
  80. data/spec/unit/util/windows/adsi_spec.rb +31 -27
  81. data/spec/unit/util/windows/sid_spec.rb +86 -15
  82. data/tasks/manpages.rake +1 -1
  83. metadata +3639 -3613
  84. checksums.yaml +0 -7
@@ -139,7 +139,7 @@ describe Puppet::Application::Cert => true do
139
139
  describe "when running" do
140
140
  before :each do
141
141
  @cert_app.all = false
142
- @ca = stub_everything 'ca'
142
+ @ca = stub_everything( 'ca', :waiting? => ['unsigned-node'] )
143
143
  @cert_app.ca = @ca
144
144
  @cert_app.command_line.stubs(:args).returns([])
145
145
  @iface = stub_everything 'iface'
@@ -186,6 +186,45 @@ describe Puppet::Application::Cert => true do
186
186
 
187
187
  @cert_app.main
188
188
  end
189
+
190
+ it "should not revoke cert if node does not have a signed certificate" do
191
+ @cert_app.subcommand = :destroy
192
+ @cert_app.command_line.stubs(:args).returns(["unsigned-node"])
193
+
194
+ Puppet::SSL::CertificateAuthority::Interface.unstub(:new)
195
+ Puppet::SSL::CertificateAuthority::Interface.expects(:new).with(:revoke, anything).never
196
+ Puppet::SSL::CertificateAuthority::Interface.expects(:new).with(:destroy, {:to => ['unsigned-node'], :digest => nil}).returns(@iface)
197
+
198
+ @cert_app.main
199
+ end
200
+
201
+ it "should only revoke signed certificate and destroy certificate signing requests" do
202
+ @cert_app.subcommand = :destroy
203
+ @cert_app.command_line.stubs(:args).returns(["host","unsigned-node"])
204
+
205
+ Puppet::SSL::CertificateAuthority::Interface.expects(:new).returns(@iface).with { |cert_mode,to|
206
+ cert_mode == :revoke
207
+ to[:to] == ["host"]
208
+ }
209
+ Puppet::SSL::CertificateAuthority::Interface.expects(:new).returns(@iface).with { |cert_mode,to|
210
+ cert_mode == :destroy
211
+ to[:to] == ["host","unsigned-node"]
212
+ }
213
+
214
+ @cert_app.main
215
+ end
216
+
217
+ it "should refuse to destroy all certificates" do
218
+ @cert_app.subcommand = :destroy
219
+ @cert_app.all = true
220
+
221
+ Puppet::SSL::CertificateAuthority::Interface.unstub(:new)
222
+ Puppet::SSL::CertificateAuthority::Interface.expects(:new).never
223
+
224
+ Puppet.expects(:log_exception).with {|e| e.message == "Refusing to destroy all certs, provide an explicit list of certs to destroy"}
225
+
226
+ expect { @cert_app.main }.to exit_with(24)
227
+ end
189
228
  end
190
229
 
191
230
  describe "when identifying subcommands" do
@@ -860,6 +860,20 @@ describe Puppet::Configurer do
860
860
  @agent.retrieve_catalog({})
861
861
  expect(@agent.instance_variable_get(:@cached_catalog_status)).to eq('on_failure')
862
862
  end
863
+
864
+ it "should not update the cached catalog in noop mode" do
865
+ Puppet[:noop] = true
866
+ Puppet::Resource::Catalog.indirection.expects(:find).with(anything, has_entries(:ignore_cache => true, :ignore_cache_save => true)).returns(@catalog)
867
+
868
+ @agent.retrieve_catalog({})
869
+ end
870
+
871
+ it "should update the cached catalog when not in noop mode" do
872
+ Puppet[:noop] = false
873
+ Puppet::Resource::Catalog.indirection.expects(:find).with(anything, has_entries(:ignore_cache => true, :ignore_cache_save => false)).returns(@catalog)
874
+
875
+ @agent.retrieve_catalog({})
876
+ end
863
877
  end
864
878
 
865
879
  describe "when converting the catalog" do
@@ -294,6 +294,14 @@ describe Puppet::Indirector::Indirection do
294
294
  @indirection.find("/my/key", :ignore_cache => true)
295
295
  end
296
296
 
297
+ it "should not save to the cache if told to skip updating the cache" do
298
+ @terminus.expects(:find).returns @instance
299
+ @cache.expects(:find).returns nil
300
+ @cache.expects(:save).never
301
+
302
+ @indirection.find("/my/key", :ignore_cache_save => true)
303
+ end
304
+
297
305
  it "should only look in the cache if the request specifies not to use the terminus" do
298
306
  @terminus.expects(:find).never
299
307
  @cache.expects(:find)
@@ -494,7 +502,7 @@ describe Puppet::Indirector::Indirection do
494
502
  end
495
503
 
496
504
  it "should return the result of saving to the terminus" do
497
- request = stub 'request', :instance => @instance, :node => nil
505
+ request = stub 'request', :instance => @instance, :node => nil, :ignore_cache_save? => false
498
506
 
499
507
  @indirection.expects(:request).returns request
500
508
 
@@ -504,7 +512,7 @@ describe Puppet::Indirector::Indirection do
504
512
  end
505
513
 
506
514
  it "should use a request to save the object to the cache" do
507
- request = stub 'request', :instance => @instance, :node => nil
515
+ request = stub 'request', :instance => @instance, :node => nil, :ignore_cache_save? => false
508
516
 
509
517
  @indirection.expects(:request).returns request
510
518
 
@@ -522,6 +530,13 @@ describe Puppet::Indirector::Indirection do
522
530
  @terminus.expects(:save).raises "eh"
523
531
  expect { @indirection.save(@instance) }.to raise_error(RuntimeError, /eh/)
524
532
  end
533
+
534
+ it "should not save to the cache if told to ignore saving to the cache" do
535
+ @terminus.expects(:save)
536
+ @cache.expects(:save).never
537
+
538
+ @indirection.save(@instance, '/my/key', :ignore_cache_save => true)
539
+ end
525
540
  end
526
541
  end
527
542
 
@@ -657,6 +672,13 @@ describe Puppet::Indirector::Indirection do
657
672
  @indirection.expire("/my/key")
658
673
  end
659
674
 
675
+ it "does not expire an instance if told to skip cache saving" do
676
+ @indirection.cache.expects(:find).never
677
+ @indirection.cache.expects(:save).never
678
+
679
+ @indirection.expire("/my/key", :ignore_cache_save => true)
680
+ end
681
+
660
682
  it "should use a request to save the expired resource to the cache" do
661
683
  @cache.expects(:find).returns @cached
662
684
 
@@ -40,23 +40,36 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
40
40
  let(:invalid_user) { SecureRandom.uuid }
41
41
 
42
42
  before :each do
43
- Puppet::Util::Windows::SID.stubs(:name_to_sid_object).with('user1').returns(user1)
44
- Puppet::Util::Windows::SID.stubs(:name_to_sid_object).with('user2').returns(user2)
45
- Puppet::Util::Windows::SID.stubs(:name_to_sid_object).with('user3').returns(user3)
46
- Puppet::Util::Windows::SID.stubs(:name_to_sid_object).with(invalid_user).returns(nil)
43
+ Puppet::Util::Windows::SID.stubs(:name_to_principal).with('user1').returns(user1)
44
+ Puppet::Util::Windows::SID.stubs(:name_to_principal).with('user2').returns(user2)
45
+ Puppet::Util::Windows::SID.stubs(:name_to_principal).with('user3').returns(user3)
46
+ Puppet::Util::Windows::SID.stubs(:name_to_principal).with(invalid_user).returns(nil)
47
47
  end
48
48
 
49
49
  describe "#members_insync?" do
50
50
  it "should return true for same lists of members" do
51
- expect(provider.members_insync?(['user1', 'user2'], ['user1', 'user2'])).to be_truthy
51
+ current = [
52
+ Puppet::Util::Windows::SID.name_to_principal('user1'),
53
+ Puppet::Util::Windows::SID.name_to_principal('user2'),
54
+ ]
55
+ expect(provider.members_insync?(current, ['user1', 'user2'])).to be_truthy
52
56
  end
53
57
 
54
58
  it "should return true for same lists of unordered members" do
55
- expect(provider.members_insync?(['user1', 'user2'], ['user2', 'user1'])).to be_truthy
59
+ current = [
60
+ Puppet::Util::Windows::SID.name_to_principal('user1'),
61
+ Puppet::Util::Windows::SID.name_to_principal('user2'),
62
+ ]
63
+ expect(provider.members_insync?(current, ['user2', 'user1'])).to be_truthy
56
64
  end
57
65
 
58
66
  it "should return true for same lists of members irrespective of duplicates" do
59
- expect(provider.members_insync?(['user1', 'user2', 'user2'], ['user2', 'user1', 'user1'])).to be_truthy
67
+ current = [
68
+ Puppet::Util::Windows::SID.name_to_principal('user1'),
69
+ Puppet::Util::Windows::SID.name_to_principal('user2'),
70
+ Puppet::Util::Windows::SID.name_to_principal('user2'),
71
+ ]
72
+ expect(provider.members_insync?(current, ['user2', 'user1', 'user1'])).to be_truthy
60
73
  end
61
74
 
62
75
  it "should return true when current and should members are empty lists" do
@@ -77,7 +90,12 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
77
90
  end
78
91
 
79
92
  it "should return true when current and should contain the same users in a different order" do
80
- expect(provider.members_insync?(['user1', 'user2', 'user3'], ['user3', 'user1', 'user2'])).to be_truthy
93
+ current = [
94
+ Puppet::Util::Windows::SID.name_to_principal('user1'),
95
+ Puppet::Util::Windows::SID.name_to_principal('user2'),
96
+ Puppet::Util::Windows::SID.name_to_principal('user3'),
97
+ ]
98
+ expect(provider.members_insync?(current, ['user3', 'user1', 'user2'])).to be_truthy
81
99
  end
82
100
 
83
101
  it "should return false when current is nil" do
@@ -85,15 +103,24 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
85
103
  end
86
104
 
87
105
  it "should return false when should is nil" do
88
- expect(provider.members_insync?(['user1'], nil)).to be_falsey
106
+ current = [
107
+ Puppet::Util::Windows::SID.name_to_principal('user1'),
108
+ ]
109
+ expect(provider.members_insync?(current, nil)).to be_falsey
89
110
  end
90
111
 
91
112
  it "should return false when current contains different users than should" do
92
- expect(provider.members_insync?(['user1'], ['user2'])).to be_falsey
113
+ current = [
114
+ Puppet::Util::Windows::SID.name_to_principal('user1'),
115
+ ]
116
+ expect(provider.members_insync?(current, ['user2'])).to be_falsey
93
117
  end
94
118
 
95
119
  it "should return false when current contains members and should is empty" do
96
- expect(provider.members_insync?(['user1'], [])).to be_falsey
120
+ current = [
121
+ Puppet::Util::Windows::SID.name_to_principal('user1'),
122
+ ]
123
+ expect(provider.members_insync?(current, [])).to be_falsey
97
124
  end
98
125
 
99
126
  it "should return false when current is empty and should contains members" do
@@ -101,11 +128,19 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
101
128
  end
102
129
 
103
130
  it "should return false when should user(s) are not the only items in the current" do
104
- expect(provider.members_insync?(['user1', 'user2'], ['user1'])).to be_falsey
131
+ current = [
132
+ Puppet::Util::Windows::SID.name_to_principal('user1'),
133
+ Puppet::Util::Windows::SID.name_to_principal('user2'),
134
+ ]
135
+ expect(provider.members_insync?(current, ['user1'])).to be_falsey
105
136
  end
106
137
 
107
138
  it "should return false when current user(s) is not empty and should is an empty list" do
108
- expect(provider.members_insync?(['user1','user2'], [])).to be_falsey
139
+ current = [
140
+ Puppet::Util::Windows::SID.name_to_principal('user1'),
141
+ Puppet::Util::Windows::SID.name_to_principal('user2'),
142
+ ]
143
+ expect(provider.members_insync?(current, [])).to be_falsey
109
144
  end
110
145
  end
111
146
 
@@ -120,15 +155,24 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
120
155
  end
121
156
 
122
157
  it "should return true when should is nil" do
123
- expect(provider.members_insync?(['user1'], nil)).to be_truthy
158
+ current = [
159
+ Puppet::Util::Windows::SID.name_to_principal('user1'),
160
+ ]
161
+ expect(provider.members_insync?(current, nil)).to be_truthy
124
162
  end
125
163
 
126
164
  it "should return false when current contains different users than should" do
127
- expect(provider.members_insync?(['user1'], ['user2'])).to be_falsey
165
+ current = [
166
+ Puppet::Util::Windows::SID.name_to_principal('user1'),
167
+ ]
168
+ expect(provider.members_insync?(current, ['user2'])).to be_falsey
128
169
  end
129
170
 
130
171
  it "should return true when current contains members and should is empty" do
131
- expect(provider.members_insync?(['user1'], [])).to be_truthy
172
+ current = [
173
+ Puppet::Util::Windows::SID.name_to_principal('user1'),
174
+ ]
175
+ expect(provider.members_insync?(current, [])).to be_truthy
132
176
  end
133
177
 
134
178
  it "should return false when current is empty and should contains members" do
@@ -136,15 +180,28 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
136
180
  end
137
181
 
138
182
  it "should return true when current user(s) contains at least the should list" do
139
- expect(provider.members_insync?(['user1','user2'], ['user1'])).to be_truthy
183
+ current = [
184
+ Puppet::Util::Windows::SID.name_to_principal('user1'),
185
+ Puppet::Util::Windows::SID.name_to_principal('user2'),
186
+ ]
187
+ expect(provider.members_insync?(current, ['user1'])).to be_truthy
140
188
  end
141
189
 
142
190
  it "should return true when current user(s) is not empty and should is an empty list" do
143
- expect(provider.members_insync?(['user1','user2'], [])).to be_truthy
191
+ current = [
192
+ Puppet::Util::Windows::SID.name_to_principal('user1'),
193
+ Puppet::Util::Windows::SID.name_to_principal('user2'),
194
+ ]
195
+ expect(provider.members_insync?(current, [])).to be_truthy
144
196
  end
145
197
 
146
198
  it "should return true when current user(s) contains at least the should list, even unordered" do
147
- expect(provider.members_insync?(['user3','user1','user2'], ['user2','user1'])).to be_truthy
199
+ current = [
200
+ Puppet::Util::Windows::SID.name_to_principal('user3'),
201
+ Puppet::Util::Windows::SID.name_to_principal('user1'),
202
+ Puppet::Util::Windows::SID.name_to_principal('user2'),
203
+ ]
204
+ expect(provider.members_insync?(current, ['user2','user1'])).to be_truthy
148
205
  end
149
206
  end
150
207
  end
@@ -196,8 +253,8 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
196
253
 
197
254
  provider.group.stubs(:member_sids).returns(member_sids[0..1])
198
255
 
199
- Puppet::Util::Windows::SID.expects(:name_to_sid_object).with('user2').returns(member_sids[1])
200
- Puppet::Util::Windows::SID.expects(:name_to_sid_object).with('user3').returns(member_sids[2])
256
+ Puppet::Util::Windows::SID.expects(:name_to_principal).with('user2').returns(member_sids[1])
257
+ Puppet::Util::Windows::SID.expects(:name_to_principal).with('user3').returns(member_sids[2])
201
258
 
202
259
  provider.group.expects(:remove_member_sids).with(member_sids[0])
203
260
  provider.group.expects(:add_member_sids).with(member_sids[2])
@@ -247,7 +304,7 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
247
304
  end
248
305
 
249
306
  it "should be able to test whether a group exists" do
250
- Puppet::Util::Windows::SID.stubs(:name_to_sid_object).returns(nil)
307
+ Puppet::Util::Windows::SID.stubs(:name_to_principal).returns(nil)
251
308
  Puppet::Util::Windows::ADSI.stubs(:connect).returns stub('connection', :Class => 'Group')
252
309
  expect(provider).to be_exists
253
310
 
@@ -126,7 +126,7 @@ describe Puppet::Type.type(:service).provider(:systemd) do
126
126
  expect(described_class).not_to be_default
127
127
  end
128
128
 
129
- [ '15.04', '15.10', '16.04', '16.10' ].each do |ver|
129
+ [ '15.04', '15.10', '16.04', '16.10', '17.04', '17.10' ].each do |ver|
130
130
  it "should be the default provider on ubuntu#{ver}" do
131
131
  Facter.stubs(:value).with(:osfamily).returns(:debian)
132
132
  Facter.stubs(:value).with(:operatingsystem).returns(:ubuntu)
@@ -81,9 +81,9 @@ describe Puppet::Type.type(:user).provider(:windows_adsi), :if => Puppet.feature
81
81
  let(:group3) { stub(:account => 'group3', :domain => '.', :sid => 'group3sid') }
82
82
 
83
83
  before :each do
84
- Puppet::Util::Windows::SID.stubs(:name_to_sid_object).with('group1').returns(group1)
85
- Puppet::Util::Windows::SID.stubs(:name_to_sid_object).with('group2').returns(group2)
86
- Puppet::Util::Windows::SID.stubs(:name_to_sid_object).with('group3').returns(group3)
84
+ Puppet::Util::Windows::SID.stubs(:name_to_principal).with('group1').returns(group1)
85
+ Puppet::Util::Windows::SID.stubs(:name_to_principal).with('group2').returns(group2)
86
+ Puppet::Util::Windows::SID.stubs(:name_to_principal).with('group3').returns(group3)
87
87
  end
88
88
 
89
89
  it "should return true for same lists of members" do
@@ -267,7 +267,7 @@ describe Puppet::Type.type(:user).provider(:windows_adsi), :if => Puppet.feature
267
267
  end
268
268
 
269
269
  it 'should be able to test whether a user exists' do
270
- Puppet::Util::Windows::SID.stubs(:name_to_sid_object).returns(nil)
270
+ Puppet::Util::Windows::SID.stubs(:name_to_principal).returns(nil)
271
271
  Puppet::Util::Windows::ADSI.stubs(:connect).returns stub('connection', :Class => 'User')
272
272
  expect(provider).to be_exists
273
273
 
@@ -440,6 +440,20 @@ describe tidy do
440
440
  result = @tidy.generate.inject({}) { |hash, res| hash[res[:path]] = res; hash }
441
441
  expect(result[@basepath + '/a'][:require].collect{|a| a.name[('File//a/' + @basepath).length..-1]}.join()).to eq('321')
442
442
  end
443
+
444
+ it "generates resources whose noop parameter matches the managed resource's noop parameter" do
445
+ @tidy[:recurse] = true
446
+ @tidy[:noop] = true
447
+
448
+ fileset = mock 'fileset'
449
+ Puppet::FileServing::Fileset.expects(:new).with(@basepath, :recurse => true).returns fileset
450
+ fileset.expects(:files).returns %w{. a a/2 a/1 a/3}
451
+ @tidy.stubs(:tidy?).returns true
452
+
453
+ result = @tidy.generate.inject({}) { |hash, res| hash[res[:path]] = res; hash }
454
+
455
+ expect(result.values).to all(be_noop)
456
+ end
443
457
  end
444
458
 
445
459
  def lstat_is(path, stat)
@@ -106,14 +106,14 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
106
106
  end
107
107
 
108
108
  it "should be able to check the existence of a user" do
109
- Puppet::Util::Windows::SID.expects(:name_to_sid_object).with(username).returns nil
109
+ Puppet::Util::Windows::SID.expects(:name_to_principal).with(username).returns nil
110
110
  Puppet::Util::Windows::ADSI.expects(:connect).with("WinNT://./#{username},user").returns connection
111
111
  connection.expects(:Class).returns('User')
112
112
  expect(Puppet::Util::Windows::ADSI::User.exists?(username)).to be_truthy
113
113
  end
114
114
 
115
115
  it "should be able to check the existence of a domain user" do
116
- Puppet::Util::Windows::SID.expects(:name_to_sid_object).with("#{domain}\\#{username}").returns nil
116
+ Puppet::Util::Windows::SID.expects(:name_to_principal).with("#{domain}\\#{username}").returns nil
117
117
  Puppet::Util::Windows::ADSI.expects(:connect).with("WinNT://#{domain}/#{username},user").returns connection
118
118
  connection.expects(:Class).returns('User')
119
119
  expect(Puppet::Util::Windows::ADSI::User.exists?(domain_username)).to be_truthy
@@ -213,7 +213,7 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
213
213
  end
214
214
 
215
215
  it "should generate the correct URI" do
216
- Puppet::Util::Windows::SID.stubs(:octet_string_to_sid_object).returns(sid)
216
+ Puppet::Util::Windows::SID.stubs(:octet_string_to_principal).returns(sid)
217
217
  expect(user.uri).to eq("WinNT://testcomputername/#{username},user")
218
218
  end
219
219
 
@@ -276,8 +276,8 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
276
276
  let(:someone_sid){ stub(:account => 'someone', :domain => 'testcomputername')}
277
277
 
278
278
  describe "should be able to use SID objects" do
279
- let(:system) { Puppet::Util::Windows::SID.name_to_sid_object('SYSTEM') }
280
- let(:invalid) { Puppet::Util::Windows::SID.name_to_sid_object('foobar') }
279
+ let(:system) { Puppet::Util::Windows::SID.name_to_principal('SYSTEM') }
280
+ let(:invalid) { Puppet::Util::Windows::SID.name_to_principal('foobar') }
281
281
 
282
282
  it "to add a member" do
283
283
  adsi_group.expects(:Add).with("WinNT://S-1-5-18")
@@ -303,11 +303,14 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
303
303
  it "should provide its groups as a list of names" do
304
304
  names = ['user1', 'user2']
305
305
 
306
- users = names.map { |name| stub('user', :Name => name) }
306
+ users = names.map { |name| stub('user', :Name => name, :objectSID => name, :ole_respond_to? => true) }
307
307
 
308
308
  adsi_group.expects(:Members).returns(users)
309
309
 
310
- expect(group.members).to match(names)
310
+ Puppet::Util::Windows::SID.expects(:octet_string_to_principal).with('user1').returns(stub(:domain_account => 'HOSTNAME\user1'))
311
+ Puppet::Util::Windows::SID.expects(:octet_string_to_principal).with('user2').returns(stub(:domain_account => 'HOSTNAME\user2'))
312
+
313
+ expect(group.members.map(&:domain_account)).to match(['HOSTNAME\user1', 'HOSTNAME\user2'])
311
314
  end
312
315
 
313
316
  context "calling .set_members" do
@@ -320,16 +323,16 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
320
323
  ]
321
324
 
322
325
  # use stubbed objectSid on member to return stubbed SID
323
- Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([0]).returns(sids[0])
324
- Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([1]).returns(sids[1])
326
+ Puppet::Util::Windows::SID.expects(:octet_string_to_principal).with([0]).returns(sids[0])
327
+ Puppet::Util::Windows::SID.expects(:octet_string_to_principal).with([1]).returns(sids[1])
325
328
 
326
- Puppet::Util::Windows::SID.expects(:name_to_sid_object).with('user2').returns(sids[1])
327
- Puppet::Util::Windows::SID.expects(:name_to_sid_object).with('DOMAIN2\user3').returns(sids[2])
329
+ Puppet::Util::Windows::SID.expects(:name_to_principal).with('user2').returns(sids[1])
330
+ Puppet::Util::Windows::SID.expects(:name_to_principal).with('DOMAIN2\user3').returns(sids[2])
328
331
 
329
332
  Puppet::Util::Windows::ADSI.expects(:sid_uri).with(sids[0]).returns("WinNT://DOMAIN/user1,user")
330
333
  Puppet::Util::Windows::ADSI.expects(:sid_uri).with(sids[2]).returns("WinNT://DOMAIN2/user3,user")
331
334
 
332
- members = names.each_with_index.map{|n,i| stub(:Name => n, :objectSID => [i])}
335
+ members = names.each_with_index.map{|n,i| stub(:Name => n, :objectSID => [i], :ole_respond_to? => true)}
333
336
  adsi_group.expects(:Members).returns members
334
337
 
335
338
  adsi_group.expects(:Remove).with('WinNT://DOMAIN/user1,user')
@@ -347,15 +350,15 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
347
350
  ]
348
351
 
349
352
  # use stubbed objectSid on member to return stubbed SID
350
- Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([0]).returns(sids[0])
351
- Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([1]).returns(sids[1])
353
+ Puppet::Util::Windows::SID.expects(:octet_string_to_principal).with([0]).returns(sids[0])
354
+ Puppet::Util::Windows::SID.expects(:octet_string_to_principal).with([1]).returns(sids[1])
352
355
 
353
- Puppet::Util::Windows::SID.expects(:name_to_sid_object).with('user2').returns(sids[1])
354
- Puppet::Util::Windows::SID.expects(:name_to_sid_object).with('DOMAIN2\user3').returns(sids[2])
356
+ Puppet::Util::Windows::SID.expects(:name_to_principal).with('user2').returns(sids[1])
357
+ Puppet::Util::Windows::SID.expects(:name_to_principal).with('DOMAIN2\user3').returns(sids[2])
355
358
 
356
359
  Puppet::Util::Windows::ADSI.expects(:sid_uri).with(sids[2]).returns("WinNT://DOMAIN2/user3,user")
357
360
 
358
- members = names.each_with_index.map{|n,i| stub(:Name => n, :objectSID => [i])}
361
+ members = names.each_with_index.map{|n,i| stub(:Name => n, :objectSID => [i], :ole_respond_to? => true)}
359
362
  adsi_group.expects(:Members).returns members
360
363
 
361
364
  adsi_group.expects(:Remove).with('WinNT://DOMAIN/user1,user').never
@@ -382,13 +385,13 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
382
385
  ]
383
386
 
384
387
  # use stubbed objectSid on member to return stubbed SID
385
- Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([0]).returns(sids[0])
386
- Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([1]).returns(sids[1])
388
+ Puppet::Util::Windows::SID.expects(:octet_string_to_principal).with([0]).returns(sids[0])
389
+ Puppet::Util::Windows::SID.expects(:octet_string_to_principal).with([1]).returns(sids[1])
387
390
 
388
391
  Puppet::Util::Windows::ADSI.expects(:sid_uri).with(sids[0]).returns("WinNT://DOMAIN/user1,user")
389
392
  Puppet::Util::Windows::ADSI.expects(:sid_uri).with(sids[1]).returns("WinNT://testcomputername/user2,user")
390
393
 
391
- members = names.each_with_index.map{|n,i| stub(:Name => n, :objectSID => [i])}
394
+ members = names.each_with_index.map{|n,i| stub(:Name => n, :objectSID => [i], :ole_respond_to? => true)}
392
395
  adsi_group.expects(:Members).returns members
393
396
 
394
397
  adsi_group.expects(:Remove).with('WinNT://DOMAIN/user1,user')
@@ -404,10 +407,10 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
404
407
  stub(:account => 'user2', :domain => 'testcomputername', :sid => 2 ),
405
408
  ]
406
409
  # use stubbed objectSid on member to return stubbed SID
407
- Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([0]).returns(sids[0])
408
- Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([1]).returns(sids[1])
410
+ Puppet::Util::Windows::SID.expects(:octet_string_to_principal).with([0]).returns(sids[0])
411
+ Puppet::Util::Windows::SID.expects(:octet_string_to_principal).with([1]).returns(sids[1])
409
412
 
410
- members = names.each_with_index.map{|n,i| stub(:Name => n, :objectSID => [i])}
413
+ members = names.each_with_index.map{|n,i| stub(:Name => n, :objectSID => [i], :ole_respond_to? => true)}
411
414
  adsi_group.expects(:Members).returns members
412
415
 
413
416
  adsi_group.expects(:Remove).never
@@ -428,7 +431,7 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
428
431
  adsi_group.expects(:objectSID).returns([0])
429
432
  Socket.expects(:gethostname).returns('TESTcomputerNAME')
430
433
  computer_sid = stub(:account => groupname,:domain => 'testcomputername')
431
- Puppet::Util::Windows::SID.expects(:octet_string_to_sid_object).with([0]).returns(computer_sid)
434
+ Puppet::Util::Windows::SID.expects(:octet_string_to_principal).with([0]).returns(computer_sid)
432
435
  expect(group.uri).to eq("WinNT://./#{groupname},group")
433
436
  end
434
437
  end
@@ -458,7 +461,7 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
458
461
  end
459
462
 
460
463
  it "should be able to confirm the existence of a group" do
461
- Puppet::Util::Windows::SID.expects(:name_to_sid_object).with(groupname).returns nil
464
+ Puppet::Util::Windows::SID.expects(:name_to_principal).with(groupname).returns nil
462
465
  Puppet::Util::Windows::ADSI.expects(:connect).with("WinNT://./#{groupname},group").returns connection
463
466
  connection.expects(:Class).returns('Group')
464
467
 
@@ -500,13 +503,14 @@ describe Puppet::Util::Windows::ADSI, :if => Puppet.features.microsoft_windows?
500
503
  Puppet::Util::Windows::ADSI.expects(:execquery).with('select name from win32_group where localaccount = "TRUE"').returns(wmi_groups)
501
504
 
502
505
  native_group = stub('IADsGroup')
503
- native_group.expects(:Members).returns([stub(:Name => 'Administrator')])
506
+ 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)])
504
508
  Puppet::Util::Windows::ADSI.expects(:connect).with("WinNT://./#{name},group").returns(native_group)
505
509
 
506
510
  groups = Puppet::Util::Windows::ADSI::Group.to_a
507
511
  expect(groups.length).to eq(1)
508
512
  expect(groups[0].name).to eq(name)
509
- expect(groups[0].members).to eq(['Administrator'])
513
+ expect(groups[0].members.map(&:domain_account)).to eq(['.\Administrator'])
510
514
  end
511
515
  end
512
516