puppet 5.5.6-x64-mingw32 → 5.5.7-x64-mingw32

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

Potentially problematic release.


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

Files changed (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
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Puppet::Type::Group::Provider::Aix' do
4
+ let(:provider_class) { Puppet::Type.type(:group).provider(:aix) }
5
+
6
+ let(:resource) do
7
+ Puppet::Type.type(:group).new(
8
+ :name => 'test_aix_user',
9
+ :ensure => :present
10
+ )
11
+ end
12
+ let(:provider) do
13
+ provider_class.new(resource)
14
+ end
15
+
16
+ describe '.find' do
17
+ let(:groups) do
18
+ objects = [
19
+ { :name => 'group1', :id => '1' },
20
+ { :name => 'group2', :id => '2' }
21
+ ]
22
+
23
+ objects
24
+ end
25
+
26
+ let(:ia_module_args) { [ '-R', 'module' ] }
27
+
28
+ let(:expected_group) do
29
+ {
30
+ :name => 'group1',
31
+ :gid => 1
32
+ }
33
+ end
34
+
35
+ before(:each) do
36
+ provider_class.stubs(:list_all).with(ia_module_args).returns(groups)
37
+ end
38
+
39
+ it 'raises an ArgumentError if the group does not exist' do
40
+ expect do
41
+ provider_class.find('non_existent_group', ia_module_args)
42
+ end.to raise_error do |error|
43
+ expect(error).to be_a(ArgumentError)
44
+
45
+ expect(error.message).to match('non_existent_group')
46
+ end
47
+ end
48
+
49
+ it 'can find the group when passed-in a group name' do
50
+ expect(provider_class.find('group1', ia_module_args)).to eql(expected_group)
51
+ end
52
+
53
+ it 'can find the group when passed-in the gid' do
54
+ expect(provider_class.find(1, ia_module_args)).to eql(expected_group)
55
+ end
56
+ end
57
+ end
@@ -71,11 +71,5 @@ describe provider_class do
71
71
  provider.expects(:execute).with(all_of(includes("-M"), includes("user2")), has_entry(:custom_environment, {}))
72
72
  provider.members = "user2"
73
73
  end
74
-
75
- it "should use -M with all the given users when the members property is changed with an array" do
76
- resource[:members] = ["user1", "user2"]
77
- provider.expects(:execute).with(all_of(includes("-M"), includes("user3,user4")), has_entry(:custom_environment, {}))
78
- provider.members = ["user3", "user4"]
79
- end
80
74
  end
81
75
  end
@@ -49,25 +49,25 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
49
49
  describe "#members_insync?" do
50
50
  it "should return true for same lists of members" do
51
51
  current = [
52
- Puppet::Util::Windows::SID.name_to_principal('user1'),
53
- Puppet::Util::Windows::SID.name_to_principal('user2'),
52
+ 'user1',
53
+ 'user2'
54
54
  ]
55
55
  expect(provider.members_insync?(current, ['user1', 'user2'])).to be_truthy
56
56
  end
57
57
 
58
58
  it "should return true for same lists of unordered members" do
59
59
  current = [
60
- Puppet::Util::Windows::SID.name_to_principal('user1'),
61
- Puppet::Util::Windows::SID.name_to_principal('user2'),
60
+ 'user1',
61
+ 'user2'
62
62
  ]
63
63
  expect(provider.members_insync?(current, ['user2', 'user1'])).to be_truthy
64
64
  end
65
65
 
66
66
  it "should return true for same lists of members irrespective of duplicates" do
67
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'),
68
+ 'user1',
69
+ 'user2',
70
+ 'user2'
71
71
  ]
72
72
  expect(provider.members_insync?(current, ['user2', 'user1', 'user1'])).to be_truthy
73
73
  end
@@ -91,9 +91,9 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
91
91
 
92
92
  it "should return true when current and should contain the same users in a different order" do
93
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'),
94
+ 'user1',
95
+ 'user2',
96
+ 'user3'
97
97
  ]
98
98
  expect(provider.members_insync?(current, ['user3', 'user1', 'user2'])).to be_truthy
