puppet 6.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +20 -20
  4. data/Guardfile.example +76 -0
  5. data/LICENSE +189 -4
  6. data/README.md +3 -3
  7. data/Rakefile +5 -2
  8. data/ext/solaris/smf/svc-puppetd +8 -1
  9. data/ext/solaris/smf/svc-puppetmasterd +8 -1
  10. data/lib/puppet/application/apply.rb +100 -59
  11. data/lib/puppet/application/cert.rb +4 -114
  12. data/lib/puppet/application/device.rb +48 -32
  13. data/lib/puppet/application/script.rb +1 -1
  14. data/lib/puppet/application/ssl.rb +135 -51
  15. data/lib/puppet/application.rb +5 -0
  16. data/lib/puppet/configurer.rb +2 -3
  17. data/lib/puppet/defaults.rb +33 -49
  18. data/lib/puppet/etc.rb +20 -0
  19. data/lib/puppet/face/config.rb +3 -3
  20. data/lib/puppet/face/key.rb +1 -1
  21. data/lib/puppet/face/node/clean.rb +0 -1
  22. data/lib/puppet/feature/base.rb +1 -1
  23. data/lib/puppet/file_bucket/dipper.rb +1 -1
  24. data/lib/puppet/file_serving/fileset.rb +1 -1
  25. data/lib/puppet/functions/abs.rb +1 -1
  26. data/lib/puppet/functions/new.rb +1 -1
  27. data/lib/puppet/module/task.rb +29 -38
  28. data/lib/puppet/pal/catalog_compiler.rb +96 -0
  29. data/lib/puppet/pal/compiler.rb +221 -0
  30. data/lib/puppet/pal/function_signature.rb +52 -0
  31. data/lib/puppet/pal/json_catalog_encoder.rb +67 -0
  32. data/lib/puppet/pal/pal_api.rb +15 -0
  33. data/lib/puppet/pal/pal_impl.rb +523 -0
  34. data/lib/puppet/pal/plan_signature.rb +71 -0
  35. data/lib/puppet/pal/script_compiler.rb +71 -0
  36. data/lib/puppet/pal/task_signature.rb +58 -0
  37. data/lib/puppet/parser/catalog_compiler.rb +24 -0
  38. data/lib/puppet/parser/compiler.rb +3 -1
  39. data/lib/puppet/parser/functions/generate.rb +7 -6
  40. data/lib/puppet/plugins/configuration.rb +5 -1
  41. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +3 -1
  42. data/lib/puppet/pops/evaluator/deferred_resolver.rb +3 -0
  43. data/lib/puppet/pops/evaluator/evaluator_impl.rb +5 -1
  44. data/lib/puppet/pops/evaluator/external_syntax_support.rb +3 -3
  45. data/lib/puppet/pops/evaluator/runtime3_converter.rb +2 -2
  46. data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +19 -10
  47. data/lib/puppet/pops/loader/task_instantiator.rb +13 -70
  48. data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
  49. data/lib/puppet/pops/parser/lexer2.rb +1 -1
  50. data/lib/puppet/pops/pcore.rb +10 -33
  51. data/lib/puppet/pops/serialization/to_data_converter.rb +9 -1
  52. data/lib/puppet/pops/serialization.rb +1 -0
  53. data/lib/puppet/pops/types/p_timespan_type.rb +2 -2
  54. data/lib/puppet/pops/types/string_converter.rb +18 -4
  55. data/lib/puppet/pops/validation/checker4_0.rb +17 -2
  56. data/lib/puppet/provider/exec.rb +59 -57
  57. data/lib/puppet/provider/group/aix.rb +18 -2
  58. data/lib/puppet/provider/group/windows_adsi.rb +7 -3
  59. data/lib/puppet/provider/nameservice.rb +1 -25
  60. data/lib/puppet/provider/package/dnf.rb +2 -0
  61. data/lib/puppet/provider/package/pkgng.rb +37 -21
  62. data/lib/puppet/provider/package/portage.rb +2 -2
  63. data/lib/puppet/provider/package/windows/exe_package.rb +16 -10
  64. data/lib/puppet/provider/package/windows/msi_package.rb +8 -0
  65. data/lib/puppet/provider/package/windows/package.rb +9 -1
  66. data/lib/puppet/provider/package/windows.rb +2 -2
  67. data/lib/puppet/provider/package/yum.rb +1 -1
  68. data/lib/puppet/provider/parsedfile.rb +25 -4
  69. data/lib/puppet/provider/service/launchd.rb +19 -3
  70. data/lib/puppet/provider/service/smf.rb +54 -0
  71. data/lib/puppet/provider/service/systemd.rb +19 -0
  72. data/lib/puppet/provider/service/upstart.rb +1 -0
  73. data/lib/puppet/provider/service/windows.rb +22 -5
  74. data/lib/puppet/provider/user/aix.rb +48 -2
  75. data/lib/puppet/provider/user/useradd.rb +2 -10
  76. data/lib/puppet/provider/user/windows_adsi.rb +9 -1
  77. data/lib/puppet/resource/catalog.rb +1 -5
  78. data/lib/puppet/resource.rb +3 -1
  79. data/lib/puppet/ssl/host.rb +26 -16
  80. data/lib/puppet/syntax_checkers/epp.rb +34 -0
  81. data/lib/puppet/syntax_checkers/pp.rb +34 -0
  82. data/lib/puppet/transaction/event_manager.rb +13 -1
  83. data/lib/puppet/transaction/persistence.rb +1 -1
  84. data/lib/puppet/transaction/resource_harness.rb +3 -1
  85. data/lib/puppet/type/group.rb +29 -1
  86. data/lib/puppet/type/package.rb +5 -1
  87. data/lib/puppet/type/resources.rb +12 -2
  88. data/lib/puppet/type/schedule.rb +7 -0
  89. data/lib/puppet/type/service.rb +12 -0
  90. data/lib/puppet/type/user.rb +5 -2
  91. data/lib/puppet/type.rb +6 -0
  92. data/lib/puppet/util/command_line.rb +2 -3
  93. data/lib/puppet/util/execution.rb +15 -1
  94. data/lib/puppet/util/filetype.rb +56 -8
  95. data/lib/puppet/util/log/destinations.rb +3 -2
  96. data/lib/puppet/util/logging.rb +3 -2
  97. data/lib/puppet/util/posix.rb +15 -0
  98. data/lib/puppet/util/selinux.rb +1 -1
  99. data/lib/puppet/util/storage.rb +12 -0
  100. data/lib/puppet/util/windows/adsi.rb +79 -2
  101. data/lib/puppet/util/windows/api_types.rb +1 -1
  102. data/lib/puppet/util/windows/process.rb +23 -3
  103. data/lib/puppet/util/windows/registry.rb +29 -5
  104. data/lib/puppet/util/windows/security.rb +14 -0
  105. data/lib/puppet/util/windows/service.rb +294 -74
  106. data/lib/puppet/util/windows/user.rb +3 -5
  107. data/lib/puppet/util.rb +7 -3
  108. data/lib/puppet/version.rb +1 -1
  109. data/lib/puppet.rb +1 -0
  110. data/lib/puppet_pal.rb +5 -1099
  111. data/locales/ja/puppet.po +952 -986
  112. data/locales/puppet.pot +592 -347
  113. data/man/man5/puppet.conf.5 +26 -31
  114. data/man/man8/puppet-agent.8 +1 -1
  115. data/man/man8/puppet-apply.8 +1 -1
  116. data/man/man8/puppet-catalog.8 +1 -1
  117. data/man/man8/puppet-config.8 +4 -4
  118. data/man/man8/puppet-describe.8 +1 -1
  119. data/man/man8/puppet-device.8 +23 -19
  120. data/man/man8/puppet-doc.8 +1 -1
  121. data/man/man8/puppet-epp.8 +1 -1
  122. data/man/man8/puppet-facts.8 +1 -1
  123. data/man/man8/puppet-filebucket.8 +1 -1
  124. data/man/man8/puppet-generate.8 +1 -1
  125. data/man/man8/puppet-help.8 +1 -1
  126. data/man/man8/puppet-key.8 +2 -2
  127. data/man/man8/puppet-lookup.8 +1 -1
  128. data/man/man8/puppet-man.8 +1 -1
  129. data/man/man8/puppet-module.8 +1 -1
  130. data/man/man8/puppet-node.8 +1 -1
  131. data/man/man8/puppet-parser.8 +1 -1
  132. data/man/man8/puppet-plugin.8 +1 -1
  133. data/man/man8/puppet-report.8 +1 -1
  134. data/man/man8/puppet-resource.8 +1 -1
  135. data/man/man8/puppet-script.8 +1 -1
  136. data/man/man8/puppet-ssl.8 +26 -3
  137. data/man/man8/puppet-status.8 +1 -1
  138. data/man/man8/puppet.8 +2 -2
  139. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/bad_func_load.rb +11 -0
  140. data/spec/fixtures/unit/provider/package/pkgng/pkg.query +7 -1
  141. data/spec/fixtures/unit/provider/package/pkgng/pkg.query.zsh +1 -0
  142. data/spec/fixtures/unit/provider/service/smf/svcs_fmri.out +6 -0
  143. data/spec/fixtures/unit/provider/service/smf/svcs_multiple_fmris.out +13 -0
  144. data/spec/integration/application/apply_spec.rb +4 -1
  145. data/spec/integration/parser/collection_spec.rb +4 -8
  146. data/spec/integration/provider/service/windows_spec.rb +5 -5
  147. data/spec/integration/ssl/key_spec.rb +0 -4
  148. data/spec/integration/transaction_spec.rb +559 -0
  149. data/spec/integration/type/file_spec.rb +6 -6
  150. data/spec/integration/util/windows/registry_spec.rb +39 -0
  151. data/spec/integration/util/windows/security_spec.rb +10 -7
  152. data/spec/integration/util/windows/user_spec.rb +37 -17
  153. data/spec/lib/puppet/test_ca.rb +1 -1
  154. data/spec/spec_helper.rb +1 -1
  155. data/spec/unit/agent_spec.rb +2 -2
  156. data/spec/unit/application/apply_spec.rb +55 -2
  157. data/spec/unit/application/device_spec.rb +10 -7
  158. data/spec/unit/application/face_base_spec.rb +1 -1
  159. data/spec/unit/application/lookup_spec.rb +2 -1
  160. data/spec/unit/application/ssl_spec.rb +178 -109
  161. data/spec/unit/application_spec.rb +29 -11
  162. data/spec/unit/configurer/downloader_spec.rb +1 -1
  163. data/spec/unit/configurer_spec.rb +16 -5
  164. data/spec/unit/etc_spec.rb +25 -0
  165. data/spec/unit/face/node_spec.rb +1 -3
  166. data/spec/unit/face/parser_spec.rb +15 -0
  167. data/spec/unit/file_serving/fileset_spec.rb +11 -11
  168. data/spec/unit/functions/logging_spec.rb +10 -3
  169. data/spec/unit/indirector/catalog/json_spec.rb +9 -3
  170. data/spec/unit/indirector/yaml_spec.rb +1 -1
  171. data/spec/unit/network/http/connection_spec.rb +2 -2
  172. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +36 -0
  173. data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +22 -4
  174. data/spec/unit/pops/loaders/loader_spec.rb +9 -17
  175. data/spec/unit/pops/loaders/loaders_spec.rb +48 -0
  176. data/spec/unit/pops/loaders/module_loaders_spec.rb +7 -7
  177. data/spec/unit/pops/parser/parse_heredoc_spec.rb +16 -0
  178. data/spec/unit/pops/serialization/to_from_hr_spec.rb +9 -0
  179. data/spec/unit/pops/types/p_timespan_type_spec.rb +22 -0
  180. data/spec/unit/pops/types/p_timestamp_type_spec.rb +19 -0
  181. data/spec/unit/pops/types/string_converter_spec.rb +25 -1
  182. data/spec/unit/pops/types/task_spec.rb +42 -116
  183. data/spec/unit/pops/validator/validator_spec.rb +24 -10
  184. data/spec/unit/provider/exec/posix_spec.rb +24 -0
  185. data/spec/unit/provider/group/aix_spec.rb +20 -6
  186. data/spec/unit/provider/group/ldap_spec.rb +22 -25
  187. data/spec/unit/provider/group/pw_spec.rb +7 -10
  188. data/spec/unit/provider/group/windows_adsi_spec.rb +42 -33
  189. data/spec/unit/provider/nameservice/directoryservice_spec.rb +97 -103
  190. data/spec/unit/provider/package/aix_spec.rb +5 -8
  191. data/spec/unit/provider/package/apt_spec.rb +3 -6
  192. data/spec/unit/provider/package/dnf_spec.rb +38 -25
  193. data/spec/unit/provider/package/dpkg_spec.rb +18 -21
  194. data/spec/unit/provider/package/freebsd_spec.rb +4 -7
  195. data/spec/unit/provider/package/gem_spec.rb +41 -41
  196. data/spec/unit/provider/package/hpux_spec.rb +7 -10
  197. data/spec/unit/provider/package/macports_spec.rb +13 -15
  198. data/spec/unit/provider/package/nim_spec.rb +3 -10
  199. data/spec/unit/provider/package/openbsd_spec.rb +14 -17
  200. data/spec/unit/provider/package/pip3_spec.rb +3 -6
  201. data/spec/unit/provider/package/pip_spec.rb +45 -49
  202. data/spec/unit/provider/package/pkgin_spec.rb +13 -18
  203. data/spec/unit/provider/package/pkgng_spec.rb +32 -27
  204. data/spec/unit/provider/package/puppet_gem_spec.rb +6 -9
  205. data/spec/unit/provider/package/tdnf_spec.rb +9 -12
  206. data/spec/unit/provider/package/windows/exe_package_spec.rb +3 -3
  207. data/spec/unit/provider/package/windows_spec.rb +4 -4
  208. data/spec/unit/provider/package/yum_spec.rb +30 -16
  209. data/spec/unit/provider/package/zypper_spec.rb +17 -19
  210. data/spec/unit/provider/service/bsd_spec.rb +7 -9
  211. data/spec/unit/provider/service/daemontools_spec.rb +12 -16
  212. data/spec/unit/provider/service/debian_spec.rb +6 -10
  213. data/spec/unit/provider/service/freebsd_spec.rb +2 -2
  214. data/spec/unit/provider/service/launchd_spec.rb +19 -0
  215. data/spec/unit/provider/service/openbsd_spec.rb +13 -17
  216. data/spec/unit/provider/service/rcng_spec.rb +2 -4
  217. data/spec/unit/provider/service/redhat_spec.rb +12 -11
  218. data/spec/unit/provider/service/runit_spec.rb +7 -14
  219. data/spec/unit/provider/service/smf_spec.rb +77 -13
  220. data/spec/unit/provider/service/src_spec.rb +11 -16
  221. data/spec/unit/provider/service/systemd_spec.rb +39 -1
  222. data/spec/unit/provider/service/windows_spec.rb +39 -7
  223. data/spec/unit/provider/user/aix_spec.rb +43 -2
  224. data/spec/unit/provider/user/hpux_spec.rb +3 -5
  225. data/spec/unit/provider/user/ldap_spec.rb +29 -32
  226. data/spec/unit/provider/user/pw_spec.rb +10 -13
  227. data/spec/unit/provider/user/useradd_spec.rb +2 -2
  228. data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
  229. data/spec/unit/puppet_pal_2pec.rb +6 -6
  230. data/spec/unit/puppet_pal_catalog_spec.rb +58 -0
  231. data/spec/unit/resource/catalog_spec.rb +2 -2
  232. data/spec/unit/resource_spec.rb +31 -0
  233. data/spec/unit/ssl/host_spec.rb +22 -1
  234. data/spec/unit/ssl/key_spec.rb +2 -4
  235. data/spec/unit/task_spec.rb +50 -5
  236. data/spec/unit/transaction/event_manager_spec.rb +12 -1
  237. data/spec/unit/transaction/persistence_spec.rb +4 -4
  238. data/spec/unit/transaction/resource_harness_spec.rb +18 -0
  239. data/spec/unit/type/group_spec.rb +11 -3
  240. data/spec/unit/type/resources_spec.rb +18 -0
  241. data/spec/unit/type/service_spec.rb +27 -1
  242. data/spec/unit/util/execution_spec.rb +77 -0
  243. data/spec/unit/util/filetype_spec.rb +13 -5
  244. data/spec/unit/util/log/destinations_spec.rb +10 -0
  245. data/spec/unit/util/logging_spec.rb +58 -41
  246. data/spec/unit/util/monkey_patches_spec.rb +18 -5
  247. data/spec/unit/util/posix_spec.rb +28 -0
  248. data/spec/unit/util/selinux_spec.rb +4 -0
  249. data/spec/unit/util/storage_spec.rb +107 -0
  250. data/spec/unit/util/suidmanager_spec.rb +1 -3
  251. data/spec/unit/util/windows/adsi_spec.rb +95 -0
  252. data/spec/unit/util/windows/service_spec.rb +377 -131
  253. metadata +24 -11
  254. data/ext/autotest/Rakefile +0 -8
  255. data/ext/autotest/config +0 -43
  256. data/ext/autotest/readme.rst +0 -16
  257. data/spec/fixtures/unit/provider/package/pkgng/pkg.info +0 -7
  258. data/spec/fixtures/unit/provider/package/pkgng/pkg.query_absent +0 -1
  259. data/spec/watchr.rb +0 -137