99
99
  end
@@ -104,21 +104,21 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
104
104
 
105
105
  it "should return false when should is nil" do
106
106
  current = [
107
- Puppet::Util::Windows::SID.name_to_principal('user1'),
107
+ 'user1'
108
108
  ]
109
109
  expect(provider.members_insync?(current, nil)).to be_falsey
110
110
  end
111
111
 
112
112
  it "should return false when current contains different users than should" do
113
113
  current = [
114
- Puppet::Util::Windows::SID.name_to_principal('user1'),
114
+ 'user1'
115
115
  ]
116
116
  expect(provider.members_insync?(current, ['user2'])).to be_falsey
117
117
  end
118
118
 
119
119
  it "should return false when current contains members and should is empty" do
120
120
  current = [
121
- Puppet::Util::Windows::SID.name_to_principal('user1'),
121
+ 'user1'
122
122
  ]
123
123
  expect(provider.members_insync?(current, [])).to be_falsey
124
124
  end
@@ -129,16 +129,16 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
129
129
 
130
130
  it "should return false when should user(s) are not the only items in the current" do
131
131
  current = [
132
- Puppet::Util::Windows::SID.name_to_principal('user1'),
133
- Puppet::Util::Windows::SID.name_to_principal('user2'),
132
+ 'user1',
133
+ 'user2'
134
134
  ]
135
135
  expect(provider.members_insync?(current, ['user1'])).to be_falsey
136
136
  end
137
137
 
138
138
  it "should return false when current user(s) is not empty and should is an empty list" do
139
139
  current = [
140
- Puppet::Util::Windows::SID.name_to_principal('user1'),
141
- Puppet::Util::Windows::SID.name_to_principal('user2'),
140
+ 'user1',
141
+ 'user2'
142
142
  ]
143
143
  expect(provider.members_insync?(current, [])).to be_falsey
144
144
  end
@@ -156,21 +156,21 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
156
156
 
157
157
  it "should return true when should is nil" do
158
158
  current = [
159
- Puppet::Util::Windows::SID.name_to_principal('user1'),
159
+ 'user1'
160
160
  ]
161
161
  expect(provider.members_insync?(current, nil)).to be_truthy
162
162
  end
163
163
 
164
164
  it "should return false when current contains different users than should" do
165
165
  current = [
166
- Puppet::Util::Windows::SID.name_to_principal('user1'),
166
+ 'user1'
167
167
  ]
168
168
  expect(provider.members_insync?(current, ['user2'])).to be_falsey
169
169
  end
170
170
 
171
171
  it "should return true when current contains members and should is empty" do
172
172
  current = [
173
- Puppet::Util::Windows::SID.name_to_principal('user1'),
173
+ 'user1'
174
174
  ]
175
175
  expect(provider.members_insync?(current, [])).to be_truthy
176
176
  end
@@ -181,25 +181,25 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
181
181
 
182
182
  it "should return true when current user(s) contains at least the should list" do
183
183
  current = [
184
- Puppet::Util::Windows::SID.name_to_principal('user1'),
185
- Puppet::Util::Windows::SID.name_to_principal('user2'),
184
+ 'user1',
185
+ 'user2'
186
186
  ]
187
187
  expect(provider.members_insync?(current, ['user1'])).to be_truthy
188
188
  end
189
189
 
190
190
  it "should return true when current user(s) is not empty and should is an empty list" do
191
191
  current = [
192
- Puppet::Util::Windows::SID.name_to_principal('user1'),
193
- Puppet::Util::Windows::SID.name_to_principal('user2'),
192
+ 'user1',
193
+ 'user2'
194
194
  ]
195
195
  expect(provider.members_insync?(current, [])).to be_truthy
196
196
  end
197
197
 
198
198
  it "should return true when current user(s) contains at least the should list, even unordered" do
199
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'),
200
+ 'user3',
201
+ 'user1',
202
+ 'user2'
203
203
  ]
204
204
  expect(provider.members_insync?(current, ['user2','user1'])).to be_truthy
205
205
  end
@@ -238,13 +238,14 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
238
238
 
239
239
  it "should be able to provide a list of members" do
240
240
  provider.group.stubs(:members).returns ['user1', 'user2', 'user3']
241
+ Puppet::Util::Windows::ADSI::User.stubs(:name_sid_hash)
242
+ .with(provider.group.members)
243
+ .returns({ 'user1' => '', 'user2' => '', 'user3' => '' })
241
244
 
242
245
  expect(provider.members).to match_array(['user1', 'user2', 'user3'])
243
246
  end
244
247
 
245
248
  it "should be able to set group members" do
246
- provider.group.stubs(:members).returns ['user1', 'user2']
247
-
248
249
  member_sids = [
249
250
  stub(:account => 'user1', :domain => 'testcomputername', :sid => 1),
250
251
  stub(:account => 'user2', :domain => 'testcomputername', :sid => 2),
@@ -259,7 +260,7 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
259
260
  provider.group.expects(:remove_member_sids).with(member_sids[0])
260
261
  provider.group.expects(:add_member_sids).with(member_sids[2])
261
262
 
262
- provider.members = ['user2', 'user3']
263
+ provider.members = 'user2,user3'
263
264
  end
264
265
  end
265
266
 
@@ -268,12 +269,13 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
268
269
  resource[:members] = ['user1', 'user2']
269
270
 
270
271
  group = stub 'group'
272
+ group.stubs(:members).returns([])
271
273
  Puppet::Util::Windows::ADSI::Group.expects(:create).with('testers').returns group
272
274
 
273
275
  create = sequence('create')
274
276
  group.expects(:commit).in_sequence(create)
275
277
  # due to PUP-1967, defaultto false will set the default to nil
276
- group.expects(:set_members).with(['user1', 'user2'], nil).in_sequence(create)
278
+ group.expects(:set_members).with('user1,user2', nil).in_sequence(create)
277
279
 
278
280
  provider.create
279
281
  end
@@ -290,10 +292,7 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
290
292
  connection.expects(:Create)
291
293
  connection.expects(:SetInfo).raises( WIN32OLERuntimeError.new("(in OLE method `SetInfo': )\n OLE error code:8007089A in Active Directory\n The specified username is invalid.\r\n\n HRESULT error code:0x80020009\n Exception occurred."))
292
294
 
293
- expect{ provider.create }.to raise_error(
294
- Puppet::Error,
295
- /not able to create\/delete domain groups/
296
- )
295
+ expect{ provider.create }.to raise_error(Puppet::Error)
297
296
  end
298
297
 
299
298
  it 'should commit a newly created group' do
@@ -17,13 +17,13 @@ end
17
17
 
18
18
  it "[#6009] should handle nested arrays of members" do
19
19
  current = ["foo", "bar", "baz"]
20
- desired = ["foo", ["quux"], "qorp"]
20
+ desired = "foo,quux,qorp"
21
21
  group = 'example'
22
22
 
23
23
  @resource.stubs(:[]).with(:name).returns(group)
24
24
  @resource.stubs(:[]).with(:auth_membership).returns(true)
25
25
  @provider.instance_variable_set(:@property_value_cache_hash,
26
- { :members => current })
26
+ { :members => current.join(',') })
27
27
 
28
28
  %w{bar baz}.each do |del|
29
29
  @provider.expects(:execute).once.
@@ -76,7 +76,7 @@ describe Puppet::Provider::Package::Windows::ExePackage do
76
76
  it 'should install using the source' do
77
77
  cmd = subject.install_command({:source => source})
78
78
 
79
- expect(cmd).to eq(['cmd.exe', '/c', 'start', '"puppet-install"', '/w', source])
79
+ expect(cmd).to eq(source)
80
80
  end
81
81
  end
82
82
 
@@ -84,7 +84,7 @@ describe Puppet::Provider::Package::Windows::ExePackage do
84
84
  ['C:\uninstall.exe', 'C:\Program Files\uninstall.exe'].each do |exe|
85
85
  it "should quote #{exe}" do