@@ -1,11 +1,7 @@
1
- #! /usr/bin/env ruby
2
- #
3
- # Unit testing for the RedHat service Provider
4
- #
5
1
  require 'spec_helper'
6
2
 
7
3
  describe 'Puppet::Type::Service::Provider::Redhat',
8
- :if => Puppet.features.posix? && !Puppet::Util::Platform.jruby? do
4
+ if: Puppet.features.posix? && !Puppet::Util::Platform.jruby?do
9
5
  let(:provider_class) { Puppet::Type.type(:service).provider(:redhat) }
10
6
 
11
7
  before :each do
@@ -40,7 +36,7 @@ describe 'Puppet::Type::Service::Provider::Redhat',
40
36
  end
41
37
 
42
38
  # test self.instances
43
- describe "when getting all service instances" do
39
+ context "when getting all service instances" do
44
40
  before :each do
45
41
  @services = ['one', 'two', 'three', 'four', 'kudzu', 'functions', 'halt', 'killall', 'single', 'linuxconf', 'boot', 'reboot']
46
42
  @not_services = ['functions', 'halt', 'killall', 'single', 'linuxconf', 'reboot', 'boot']
@@ -78,7 +74,7 @@ describe 'Puppet::Type::Service::Provider::Redhat',
78
74
  expect(@provider).to respond_to(:enabled?)
79
75
  end
80
76
 
81
- describe "when checking enabled? on Suse" do
77
+ context "when checking enabled? on Suse" do
82
78
  before :each do
83
79
  Facter.expects(:value).with(:osfamily).returns 'Suse'
84
80
  end
@@ -132,20 +128,23 @@ describe 'Puppet::Type::Service::Provider::Redhat',
132
128
  end
133
129
  end
134
130
 
135
- describe "when checking status" do
136
- describe "when hasstatus is :true" do
131
+ context "when checking status" do
132
+ context "when hasstatus is :true" do
137
133
  before :each do
138
134
  @resource.stubs(:[]).with(:hasstatus).returns :true
139
135
  end
136
+
140
137
  it "should execute the service script with fail_on_failure false" do
141
138
  @provider.expects(:texecute).with(:status, ['/sbin/service', 'myservice', 'status'], false)
142
139
  @provider.status
143
140
  end
141
+
144
142
  it "should consider the process running if the command returns 0" do
145
143
  @provider.expects(:texecute).with(:status, ['/sbin/service', 'myservice', 'status'], false)
146
144
  $CHILD_STATUS.stubs(:exitstatus).returns(0)
147
145
  expect(@provider.status).to eq(:running)
148
146
  end
147
+
149
148
  [-10,-1,1,10].each { |ec|
150
149
  it "should consider the process stopped if the command returns something non-0" do
151
150
  @provider.expects(:texecute).with(:status, ['/sbin/service', 'myservice', 'status'], false)
@@ -154,11 +153,13 @@ describe 'Puppet::Type::Service::Provider::Redhat',
154
153
  end
155
154
  }