86
86
  expect(subject.new(name, version, exe).uninstall_command).to eq(
87
- ['cmd.exe', '/c', 'start', '"puppet-uninstall"', '/w', "\"#{exe}\""]
87
+ "\"#{exe}\""
88
88
  )
89
89
  end
90
90
  end
@@ -92,7 +92,7 @@ describe Puppet::Provider::Package::Windows::ExePackage do
92
92
  ['"C:\Program Files\uninstall.exe"', '"C:\Program Files (x86)\Git\unins000.exe" /SILENT"'].each do |exe|
93
93
  it "should not quote #{exe}" do
94
94
  expect(subject.new(name, version, exe).uninstall_command).to eq(
95
- ['cmd.exe', '/c', 'start', '"puppet-uninstall"', '/w', exe]
95
+ exe
96
96
  )
97
97
  end
98
98
  end
@@ -1,12 +1,12 @@
1
1
  #! /usr/bin/env ruby
2
2
  require 'spec_helper'
3
3
 
4
- describe Puppet::Type.type(:package).provider(:windows) do
4
+ describe Puppet::Type.type(:package).provider(:windows), :if => Puppet.features.microsoft_windows? do
5
5
  let (:name) { 'mysql-5.1.58-win-x64' }
6
- let (:source) { 'E:\mysql-5.1.58-win-x64.msi' }
6
+ let (:source) { 'E:\Rando\Directory\mysql-5.1.58-win-x64.msi' }
7
7
  let (:resource) { Puppet::Type.type(:package).new(:name => name, :provider => :windows, :source => source) }
8
8
  let (:provider) { resource.provider }
9
- let (:execute_options) do {:failonfail => false, :combine => true} end
9
+ let (:execute_options) do {:failonfail => false, :combine => true, :suppress_window => true} end
10
10
 
11
11
  before :each do
12
12
  # make sure we never try to execute anything
@@ -86,7 +86,7 @@ describe Puppet::Type.type(:package).provider(:windows) do
86
86
  context '#install' do
87
87
  let(:command) { 'blarg.exe /S' }
88
88
  let(:klass) { mock('installer', :install_command => ['blarg.exe', '/S'] ) }
89
-
89
+ let(:execute_options) do {:failonfail => false, :combine => true, :cwd => 'E:\Rando\Directory', :suppress_window => true} end
90
90
  before :each do
91
91
  Puppet::Provider::Package::Windows::Package.expects(:installer_class).returns(klass)
92
92
  end
@@ -343,4 +343,23 @@ describe Puppet::Type.type(:service).provider(:launchd) do
343
343
  expect { provider.jobsearch("NOSUCH") }.to raise_error(Puppet::Error)
344
344
  end
345
345
  end
346
+
347
+ describe "read_overrides" do
348
+ before do
349
+ Kernel.stubs(:sleep)
350
+ end
351
+ it "should read overrides" do
352
+ provider.expects(:read_plist).once.returns({})
353
+ expect(provider.read_overrides).to eq({})
354
+ end
355
+ it "should retry if read_plist fails" do
356
+ provider.expects(:read_plist).once.returns({})
357
+ provider.expects(:read_plist).once.returns(nil)
358
+ expect(provider.read_overrides).to eq({})
359
+ end
360
+ it "raises Puppet::Error after 20 attempts" do
361
+ provider.expects(:read_plist).times(20).returns(nil)
362
+ expect { provider.read_overrides }.to raise_error(Puppet::Error)
363
+ end
364
+ end
346
365
  end
@@ -13,55 +13,46 @@ describe Puppet::Type.type(:service).provider(:windows), :if => Puppet.features.
13
13
  let(:provider) { resource.provider }
14
14
  let(:config) { Struct::ServiceConfigInfo.new }
15
15
  let(:status) { Struct::ServiceStatus.new }
16
+ let(:service_util) { Puppet::Util::Windows::Service }
17
+ let(:service_handle) { mock() }
16
18
 
17
19
  before :each do
18
20
  # make sure we never actually execute anything (there are two execute methods)
19
21
  provider.class.expects(:execute).never
20
22
  provider.expects(:execute).never
21
23
 