156
155
  end
157
- describe "when hasstatus is not :true" do
156
+
157
+ context "when hasstatus is not :true" do
158
158
  it "should consider the service :running if it has a pid" do
159
159
  @provider.expects(:getpid).returns "1234"
160
160
  expect(@provider.status).to eq(:running)
161
161
  end
162
+
162
163
  it "should consider the service :stopped if it doesn't have a pid" do
163
164
  @provider.expects(:getpid).returns nil
164
165
  expect(@provider.status).to eq(:stopped)
@@ -166,7 +167,7 @@ describe 'Puppet::Type::Service::Provider::Redhat',
166
167
  end
167
168
  end
168
169
 
169
- describe "when restarting and hasrestart is not :true" do
170
+ context "when restarting and hasrestart is not :true" do
170
171
  it "should stop and restart the process with the server script" do
171
172
  @provider.expects(:texecute).with(:stop, ['/sbin/service', 'myservice', 'stop'], true)
172
173
  @provider.expects(:texecute).with(:start, ['/sbin/service', 'myservice', 'start'], true)
@@ -1,9 +1,3 @@
1
- #! /usr/bin/env ruby
2
- #
3
- # Unit testing for the Runit service Provider
4
- #
5
- # author Brice Figureau
6
- #
7
1
  require 'spec_helper'
8
2
 
9
3
  describe 'Puppet::Type::Service::Provider::Runit', unless: Puppet::Util::Platform.jruby? do
@@ -62,7 +56,7 @@ describe 'Puppet::Type::Service::Provider::Runit', unless: Puppet::Util::Platfor
62
56
  expect(@provider).to respond_to(:disable)
63
57
  end
64
58
 
65
- describe "when starting" do
59
+ context "when starting" do
66
60
  it "should enable the service if it is not enabled" do
67
61
  @provider.stubs(:sv)
68
62
 
@@ -80,21 +74,21 @@ describe 'Puppet::Type::Service::Provider::Runit', unless: Puppet::Util::Platfor
80
74
  end
81
75
  end
82
76
 
83
- describe "when stopping" do
77
+ context "when stopping" do
84
78
  it "should execute external command 'sv stop /etc/service/myservice'" do
85
79
  @provider.expects(:sv).with("stop", "/etc/service/myservice")
86
80
  @provider.stop
87
81
  end
88
82
  end
89
83
 
90
- describe "when restarting" do
84
+ context "when restarting" do
91
85
  it "should call 'sv restart /etc/service/myservice'" do
92
86
  @provider.expects(:sv).with("restart","/etc/service/myservice")
93
87
  @provider.restart
94
88
  end
95
89
  end
96
90
 
97
- describe "when enabling" do
91
+ context "when enabling" do
98
92
  it "should create a symlink between daemon dir and service dir", :if => Puppet.features.manages_symlinks? do
99
93
  daemon_path = File.join(@daemondir,"myservice")
100
94
  service_path = File.join(@servicedir,"myservice")
@@ -104,7 +98,7 @@ describe 'Puppet::Type::Service::Provider::Runit', unless: Puppet::Util::Platfor
104
98
  end
105
99
  end
106
100
 
107
- describe "when disabling" do
101
+ context "when disabling" do
108
102
  it "should remove the '/etc/service/myservice' symlink" do
109
103
  path = File.join(@servicedir,"myservice")
110
104
  # mocked_file = mock(path, :symlink? => true)
@@ -115,14 +109,14 @@ describe 'Puppet::Type::Service::Provider::Runit', unless: Puppet::Util::Platfor
115
109
  end
116
110
  end
117
111
 
118
- describe "when checking status" do
112
+ context "when checking status" do
119
113
  it "should call the external command 'sv status /etc/sv/myservice'" do
120
114
  @provider.expects(:sv).with('status',File.join(@daemondir,"myservice"))
121
115
  @provider.status
122
116
  end
123
117
  end
124
118
 
125
- describe "when checking status" do
119
+ context "when checking status" do
126
120
  it "and sv status fails, properly raise a Puppet::Error" do
127
121
  @provider.expects(:sv).with('status',File.join(@daemondir,"myservice")).raises(Puppet::ExecutionFailure, "fail: /etc/sv/myservice: file not found")