22
- Win32::Service.stubs(:config_info).with(name).returns(config)
23
- Win32::Service.stubs(:status).with(name).returns(status)
24
+ service_util.stubs(:exists?).with(resource[:name]).returns(true)
24
25
  end
25
26
 
26
27
  describe ".instances" do
27
28
  it "should enumerate all services" do
28
- list_of_services = ['snmptrap', 'svchost', 'sshd'].map { |s| stub('service', :service_name => s) }
29
- Win32::Service.expects(:services).returns(list_of_services)
29
+ list_of_services = {'snmptrap' => {}, 'svchost' => {}, 'sshd' => {}}
30
+ service_util.expects(:services).returns(list_of_services)
30
31
 
31
32
  expect(described_class.instances.map(&:name)).to match_array(['snmptrap', 'svchost', 'sshd'])
32
33
  end
33
34
  end
34
35
 
35
36
  describe "#start" do
36
- before :each do
37
- config.start_type = Win32::Service.get_start_type(Win32::Service::SERVICE_AUTO_START)
37
+ before(:each) do
38
+ provider.stubs(:status).returns(:stopped)
38
39
  end
39
40
 
40
- it "should start the service" do
41
- provider.expects(:net).with(:start, name)
42
-
41
+ it "should resume a paused service" do
42
+ provider.stubs(:status).returns(:paused)
43
+ service_util.expects(:resume).with(name)
43
44
  provider.start
44
45
  end
45
46
 