128
122
  expect { @provider.status }.to raise_error(Puppet::Error, 'Could not get status for service Service[myservice]: fail: /etc/sv/myservice: file not found')
@@ -140,5 +134,4 @@ describe 'Puppet::Type::Service::Provider::Runit', unless: Puppet::Util::Platfor
140
134
  expect(@provider.status).to eq(:stopped)
141
135
  end
142
136
  end
143
-
144
137
  end
@@ -1,13 +1,7 @@
1
- #! /usr/bin/env ruby
2
- #
3
- # Unit testing for the SMF service Provider
4
- #
5
- # author Dominic Cleal
6
- #
7
1
  require 'spec_helper'
8
2
 
9
3
  describe 'Puppet::Type::Service::Provider::Smf',
10
- if: Puppet.features.posix? && !Puppet::Util::Platform.jruby? do
4
+ if: Puppet.features.posix? && !Puppet::Util::Platform.jruby? do
11
5
  let(:provider_class) { Puppet::Type.type(:service).provider(:smf) }
12
6
 
13
7
  before(:each) do
@@ -25,7 +19,7 @@ describe 'Puppet::Type::Service::Provider::Smf',
25
19
  Facter.stubs(:value).with(:operatingsystemrelease).returns '11.2'
26
20
  end
27
21
 
28
- describe ".instances" do
22
+ context ".instances" do
29
23
  it "should have an instances method" do
30
24
  expect(provider_class).to respond_to :instances
31
25
  end
@@ -70,6 +64,10 @@ describe 'Puppet::Type::Service::Provider::Smf',
70
64
  end
71
65
 
72
66
  describe "when checking status" do
67
+ before(:each) do
68
+ @provider.stubs(:complete_service?).returns(true)
69
+ end
70
+
73
71
  it "should call the external command 'svcs /system/myservice' once" do
74
72
  @provider.expects(:svcs).with('-H', '-o', 'state,nstate', "/system/myservice").returns("online\t-")
75
73
  @provider.status
@@ -78,6 +76,11 @@ describe 'Puppet::Type::Service::Provider::Smf',
78
76
  @provider.stubs(:svcs).raises(Puppet::ExecutionFailure.new("no svc found"))
79
77
  expect(@provider.status).to eq(:stopped)
80
78
  end
79
+ it "should return stopped for an incomplete service on Solaris 11" do
80
+ Facter.stubs(:value).with(:operatingsystemrelease).returns('11.3')
81
+ @provider.stubs(:complete_service?).returns(false)
82
+ expect(@provider.status).to eq(:stopped)
83
+ end
81
84
  it "should return running if online in svcs output" do
82
85
  @provider.stubs(:svcs).returns("online\t-")
83
86
  expect(@provider.status).to eq(:running)
@@ -104,7 +107,7 @@ describe 'Puppet::Type::Service::Provider::Smf',
104
107
  end
105
108
  end
106
109
 
107
- describe "when starting" do
110
+ context "when starting" do
108
111
  it "should enable the service if it is not enabled" do
109
112
  @provider.expects(:status).returns :stopped
110
113
  @provider.expects(:texecute).with(:start, ['/usr/sbin/svcadm', :enable, '-rs', '/system/myservice'], true)
@@ -141,7 +144,7 @@ describe 'Puppet::Type::Service::Provider::Smf',
141
144
  end
142
145
  end
143
146
 
144
- describe "when starting a service with a manifest" do
147
+ context "when starting a service with a manifest" do
145
148
  before(:each) do
146
149
  @resource = Puppet::Type.type(:service).new(:name => "/system/myservice", :ensure => :running, :enable => :true, :manifest => "/tmp/myservice.xml")
147
150
  @provider = provider_class.new(@resource)
@@ -149,6 +152,7 @@ describe 'Puppet::Type::Service::Provider::Smf',
149
152
  end
150
153
 
151
154
  it "should import the manifest if service is missing" do
155
+ @provider.stubs(:complete_service?).returns(true)
152
156
  @provider.expects(:svcs).with('-l', '/system/myservice').raises(Puppet::ExecutionFailure, "Exited 1")
153
157
  @provider.expects(:svccfg).with(:import, "/tmp/myservice.xml")
154
158
  @provider.expects(:texecute).with(:start, ["/usr/sbin/svcadm", :enable, '-rs', "/system/myservice"], true)
@@ -164,7 +168,7 @@ describe 'Puppet::Type::Service::Provider::Smf',
164
168
  end
165
169
  end
166
170
 
167
- describe "when stopping" do
171
+ context "when stopping" do
168
172
  it "should execute external command 'svcadm disable /system/myservice'" do
169
173
  @provider.expects(:texecute).with(:stop, ["/usr/sbin/svcadm", :disable, '-s', "/system/myservice"], true)
170
174
  @provider.expects(:wait).with('offline', 'disabled', 'uninitialized')
@@ -178,8 +182,7 @@ describe 'Puppet::Type::Service::Provider::Smf',
178
182
  end
179
183
  end
180
184
 
181
- describe "when restarting" do
182
-
185
+ context "when restarting" do
183
186
  it "should error if timeout occurs while restarting the service" do
184
187
  @provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, '-s', "/system/myservice"], true)
185
188
  Timeout.expects(:timeout).with(60).raises(Timeout::Error)
@@ -212,6 +215,67 @@ describe 'Puppet::Type::Service::Provider::Smf',
212
215
  @provider.restart
213
216
  end
214
217
  end
218
+ end
219
+
220
+ describe '#service_fmri' do
221
+ it 'raises a Puppet::Error if the service resource matches multiple FMRIs' do
222
+ @provider.stubs(:svcs).with('-l', @provider.resource[:name]).returns(File.read(my_fixture('svcs_multiple_fmris.out')))
223
+
224
+ expect { @provider.service_fmri }.to raise_error do |error|
225
+ expect(error).to be_a(Puppet::Error)
226
+ expect(error.message).to match(@provider.resource[:name])
227
+ expect(error.message).to match('multiple')
228
+
229
+ matched_fmris = ["svc:/application/tstapp:one", "svc:/application/tstapp:two"]
230
+ expect(error.message).to match(matched_fmris.join(', '))
231
+ end
232
+ end
233
+
234
+ it 'raises a Puppet:ExecutionFailure if svcs fails' do
235
+ @provider.stubs(:svcs).with('-l', @provider.resource[:name]).raises(
236
+ Puppet::ExecutionFailure, 'svcs failed!'
237
+ )
238
+
239
+ expect { @provider.service_fmri }.to raise_error do |error|
240
+ expect(error).to be_a(Puppet::ExecutionFailure)
241
+ expect(error.message).to match('svcs failed!')
242
+ end
243
+ end
215
244
 
245
+ it "returns the service resource's fmri and memoizes it" do
246
+ @provider.stubs(:svcs).with('-l', @provider.resource[:name]).returns(File.read(my_fixture('svcs_fmri.out')))
247
+
248
+ expected_fmri = 'svc:/application/tstapp:default'
249
+
250
+ expect(@provider.service_fmri).to eql(expected_fmri)
251
+ expect(@provider.instance_variable_get(:@fmri)).to eql(expected_fmri)
252
+ end
253
+ end
254
+
255
+ describe '#complete_service?' do
256
+ let(:fmri) { 'service_fmri' }
257
+
258
+ before(:each) do
259
+ @provider.stubs(:service_fmri).returns(fmri)
260
+ end
261
+
262
+ it 'should raise a Puppet::Error if it is called on an older Solaris machine' do
263
+ Facter.stubs(:value).with(:operatingsystemrelease).returns('10.0')
264
+
265
+ expect { @provider.complete_service? }.to raise_error(Puppet::Error)
266
+ end
267
+
268
+ it 'should return false for an incomplete service' do
269
+ @provider.stubs(:svccfg).with('-s', fmri, 'listprop', 'general/complete').returns("")
270
+ expect(@provider.complete_service?).to be false
271
+ end
272
+
273
+ it 'should return true for a complete service' do
274
+ @provider.stubs(:svccfg)
275
+ .with('-s', fmri, 'listprop', 'general/complete')
276
+ .returns("general/complete astring")
277
+
278
+ expect(@provider.complete_service?).to be true
279
+ end
216
280
  end
217
281
  end
@@ -1,11 +1,7 @@
1
- #! /usr/bin/env ruby
2
- #
3
- # Unit testing for the AIX System Resource Controller (src) provider
4
- #
5
-
6
1
  require 'spec_helper'
7
2
 
8
- describe 'Puppet::Type::Service::Provider::Src', unless: Puppet::Util::Platform.jruby? do
3
+ describe 'Puppet::Type::Service::Provider::Src',
4
+ unless: Puppet::Util::Platform.jruby? do
9
5
  let(:provider_class) { Puppet::Type.type(:service).provider(:src) }
10
6
 
11
7
  if Puppet::Util::Platform.windows?
@@ -41,7 +37,7 @@ describe 'Puppet::Type::Service::Provider::Src', unless: Puppet::Util::Platform.
41
37
  @provider.stubs(:chitab)
42
38
  end
43
39
 
44
- describe ".instances" do
40
+ context ".instances" do
45
41
  it "should have a .instances method" do
46
42
  expect(provider_class).to respond_to :instances
47
43
  end
@@ -65,7 +61,7 @@ _EOF_
65
61
 
66
62
  end
67
63
 
68
- describe "when starting a service" do
64
+ context "when starting a service" do
69
65
  it "should execute the startsrc command" do