46
- it "should raise an error if the start command fails" do
47
- provider.expects(:net).with(:start, name).raises(Puppet::ExecutionFailure, "The service name is invalid.")
48
-
49
- expect {
50
- provider.start
51
- }.to raise_error(Puppet::Error, /Cannot start #{name}, error was: The service name is invalid./)
52
- end
53
-
54
- it "raises an error if the service doesn't exist" do
55
- Win32::Service.expects(:config_info).with(name).raises(SystemCallError, 'OpenService')
56
-
57
- expect {
58
- provider.start
59
- }.to raise_error(Puppet::Error, /Cannot get start type for #{name}/)
47
+ it "should start the service" do
48
+ service_util.expects(:service_start_type).with(name).returns(:SERVICE_AUTO_START)
49
+ service_util.expects(:start).with(name)
50
+ provider.start
60
51
  end
61
52
 
62
- describe "when the service is disabled" do
53
+ context "when the service is disabled" do
63
54
  before :each do
64
- config.start_type = Win32::Service.get_start_type(Win32::Service::SERVICE_DISABLED)
55
+ service_util.expects(:service_start_type).with(name).returns(:SERVICE_DISABLED)
65
56
  end
66
57
 
67
58
  it "should refuse to start if not managing enable" do
@@ -70,18 +61,16 @@ describe Puppet::Type.type(:service).provider(:windows), :if => Puppet.features.
70
61
 
71
62
  it "should enable if managing enable and enable is true" do
72
63
  resource[:enable] = :true
73
-
74
- provider.expects(:net).with(:start, name)
75
- Win32::Service.expects(:configure).with('service_name' => name, 'start_type' => Win32::Service::SERVICE_AUTO_START).returns(Win32::Service)
64
+ service_util.expects(:start).with(name)
65
+ service_util.expects(:set_startup_mode).with(name, :SERVICE_AUTO_START)
76
66
 
77
67
  provider.start
78
68
  end
79
69
 
80
70
  it "should manual start if managing enable and enable is false" do
81
71
  resource[:enable] = :false
82
-
83
- provider.expects(:net).with(:start, name)
84
- Win32::Service.expects(:configure).with('service_name' => name, 'start_type' => Win32::Service::SERVICE_DEMAND_START).returns(Win32::Service)
72
+ service_util.expects(:start).with(name)
73
+ service_util.expects(:set_startup_mode).with(name, :SERVICE_DEMAND_START)
85
74
 
86
75
  provider.start
87
76
  end
@@ -90,44 +79,50 @@ describe Puppet::Type.type(:service).provider(:windows), :if => Puppet.features.
90
79
 
91
80
  describe "#stop" do
92
81
  it "should stop a running service" do
93
- provider.expects(:net).with(:stop, name)
82
+ service_util.expects(:stop).with(name)
94
83
 
95
84
  provider.stop
96
85
  end
86
+ end
97
87
 
98
- it "should raise an error if the stop command fails" do
99
- provider.expects(:net).with(:stop, name).raises(Puppet::ExecutionFailure, 'The service name is invalid.')
88
+ describe "#status" do
89
+ it "should report a nonexistent service as stopped" do
90
+ service_util.stubs(:exists?).with(resource[:name]).returns(false)
100
91
 
101
- expect {
102
- provider.stop
103
- }.to raise_error(Puppet::Error, /Cannot stop #{name}, error was: The service name is invalid./)
92
+ expect(provider.status).to eql(:stopped)
104
93
  end
105
- end
106
94
 
107
- describe "#status" do
108
- ['stopped', 'paused', 'stop pending', 'pause pending'].each do |state|
109
- it "should report a #{state} service as stopped" do
110
- status.current_state = state
95
+ [
96
+ :SERVICE_PAUSED,
97
+ :SERVICE_PAUSE_PENDING
98
+ ].each do |state|
99
+ it "should report a #{state} service as paused" do
100
+ service_util.expects(:service_state).with(name).returns(state)
101
+ expect(provider.status).to eq(:paused)
102
+ end
103
+ end
111
104
 
105
+ [
106
+ :SERVICE_STOPPED,
107
+ :SERVICE_STOP_PENDING
108
+ ].each do |state|
109
+ it "should report a #{state} service as stopped" do
110
+ service_util.expects(:service_state).with(name).returns(state)
112
111
  expect(provider.status).to eq(:stopped)
113
112
  end
114
113
  end
115
114
 
116
- ["running", "continue pending", "start pending" ].each do |state|
115
+ [
116
+ :SERVICE_RUNNING,
117
+ :SERVICE_CONTINUE_PENDING,
118
+ :SERVICE_START_PENDING,
119
+ ].each do |state|
117
120
  it "should report a #{state} service as running" do
118
- status.current_state = state
121
+ service_util.expects(:service_state).with(name).returns(state)
119
122
 
120
123
  expect(provider.status).to eq(:running)
121
124
  end
122
125
  end
123
-
124
- it "raises an error if the service doesn't exist" do
125
- Win32::Service.expects(:status).with(name).raises(SystemCallError, 'OpenService')
126
-
127
- expect {
128
- provider.status
129
- }.to raise_error(Puppet::Error, /Cannot get status of #{name}/)
130
- end
131
126
  end
132
127
 
133
128
  describe "#restart" do
@@ -150,34 +145,32 @@ describe Puppet::Type.type(:service).provider(:windows), :if => Puppet.features.
150
145
  end
151
146
 
152
147
  describe "#enabled?" do
153
- it "should report a service with a startup type of manual as manual" do
154
- config.start_type = Win32::Service.get_start_type(Win32::Service::SERVICE_DEMAND_START)
148
+ it "should report a nonexistent service as false" do
149
+ service_util.stubs(:exists?).with(resource[:name]).returns(false)
155
150
 
151
+ expect(provider.enabled?).to eql(:false)
152
+ end
153
+
154
+ it "should report a service with a startup type of manual as manual" do
155
+ service_util.expects(:service_start_type).with(name).returns(:SERVICE_DEMAND_START)
156
156
  expect(provider.enabled?).to eq(:manual)
157
157
  end
158
158
 
159
159
  it "should report a service with a startup type of disabled as false" do
160
- config.start_type = Win32::Service.get_start_type(Win32::Service::SERVICE_DISABLED)
161
-
160
+ service_util.expects(:service_start_type).with(name).returns(:SERVICE_DISABLED)
162
161
  expect(provider.enabled?).to eq(:false)
163
162
  end
164
163
 
165
- it "raises an error if the service doesn't exist" do
166
- Win32::Service.expects(:config_info).with(name).raises(SystemCallError, 'OpenService')
167
-
168
- expect {
169
- provider.enabled?
170
- }.to raise_error(Puppet::Error, /Cannot get start type for #{name}/)
171
- end
172
-
173
164
  # We need to guard this section explicitly since rspec will always
174
165
  # construct all examples, even if it isn't going to run them.
175
166
  if Puppet.features.microsoft_windows?
176
- [Win32::Service::SERVICE_AUTO_START, Win32::Service::SERVICE_BOOT_START, Win32::Service::SERVICE_SYSTEM_START].each do |start_type_const|
177
- start_type = Win32::Service.get_start_type(start_type_const)
167
+ [
168
+ :SERVICE_AUTO_START,
169
+ :SERVICE_BOOT_START,
170
+ :SERVICE_SYSTEM_START
171
+ ].each do |start_type|
178
172
  it "should report a service with a startup type of '#{start_type}' as true" do
179
- config.start_type = start_type
180
-
173
+ service_util.expects(:service_start_type).with(name).returns(start_type)
181
174
  expect(provider.enabled?).to eq(:true)
182
175
  end
183
176
  end
@@ -186,12 +179,12 @@ describe Puppet::Type.type(:service).provider(:windows), :if => Puppet.features.
186
179
 
187
180
  describe "#enable" do
188
181
  it "should set service start type to Service_Auto_Start when enabled" do
189
- Win32::Service.expects(:configure).with('service_name' => name, 'start_type' => Win32::Service::SERVICE_AUTO_START).returns(Win32::Service)
182
+ service_util.expects(:set_startup_mode).with(name, :SERVICE_AUTO_START)
190
183
  provider.enable
191
184
  end
192
185
 
193
- it "raises an error if the service doesn't exist" do
194
- Win32::Service.expects(:configure).with(has_entry('service_name' => name)).raises(SystemCallError, 'OpenService')
186
+ it "raises an error if set_startup_mode fails" do
187
+ service_util.expects(:set_startup_mode).with(name, :SERVICE_AUTO_START).raises(Puppet::Error.new('foobar'))
195
188
 
196
189
  expect {
197
190
  provider.enable
@@ -201,12 +194,12 @@ describe Puppet::Type.type(:service).provider(:windows), :if => Puppet.features.
201
194
 
202
195
  describe "#disable" do
203
196
  it "should set service start type to Service_Disabled when disabled" do
204
- Win32::Service.expects(:configure).with('service_name' => name, 'start_type' => Win32::Service::SERVICE_DISABLED).returns(Win32::Service)
197
+ service_util.expects(:set_startup_mode).with(name, :SERVICE_DISABLED)
205
198
  provider.disable
206
- end
199
+ end
207
200
 
208
- it "raises an error if the service doesn't exist" do
209
- Win32::Service.expects(:configure).with(has_entry('service_name' => name)).raises(SystemCallError, 'OpenService')
201
+ it "raises an error if set_startup_mode fails" do
202
+ service_util.expects(:set_startup_mode).with(name, :SERVICE_DISABLED).raises(Puppet::Error.new('foobar'))
210
203
 
211
204
  expect {
212
205
  provider.disable
@@ -216,12 +209,12 @@ describe Puppet::Type.type(:service).provider(:windows), :if => Puppet.features.
216
209
 
217
210
  describe "#manual_start" do
218
211
  it "should set service start type to Service_Demand_Start (manual) when manual" do
219
- Win32::Service.expects(:configure).with('service_name' => name, 'start_type' => Win32::Service::SERVICE_DEMAND_START).returns(Win32::Service)
212
+ service_util.expects(:set_startup_mode).with(name, :SERVICE_DEMAND_START)
220
213
  provider.manual_start
221
214
  end
222
215
 
223
- it "raises an error if the service doesn't exist" do
224
- Win32::Service.expects(:configure).with(has_entry('service_name' => name)).raises(SystemCallError, 'OpenService')
216
+ it "raises an error if set_startup_mode fails" do
217
+ service_util.expects(:set_startup_mode).with(name, :SERVICE_DEMAND_START).raises(Puppet::Error.new('foobar'))
225
218
 
226
219
  expect {
227
220
  provider.manual_start