70
66
  @provider.expects(:execute).with(['/usr/bin/startsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
71
67
  @provider.expects(:status).returns :running
@@ -79,7 +75,7 @@ _EOF_
79
75
  end
80
76
  end
81
77
 
82
- describe "when stopping a service" do
78
+ context "when stopping a service" do
83
79
  it "should execute the stopsrc command" do
84
80
  @provider.expects(:execute).with(['/usr/bin/stopsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
85
81
  @provider.expects(:status).returns :stopped
@@ -93,7 +89,7 @@ _EOF_
93
89
  end
94
90
  end
95
91
 
96
- describe "should have a set of methods" do
92
+ context "should have a set of methods" do
97
93
  [:enabled?, :enable, :disable, :start, :stop, :status, :restart].each do |method|
98
94
  it "should have a #{method} method" do
99
95
  expect(@provider).to respond_to(method)
@@ -101,21 +97,21 @@ _EOF_
101
97
  end
102
98
  end
103
99
 
104
- describe "when enabling" do
100
+ context "when enabling" do
105
101
  it "should execute the mkitab command" do
106
102
  @provider.expects(:mkitab).with("myservice:2:once:/usr/bin/startsrc -s myservice").once
107
103
  @provider.enable
108
104
  end
109
105
  end
110
106
 
111
- describe "when disabling" do
107
+ context "when disabling" do
112
108
  it "should execute the rmitab command" do
113
109
  @provider.expects(:rmitab).with("myservice")
114
110
  @provider.disable
115
111
  end
116
112
  end
117
113
 
118
- describe "when checking if it is enabled" do
114
+ context "when checking if it is enabled" do
119
115
  it "should execute the lsitab command" do
120
116
  @provider.expects(:execute).with(['/usr/sbin/lsitab', 'myservice'], {:combine => true, :failonfail => false})
121
117
  $CHILD_STATUS.stubs(:exitstatus).returns(0)
@@ -135,8 +131,7 @@ _EOF_
135
131
  end
136
132
  end
137
133
 
138
-
139
- describe "when checking a subsystem's status" do
134
+ context "when checking a subsystem's status" do
140
135
  it "should execute status and return running if the subsystem is active" do
141
136
  sample_output = <<_EOF_
142
137
  Subsystem Group PID Status
@@ -173,7 +168,7 @@ _EOF_
173
168
  end
174
169
  end
175
170
 
176
- describe "when restarting a service" do
171
+ context "when restarting a service" do
177
172
  it "should execute restart which runs refresh" do
178
173
  sample_output = <<_EOF_
179
174
  #subsysname:synonym:cmdargs:path:uid:auditid:standin:standout:standerr:action:multi:contact:svrkey:svrmtype:priority:signorm:sigforce:display:waittime:grpname:
@@ -143,7 +143,25 @@ describe 'Puppet::Type::Service::Provider::Systemd', unless: Puppet::Util::Platf
143
143
  end
144
144
  end
145
145
 
146
- [:enabled?, :enable, :disable, :start, :stop, :status, :restart].each do |method|
146
+ [ '10', '11', '12', '13', '14', '15', '16', '17' ].each do |ver|
147
+ it "should not be the default provider on LinuxMint#{ver}" do
148
+ Facter.stubs(:value).with(:osfamily).returns(:debian)
149
+ Facter.stubs(:value).with(:operatingsystem).returns(:LinuxMint)
150
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("#{ver}")
151
+ expect(provider_class).not_to be_default
152
+ end
153
+ end
154
+
155
+ [ '18', '19' ].each do |ver|
156
+ it "should be the default provider on LinuxMint#{ver}" do
157
+ Facter.stubs(:value).with(:osfamily).returns(:debian)
158
+ Facter.stubs(:value).with(:operatingsystem).returns(:LinuxMint)
159
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("#{ver}")
160
+ expect(provider_class).to be_default
161
+ end
162
+ end
163
+
164
+ [:enabled?, :daemon_reload?, :enable, :disable, :start, :stop, :status, :restart].each do |method|
147
165
  it "should have a #{method} method" do
148
166
  expect(provider).to respond_to(method)
149
167
  end
@@ -169,6 +187,7 @@ describe 'Puppet::Type::Service::Provider::Systemd', unless: Puppet::Util::Platf
169
187
  describe "#start" do
170
188
  it "should use the supplied start command if specified" do
171
189
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service', :start => '/bin/foo'))
190
+ provider.expects(:daemon_reload?).returns('no')
172
191
  provider.expects(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
173
192
  provider.start
174
193
  end
@@ -176,6 +195,7 @@ describe 'Puppet::Type::Service::Provider::Systemd', unless: Puppet::Util::Platf
176
195
  it "should start the service with systemctl start otherwise" do
177
196
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
178
197
  provider.expects(:systemctl).with(:unmask, 'sshd.service')
198
+ provider.expects(:daemon_reload?).returns('no')
179
199
  provider.expects(:execute).with(['/bin/systemctl','start','sshd.service'], {:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
180
200
  provider.start
181
201
  end
@@ -183,6 +203,7 @@ describe 'Puppet::Type::Service::Provider::Systemd', unless: Puppet::Util::Platf
183
203
  it "should show journald logs on failure" do
184
204
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
185
205
  provider.expects(:systemctl).with(:unmask, 'sshd.service')
206
+ provider.expects(:daemon_reload?).returns('no')
186
207
  provider.expects(:execute).with(['/bin/systemctl','start','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
187
208
  .raises(Puppet::ExecutionFailure, "Failed to start sshd.service: Unit sshd.service failed to load: Invalid argument. See system logs and 'systemctl status sshd.service' for details.")
188
209
  journalctl_logs = <<-EOS
@@ -224,6 +245,20 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
224
245
  end
225
246
  end
226
247
 
248
+ describe "#daemon_reload?" do
249
+ it "should skip the systemctl daemon_reload if not required by the service" do
250
+ provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
251
+ provider.expects(:execute).with(['/bin/systemctl','show','sshd.service','--property=NeedDaemonReload'], :failonfail => false).returns "no"
252
+ provider.daemon_reload?
253
+ end
254
+ it "should run a systemctl daemon_reload if the service has been modified" do
255
+ provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
256
+ provider.expects(:execute).with(['/bin/systemctl','show','sshd.service','--property=NeedDaemonReload'], :failonfail => false).returns "yes"
257
+ provider.expects(:execute).with(['/bin/systemctl','daemon-reload'], :failonfail => false)
258
+ provider.daemon_reload?
259
+ end
260
+ end
261
+
227
262
  describe "#enabled?" do
228
263
  it "should return :true if the service is enabled" do
229
264
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
@@ -328,6 +363,7 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
328
363
  describe "#restart" do
329
364
  it "should use the supplied restart command if specified" do
330
365
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :restart => '/bin/foo'))
366
+ provider.expects(:daemon_reload?).returns('no')
331
367
  provider.expects(:execute).with(['/bin/systemctl','restart','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true).never
332
368
  provider.expects(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
333
369
  provider.restart
@@ -335,12 +371,14 @@ Jun 14 21:43:23 foo.example.com systemd[1]: sshd.service lacks both ExecStart= a
335
371
 
336
372
  it "should restart the service with systemctl restart" do
337
373
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
374
+ provider.expects(:daemon_reload?).returns('no')
338
375
  provider.expects(:execute).with(['/bin/systemctl','restart','sshd.service'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
339
376
  provider.restart
340
377
  end
341
378
 
342
379
  it "should show journald logs on failure" do
343
380
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd.service'))
381
+ provider.expects(:daemon_reload?).returns('no')
344
382
  provider.expects(:execute).with(['/bin/systemctl','restart','sshd.service'],{:failonfail => true, :override_locale => false, :squelch => false, :combine => true})
345
383
  .raises(Puppet::ExecutionFailure, "Failed to restart sshd.service: Unit sshd.service failed to load: Invalid argument. See system logs and 'systemctl status sshd.service' for details.")
346
384
  journalctl_logs = <<-EOS
@@ -22,6 +22,8 @@ describe 'Puppet::Type::Service::Provider::Windows',
22
22
  # make sure we never actually execute anything (there are two execute methods)
23
23
  provider.class.expects(:execute).never
24
24
  provider.expects(:execute).never
25
+
26
+ service_util.stubs(:exists?).with(resource[:name]).returns(true)
25
27
  end
26
28
 
27
29
  describe ".instances" do
@@ -34,9 +36,19 @@ describe 'Puppet::Type::Service::Provider::Windows',
34
36
  end
35
37
 
36
38
  describe "#start" do
39
+ before(:each) do
40
+ provider.stubs(:status).returns(:stopped)
41
+ end
42
+
43
+ it "should resume a paused service" do
44
+ provider.stubs(:status).returns(:paused)
45
+ service_util.expects(:resume)
46
+ provider.start
47
+ end
48
+
37
49
  it "should start the service" do
38
50
  service_util.expects(:service_start_type).with(name).returns(:SERVICE_AUTO_START)
39
- service_util.expects(:start).with(name)
51
+ service_util.expects(:start)
40
52
  provider.start
41
53
  end
42
54
 
@@ -51,7 +63,7 @@ describe 'Puppet::Type::Service::Provider::Windows',
51
63
 
52
64
  it "should enable if managing enable and enable is true" do
53
65
  resource[:enable] = :true
54
- service_util.expects(:start).with(name)
66
+ service_util.expects(:start)
55
67
  service_util.expects(:set_startup_mode).with(name, :SERVICE_AUTO_START)
56
68
 
57
69
  provider.start
@@ -59,7 +71,7 @@ describe 'Puppet::Type::Service::Provider::Windows',
59
71
 
60
72
  it "should manual start if managing enable and enable is false" do
61
73
  resource[:enable] = :false
62
- service_util.expects(:start).with(name)
74
+ service_util.expects(:start)
63
75
  service_util.expects(:set_startup_mode).with(name, :SERVICE_DEMAND_START)
64
76
 
65
77
  provider.start
@@ -69,18 +81,32 @@ describe 'Puppet::Type::Service::Provider::Windows',
69
81
 
70
82
  describe "#stop" do
71
83
  it "should stop a running service" do
72
- service_util.expects(:stop).with(name)
84
+ service_util.expects(:stop)
73
85
 
74
86
  provider.stop
75
87
  end
76
88
  end
77
89
 
78
90
  describe "#status" do
91
+ it "should report a nonexistent service as stopped" do
92
+ service_util.stubs(:exists?).with(resource[:name]).returns(false)
93
+
94
+ expect(provider.status).to eql(:stopped)
95
+ end
96
+
79
97
  [
80
- :SERVICE_STOPPED,
81
98
  :SERVICE_PAUSED,
82
- :SERVICE_STOP_PENDING,
83
- :SERVICE_PAUSE_PENDING,
99
+ :SERVICE_PAUSE_PENDING
100
+ ].each do |state|
101
+ it "should report a #{state} service as paused" do
102
+ service_util.expects(:service_state).with(name).returns(state)
103
+ expect(provider.status).to eq(:paused)
104
+ end
105
+ end
106
+
107
+ [
108
+ :SERVICE_STOPPED,
109
+ :SERVICE_STOP_PENDING
84
110
  ].each do |state|
85
111
  it "should report a #{state} service as stopped" do
86
112
  service_util.expects(:service_state).with(name).returns(state)
@@ -121,6 +147,12 @@ describe 'Puppet::Type::Service::Provider::Windows',
121
147
  end
122
148
 
123
149
  describe "#enabled?" do
150
+ it "should report a nonexistent service as false" do
151
+ service_util.stubs(:exists?).with(resource[:name]).returns(false)
152
+
153
+ expect(provider.enabled?).to eql(:false)
154
+ end
155
+
124
156
  it "should report a service with a startup type of manual as manual" do
125
157
  service_util.expects(:service_start_type).with(name).returns(:SERVICE_DEMAND_START)
126
158
  expect(provider.enabled?).to eq(:manual)
@@ -70,11 +70,23 @@ describe 'Puppet::Type::User::Provider::Aix' do
70
70
  end
71
71
  end
72
72
 
73
- describe '.groups_to_groups' do
73
+ describe '.groups_attribute_to_property' do
74
+ it "reads the user's groups from the etc/groups file" do
75
+ groups = ['system', 'adm']
76
+ Puppet::Util::POSIX.stubs(:groups_of).with(resource[:name]).returns(groups)
77
+
78
+ actual_groups = provider_class.groups_attribute_to_property(provider, 'unused_value')
79
+ expected_groups = groups.join(',')
80
+
81
+ expect(actual_groups).to eql(expected_groups)
82
+ end
83
+ end
84
+
85
+ describe '.groups_property_to_attribute' do
74
86
  it 'raises an ArgumentError if the groups are space-separated' do
75
87
  groups = "foo bar baz"
76
88
  expect do
77
- provider_class.groups_to_groups(groups)
89
+ provider_class.groups_property_to_attribute(groups)
78
90
  end.to raise_error do |error|
79
91
  expect(error).to be_a(ArgumentError)
80
92
 
@@ -84,6 +96,33 @@ describe 'Puppet::Type::User::Provider::Aix' do
84
96
  end
85
97
  end
86
98
 
99
+ describe '#gid=' do
100
+ let(:value) { 'new_pgrp' }
101
+
102
+ let(:old_pgrp) { 'old_pgrp' }
103
+ let(:cur_groups) { 'system,adm' }
104
+ before(:each) do
105
+ provider.stubs(:gid).returns(old_pgrp)
106
+ provider.stubs(:groups).returns(cur_groups)
107
+ provider.stubs(:set)
108
+ end
109
+
110
+ it 'raises a Puppet::Error if it fails to set the groups property' do
111
+ provider.stubs(:set)
112
+ .with(:groups, cur_groups)
113
+ .raises(Puppet::ExecutionFailure, 'failed to reset the groups!')
114
+
115
+ expect { provider.gid = value }.to raise_error do |error|
116
+ expect(error).to be_a(Puppet::Error)
117
+
118
+ expect(error.message).to match('groups')
119
+ expect(error.message).to match(cur_groups)
120
+ expect(error.message).to match(old_pgrp)
121
+ expect(error.message).to match(value)
122
+ end
123
+ end
124
+ end
125
+
87
126
  describe '#parse_password' do
88
127
  def call_parse_password
89
128
  File.open(my_fixture('aix_passwd_file.out')) do |f|
@@ -163,9 +202,11 @@ describe 'Puppet::Type::User::Provider::Aix' do
163
202
  describe '#create' do
164
203
  it 'should create the user' do
165
204
  provider.resource.stubs(:should).with(anything).returns(nil)
205
+ provider.resource.stubs(:should).with(:groups).returns('g1,g2')
166
206
  provider.resource.stubs(:should).with(:password).returns('password')
167
207
 
168
208
  provider.expects(:execute)
209
+ provider.expects(:groups=).with('g1,g2')
169
210
  provider.expects(:password=).with('password')
170
211
 
171
212
  provider.create