puppet 3.0.0.rc5 → 3.0.0.rc7

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 (398) hide show
  1. data/LICENSE +1 -1
  2. data/README_DEVELOPER.md +209 -1
  3. data/README_HIERA.md +148 -0
  4. data/Rakefile +25 -27
  5. data/bin/extlookup2hiera +56 -0
  6. data/conf/auth.conf +34 -34
  7. data/examples/hiera/README.md +91 -0
  8. data/examples/hiera/etc/hiera.yaml +15 -0
  9. data/examples/hiera/etc/hieradb/common.yaml +3 -0
  10. data/examples/hiera/etc/hieradb/dc1.yaml +6 -0
  11. data/examples/hiera/etc/hieradb/development.yaml +2 -0
  12. data/examples/hiera/etc/puppet.conf +3 -0
  13. data/examples/hiera/modules/data/manifests/common.pp +3 -0
  14. data/examples/hiera/modules/ntp/manifests/config.pp +5 -0
  15. data/examples/hiera/modules/ntp/manifests/data.pp +3 -0
  16. data/examples/hiera/modules/ntp/templates/ntp.conf.erb +3 -0
  17. data/examples/hiera/modules/users/manifests/common.pp +3 -0
  18. data/examples/hiera/modules/users/manifests/dc1.pp +3 -0
  19. data/examples/hiera/modules/users/manifests/development.pp +3 -0
  20. data/examples/hiera/site.pp +3 -0
  21. data/ext/build_defaults.yaml +23 -0
  22. data/ext/debian/README.Debian +8 -0
  23. data/ext/debian/README.source +2 -0
  24. data/ext/debian/TODO.Debian +1 -0
  25. data/ext/debian/changelog.erb +1104 -0
  26. data/ext/debian/compat +1 -0
  27. data/ext/debian/control +143 -0
  28. data/ext/debian/copyright +361 -0
  29. data/ext/debian/docs +1 -0
  30. data/ext/debian/fileserver.conf +17 -0
  31. data/ext/debian/puppet-common.dirs +8 -0
  32. data/ext/debian/puppet-common.install +4 -0
  33. data/ext/debian/puppet-common.lintian-overrides +5 -0
  34. data/ext/debian/puppet-common.manpages +2 -0
  35. data/ext/debian/puppet-common.postinst +35 -0
  36. data/ext/debian/puppet-common.postrm +32 -0
  37. data/ext/debian/puppet-el.dirs +1 -0
  38. data/ext/debian/puppet-el.emacsen-install +25 -0
  39. data/ext/debian/puppet-el.emacsen-remove +11 -0
  40. data/ext/debian/puppet-el.emacsen-startup +9 -0
  41. data/ext/debian/puppet-el.install +1 -0
  42. data/ext/debian/puppet-testsuite.install +2 -0
  43. data/ext/debian/puppet-testsuite.lintian-overrides +4 -0
  44. data/ext/debian/puppet.conf +14 -0
  45. data/ext/debian/puppet.default +7 -0
  46. data/ext/debian/puppet.init +118 -0
  47. data/ext/debian/puppet.lintian-overrides +3 -0
  48. data/ext/debian/puppet.logrotate +11 -0
  49. data/ext/debian/puppet.manpages +32 -0
  50. data/ext/debian/puppet.postinst +20 -0
  51. data/ext/debian/puppet.postrm +20 -0
  52. data/ext/debian/puppet.preinst +20 -0
  53. data/ext/debian/puppetmaster-common.install +2 -0
  54. data/ext/debian/puppetmaster-common.manpages +2 -0
  55. data/ext/debian/puppetmaster-common.puppetqd.default +27 -0
  56. data/ext/debian/puppetmaster-common.puppetqd.init +84 -0
  57. data/ext/debian/puppetmaster-passenger.dirs +4 -0
  58. data/ext/debian/puppetmaster-passenger.postinst +66 -0
  59. data/ext/debian/puppetmaster-passenger.postrm +33 -0
  60. data/ext/debian/puppetmaster.README.debian +16 -0
  61. data/ext/debian/puppetmaster.default +38 -0
  62. data/ext/debian/puppetmaster.init +158 -0
  63. data/ext/debian/puppetmaster.lintian-overrides +3 -0
  64. data/ext/debian/puppetmaster.postinst +20 -0
  65. data/ext/debian/puppetmaster.postrm +5 -0
  66. data/ext/debian/puppetmaster.preinst +22 -0
  67. data/ext/debian/rules +128 -0
  68. data/ext/debian/source/format +1 -0
  69. data/ext/debian/source/options +1 -0
  70. data/ext/debian/vim-puppet.README.Debian +13 -0
  71. data/ext/debian/vim-puppet.dirs +3 -0
  72. data/ext/debian/vim-puppet.yaml +5 -0
  73. data/ext/debian/watch +2 -0
  74. data/ext/emacs/puppet-mode.el +1 -0
  75. data/ext/envpuppet +4 -0
  76. data/ext/envpuppet.bat +3 -2
  77. data/{conf → ext}/freebsd/puppetd +0 -0
  78. data/{conf → ext}/freebsd/puppetmasterd +0 -0
  79. data/{conf → ext}/gentoo/conf.d/puppet +0 -0
  80. data/{conf → ext}/gentoo/conf.d/puppetmaster +0 -0
  81. data/{conf → ext}/gentoo/init.d/puppet +0 -0
  82. data/{conf → ext}/gentoo/init.d/puppetmaster +0 -0
  83. data/{conf → ext}/gentoo/puppet/fileserver.conf +0 -0
  84. data/{conf → ext}/gentoo/puppet/puppet.conf +0 -0
  85. data/ext/ips/puppet-agent +49 -0
  86. data/ext/ips/puppet-master +44 -0
  87. data/ext/ips/puppet.conf +29 -0
  88. data/ext/ips/puppet.p5m.erb +12 -0
  89. data/ext/ips/puppetagent.xml +46 -0
  90. data/ext/ips/puppetmaster.xml +42 -0
  91. data/ext/ips/rules +19 -0
  92. data/ext/ips/transforms +34 -0
  93. data/{conf → ext}/osx/PackageInfo.plist +0 -0
  94. data/{conf → ext}/osx/createpackage.sh +1 -1
  95. data/ext/osx/file_mapping.yaml +33 -0
  96. data/ext/osx/preflight.erb +37 -0
  97. data/{tasks/rake/templates → ext/osx}/prototype.plist.erb +0 -0
  98. data/ext/packaging/README-Solaris.md +117 -0
  99. data/ext/packaging/README.md +89 -0
  100. data/ext/packaging/tasks/00_utils.rb +236 -0
  101. data/ext/packaging/tasks/10_setupvars.rake +62 -0
  102. data/ext/packaging/tasks/apple.rake +201 -0
  103. data/ext/packaging/tasks/clean.rake +5 -0
  104. data/ext/packaging/tasks/deb.rake +105 -0
  105. data/ext/packaging/tasks/gem.rake +52 -0
  106. data/ext/packaging/tasks/ips.rake +78 -0
  107. data/ext/packaging/tasks/mock.rake +88 -0
  108. data/ext/packaging/tasks/release.rake +20 -0
  109. data/ext/packaging/tasks/rpm.rake +39 -0
  110. data/ext/packaging/tasks/ship.rake +34 -0
  111. data/ext/packaging/tasks/sign.rake +76 -0
  112. data/ext/packaging/tasks/tar.rake +20 -0
  113. data/ext/project_data.yaml +25 -0
  114. data/ext/rack/files/apache2.conf +2 -1
  115. data/{conf → ext}/redhat/client.init +0 -0
  116. data/{conf → ext}/redhat/client.sysconfig +0 -0
  117. data/{conf → ext}/redhat/fileserver.conf +0 -0
  118. data/{conf → ext}/redhat/logrotate +0 -0
  119. data/{conf → ext}/redhat/puppet.conf +0 -0
  120. data/{conf/redhat/puppet.spec → ext/redhat/puppet.spec.erb} +140 -33
  121. data/{conf → ext}/redhat/queue.init +0 -0
  122. data/{conf → ext}/redhat/rundir-perms.patch +0 -0
  123. data/{conf → ext}/redhat/server.init +0 -0
  124. data/{conf → ext}/redhat/server.sysconfig +0 -0
  125. data/{conf → ext}/solaris/pkginfo +0 -0
  126. data/{conf → ext}/solaris/smf/puppetd.xml +0 -0
  127. data/{conf → ext}/solaris/smf/puppetmasterd.xml +0 -0
  128. data/{conf → ext}/solaris/smf/svc-puppetd +0 -0
  129. data/{conf → ext}/solaris/smf/svc-puppetmasterd +0 -0
  130. data/{conf → ext}/suse/client.init +0 -0
  131. data/{conf → ext}/suse/fileserver.conf +0 -0
  132. data/{conf → ext}/suse/logrotate +0 -0
  133. data/{conf → ext}/suse/puppet.conf +0 -0
  134. data/{conf → ext}/suse/puppet.spec +1 -1
  135. data/{conf → ext}/suse/server.init +0 -0
  136. data/ext/systemd/puppetagent.service +13 -0
  137. data/ext/systemd/puppetmaster.service +13 -0
  138. data/{conf → ext}/windows/eventlog/Rakefile +0 -0
  139. data/{conf → ext}/windows/eventlog/puppetres.dll +0 -0
  140. data/{conf → ext}/windows/eventlog/puppetres.mc +0 -0
  141. data/ext/windows/service/daemon.bat +6 -0
  142. data/ext/windows/service/daemon.rb +90 -0
  143. data/install.rb +22 -32
  144. data/lib/hiera/backend/puppet_backend.rb +102 -0
  145. data/lib/hiera/scope.rb +42 -0
  146. data/lib/hiera_puppet.rb +89 -0
  147. data/lib/puppet.rb +1 -1
  148. data/lib/puppet/agent.rb +2 -2
  149. data/lib/puppet/agent/locker.rb +12 -9
  150. data/lib/puppet/application.rb +10 -8
  151. data/lib/puppet/application/agent.rb +12 -8
  152. data/lib/puppet/application/apply.rb +2 -2
  153. data/lib/puppet/application/cert.rb +6 -6
  154. data/lib/puppet/application/certificate.rb +1 -4
  155. data/lib/puppet/application/describe.rb +1 -1
  156. data/lib/puppet/application/device.rb +5 -2
  157. data/lib/puppet/application/doc.rb +1 -1
  158. data/lib/puppet/application/face_base.rb +3 -13
  159. data/lib/puppet/application/filebucket.rb +1 -1
  160. data/lib/puppet/application/inspect.rb +1 -1
  161. data/lib/puppet/application/kick.rb +4 -2
  162. data/lib/puppet/application/master.rb +2 -2
  163. data/lib/puppet/application/queue.rb +3 -1
  164. data/lib/puppet/application/resource.rb +1 -1
  165. data/lib/puppet/configurer.rb +11 -7
  166. data/lib/puppet/configurer/downloader.rb +1 -4
  167. data/lib/puppet/daemon.rb +4 -4
  168. data/lib/puppet/defaults.rb +64 -60
  169. data/lib/puppet/external/dot.rb +1 -1
  170. data/lib/puppet/external/pson/common.rb +15 -0
  171. data/lib/puppet/external/pson/pure.rb +0 -62
  172. data/lib/puppet/external/pson/pure/generator.rb +1 -1
  173. data/lib/puppet/external/pson/pure/parser.rb +2 -2
  174. data/lib/puppet/face/ca.rb +19 -14
  175. data/lib/puppet/face/config.rb +2 -2
  176. data/lib/puppet/face/facts.rb +1 -1
  177. data/lib/puppet/face/help/action.erb +0 -1
  178. data/lib/puppet/face/help/face.erb +0 -1
  179. data/lib/puppet/face/help/man.erb +3 -6
  180. data/lib/puppet/face/module/install.rb +1 -1
  181. data/lib/puppet/face/module/list.rb +1 -1
  182. data/lib/puppet/face/module/uninstall.rb +1 -1
  183. data/lib/puppet/face/node.rb +1 -1
  184. data/lib/puppet/face/node/clean.rb +30 -25
  185. data/lib/puppet/feature/base.rb +0 -3
  186. data/lib/puppet/feature/rails.rb +2 -1
  187. data/lib/puppet/file_serving/terminus_selector.rb +1 -1
  188. data/lib/puppet/indirector/catalog/active_record.rb +5 -0
  189. data/lib/puppet/indirector/catalog/static_compiler.rb +2 -3
  190. data/lib/puppet/indirector/certificate/disabled_ca.rb +22 -0
  191. data/lib/puppet/indirector/certificate_request/disabled_ca.rb +22 -0
  192. data/lib/puppet/indirector/certificate_revocation_list/disabled_ca.rb +22 -0
  193. data/lib/puppet/indirector/face.rb +3 -3
  194. data/lib/puppet/indirector/facts/active_record.rb +5 -0
  195. data/lib/puppet/indirector/facts/facter.rb +1 -4
  196. data/lib/puppet/indirector/facts/inventory_active_record.rb +6 -0
  197. data/lib/puppet/indirector/file_bucket_file/file.rb +2 -1
  198. data/lib/puppet/indirector/indirection.rb +2 -2
  199. data/lib/puppet/indirector/key/disabled_ca.rb +22 -0
  200. data/lib/puppet/indirector/node/active_record.rb +5 -0
  201. data/lib/puppet/indirector/request.rb +4 -0
  202. data/lib/puppet/indirector/resource/active_record.rb +5 -0
  203. data/lib/puppet/network/authentication.rb +30 -0
  204. data/lib/puppet/network/http.rb +0 -13
  205. data/lib/puppet/network/http/connection.rb +10 -2
  206. data/lib/puppet/network/http/handler.rb +8 -0
  207. data/lib/puppet/network/http/mongrel/rest.rb +5 -0
  208. data/lib/puppet/network/http/rack/rest.rb +7 -0
  209. data/lib/puppet/network/http/webrick.rb +3 -6
  210. data/lib/puppet/network/http/webrick/rest.rb +4 -0
  211. data/lib/puppet/network/server.rb +9 -33
  212. data/lib/puppet/node.rb +1 -1
  213. data/lib/puppet/node/facts.rb +0 -1
  214. data/lib/puppet/parser/compiler.rb +1 -1
  215. data/lib/puppet/parser/functions.rb +12 -1
  216. data/lib/puppet/parser/functions/hiera.rb +8 -0
  217. data/lib/puppet/parser/functions/hiera_array.rb +8 -0
  218. data/lib/puppet/parser/functions/hiera_hash.rb +8 -0
  219. data/lib/puppet/parser/functions/hiera_include.rb +11 -0
  220. data/lib/puppet/parser/functions/shellquote.rb +21 -29
  221. data/lib/puppet/parser/lexer.rb +2 -1
  222. data/lib/puppet/parser/scope.rb +8 -0
  223. data/lib/puppet/provider/exec/windows.rb +1 -1
  224. data/lib/puppet/provider/group/groupadd.rb +2 -3
  225. data/lib/puppet/provider/package/pkg.rb +37 -10
  226. data/lib/puppet/provider/service/daemontools.rb +1 -1
  227. data/lib/puppet/provider/service/launchd.rb +1 -1
  228. data/lib/puppet/provider/service/redhat.rb +1 -1
  229. data/lib/puppet/provider/service/runit.rb +1 -1
  230. data/lib/puppet/provider/user/useradd.rb +8 -3
  231. data/lib/puppet/provider/user/windows_adsi.rb +11 -0
  232. data/lib/puppet/provider/zfs/zfs.rb +29 -2
  233. data/lib/puppet/provider/zone/solaris.rb +144 -39
  234. data/lib/puppet/provider/zpool/zpool.rb +7 -10
  235. data/lib/puppet/settings.rb +50 -86
  236. data/lib/puppet/settings/duration_setting.rb +34 -0
  237. data/lib/puppet/settings/terminus_setting.rb +16 -0
  238. data/lib/puppet/ssl/base.rb +49 -9
  239. data/lib/puppet/ssl/certificate.rb +13 -9
  240. data/lib/puppet/ssl/certificate_authority.rb +4 -0
  241. data/lib/puppet/ssl/certificate_authority/interface.rb +10 -17
  242. data/lib/puppet/ssl/certificate_factory.rb +4 -21
  243. data/lib/puppet/ssl/certificate_request.rb +1 -10
  244. data/lib/puppet/ssl/certificate_revocation_list.rb +1 -3
  245. data/lib/puppet/ssl/digest.rb +20 -0
  246. data/lib/puppet/ssl/host.rb +31 -6
  247. data/lib/puppet/test/test_helper.rb +1 -1
  248. data/lib/puppet/transaction/report.rb +2 -1
  249. data/lib/puppet/type.rb +1 -1
  250. data/lib/puppet/type/augeas.rb +1 -1
  251. data/lib/puppet/type/cron.rb +1 -1
  252. data/lib/puppet/type/exec.rb +7 -8
  253. data/lib/puppet/type/file.rb +1 -1
  254. data/lib/puppet/type/file/content.rb +2 -2
  255. data/lib/puppet/type/file/ensure.rb +1 -1
  256. data/lib/puppet/type/file/mode.rb +1 -1
  257. data/lib/puppet/type/file/selcontext.rb +6 -2
  258. data/lib/puppet/type/file/source.rb +1 -1
  259. data/lib/puppet/type/schedule.rb +1 -1
  260. data/lib/puppet/type/scheduled_task.rb +1 -1
  261. data/lib/puppet/type/tidy.rb +1 -1
  262. data/lib/puppet/type/zone.rb +126 -253
  263. data/lib/puppet/util.rb +10 -23
  264. data/lib/puppet/util/adsi.rb +22 -14
  265. data/lib/puppet/util/log/destinations.rb +7 -0
  266. data/lib/puppet/util/log/rate_limited_logger.rb +40 -0
  267. data/lib/puppet/util/metric.rb +2 -2
  268. data/lib/puppet/util/monkey_patches.rb +8 -0
  269. data/lib/puppet/util/platform.rb +7 -0
  270. data/lib/puppet/util/selinux.rb +31 -36
  271. data/lib/puppet/util/windows/error.rb +1 -1
  272. data/lib/puppet/util/windows/process.rb +3 -3
  273. data/lib/puppet/util/windows/security.rb +7 -7
  274. data/lib/puppet/util/windows/user.rb +65 -2
  275. data/lib/puppet/util/zaml.rb +90 -46
  276. data/lib/puppet/version.rb +1 -1
  277. data/spec/fixtures/hiera.yaml +9 -0
  278. data/spec/fixtures/manifests/site.pp +0 -0
  279. data/spec/integration/defaults_spec.rb +25 -11
  280. data/spec/integration/faces/ca_spec.rb +11 -16
  281. data/spec/integration/network/server/webrick_spec.rb +14 -27
  282. data/spec/integration/node_spec.rb +4 -1
  283. data/spec/integration/parser/functions/require_spec.rb +3 -3
  284. data/spec/integration/parser/undef_param_spec.rb +88 -0
  285. data/spec/integration/provider/mount_spec.rb +4 -1
  286. data/spec/integration/ssl/certificate_authority_spec.rb +18 -0
  287. data/spec/lib/puppet_spec/files.rb +3 -3
  288. data/spec/lib/puppet_spec/settings.rb +0 -1
  289. data/spec/shared_contexts/platform.rb +8 -0
  290. data/spec/spec_helper.rb +6 -0
  291. data/spec/unit/agent/locker_spec.rb +8 -2
  292. data/spec/unit/application/agent_spec.rb +29 -7
  293. data/spec/unit/application/apply_spec.rb +1 -1
  294. data/spec/unit/application/device_spec.rb +18 -1
  295. data/spec/unit/application/face_base_spec.rb +16 -2
  296. data/spec/unit/application/kick_spec.rb +8 -0
  297. data/spec/unit/application/queue_spec.rb +5 -0
  298. data/spec/unit/application_spec.rb +13 -23
  299. data/spec/unit/configurer/downloader_spec.rb +2 -11
  300. data/spec/unit/configurer_spec.rb +6 -0
  301. data/spec/unit/face/node_spec.rb +1 -1
  302. data/spec/unit/hiera/backend/puppet_backend_spec.rb +140 -0
  303. data/spec/unit/hiera/scope_spec.rb +62 -0
  304. data/spec/unit/hiera_puppet_spec.rb +111 -0
  305. data/spec/unit/indirector/catalog/active_record_spec.rb +4 -0
  306. data/spec/unit/indirector/catalog/static_compiler_spec.rb +194 -0
  307. data/spec/unit/indirector/certificate/disabled_ca_spec.rb +33 -0
  308. data/spec/unit/indirector/certificate_request/disabled_ca_spec.rb +33 -0
  309. data/spec/unit/indirector/certificate_revocation_list/disabled_ca_spec.rb +33 -0
  310. data/spec/unit/indirector/facts/active_record_spec.rb +37 -26
  311. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +5 -0
  312. data/spec/unit/indirector/hiera_spec.rb +2 -1
  313. data/spec/unit/indirector/key/disabled_ca_spec.rb +33 -0
  314. data/spec/unit/indirector/node/active_record_spec.rb +7 -0
  315. data/spec/unit/indirector/request_spec.rb +22 -0
  316. data/spec/unit/indirector/resource/active_record_spec.rb +5 -0
  317. data/spec/unit/module_tool/application_spec.rb +1 -1
  318. data/spec/unit/network/authentication_spec.rb +86 -0
  319. data/spec/unit/network/http/connection_spec.rb +21 -0
  320. data/spec/unit/network/http/handler_spec.rb +12 -0
  321. data/spec/unit/network/http/rack/rest_spec.rb +7 -0
  322. data/spec/unit/network/http/webrick_spec.rb +11 -26
  323. data/spec/unit/network/server_spec.rb +79 -192
  324. data/spec/unit/node/facts_spec.rb +2 -2
  325. data/spec/unit/parser/ast/vardef_spec.rb +4 -4
  326. data/spec/unit/parser/files_spec.rb +3 -0
  327. data/spec/unit/parser/functions/defined_spec.rb +5 -5
  328. data/spec/unit/parser/functions/fqdn_rand_spec.rb +1 -1
  329. data/spec/unit/parser/functions/hiera_array_spec.rb +23 -0
  330. data/spec/unit/parser/functions/hiera_hash_spec.rb +19 -0
  331. data/spec/unit/parser/functions/hiera_include_spec.rb +19 -0
  332. data/spec/unit/parser/functions/hiera_spec.rb +21 -0
  333. data/spec/unit/parser/functions/include_spec.rb +3 -3
  334. data/spec/unit/parser/functions/realize_spec.rb +3 -3
  335. data/spec/unit/parser/functions/require_spec.rb +5 -5
  336. data/spec/unit/parser/functions/shellquote_spec.rb +0 -4
  337. data/spec/unit/parser/functions_spec.rb +6 -10
  338. data/spec/unit/parser/lexer_spec.rb +13 -0
  339. data/spec/unit/parser/scope_spec.rb +16 -1
  340. data/spec/unit/provider/exec/posix_spec.rb +7 -6
  341. data/spec/unit/provider/group/groupadd_spec.rb +36 -30
  342. data/spec/unit/provider/package/pkg_spec.rb +16 -2
  343. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  344. data/spec/unit/provider/sshkey/parsed_spec.rb +4 -0
  345. data/spec/unit/provider/user/user_role_add_spec.rb +125 -126
  346. data/spec/unit/provider/user/useradd_spec.rb +147 -118
  347. data/spec/unit/provider/user/windows_adsi_spec.rb +22 -0
  348. data/spec/unit/provider/zone/solaris_spec.rb +126 -7
  349. data/spec/unit/provider/zpool/zpool_spec.rb +4 -3
  350. data/spec/unit/puppet_spec.rb +7 -0
  351. data/spec/unit/settings/duration_setting_spec.rb +45 -0
  352. data/spec/unit/settings/terminus_setting_spec.rb +28 -0
  353. data/spec/unit/settings_spec.rb +21 -23
  354. data/spec/unit/ssl/base_spec.rb +68 -19
  355. data/spec/unit/ssl/certificate_authority/interface_spec.rb +19 -30
  356. data/spec/unit/ssl/certificate_authority_spec.rb +3 -2
  357. data/spec/unit/ssl/certificate_factory_spec.rb +15 -6
  358. data/spec/unit/ssl/certificate_request_spec.rb +80 -113
  359. data/spec/unit/ssl/certificate_revocation_list_spec.rb +1 -1
  360. data/spec/unit/ssl/certificate_spec.rb +26 -2
  361. data/spec/unit/ssl/digest_spec.rb +35 -0
  362. data/spec/unit/ssl/host_spec.rb +73 -27
  363. data/spec/unit/ssl/key_spec.rb +0 -4
  364. data/spec/unit/type/exec_spec.rb +1 -1
  365. data/spec/unit/type/file_spec.rb +2 -1
  366. data/spec/unit/type/scheduled_task_spec.rb +2 -2
  367. data/spec/unit/type/zone_spec.rb +52 -10
  368. data/spec/unit/util/adsi_spec.rb +19 -0
  369. data/spec/unit/util/checksums_spec.rb +2 -3
  370. data/spec/unit/util/execution_spec.rb +1 -1
  371. data/spec/unit/util/log/destinations_spec.rb +1 -0
  372. data/spec/unit/util/log/rate_limited_logger_spec.rb +51 -0
  373. data/spec/unit/util/logging_spec.rb +6 -6
  374. data/spec/unit/util/selinux_spec.rb +24 -32
  375. data/spec/unit/util/zaml_spec.rb +94 -6
  376. data/spec/unit/util_spec.rb +17 -0
  377. data/spec/watchr.rb +2 -6
  378. data/tasks/{rake/manpages.rake → manpages.rake} +0 -0
  379. data/tasks/{rake/parser.rake → parser.rake} +0 -0
  380. metadata +1003 -119
  381. data/CHANGELOG +0 -9233
  382. data/conf/osx/preflight +0 -24
  383. data/lib/puppet/network/http/mongrel.rb +0 -35
  384. data/lib/puppet/util/config_timeout.rb +0 -24
  385. data/spec/unit/network/http/mongrel/rest_spec.rb +0 -257
  386. data/spec/unit/network/http/mongrel_spec.rb +0 -91
  387. data/spec/unit/network/http_spec.rb +0 -31
  388. data/spec/unit/util/config_timeout_spec.rb +0 -57
  389. data/tasks/rake/apple.rake +0 -176
  390. data/tasks/rake/changelog.rake +0 -15
  391. data/tasks/rake/ci.rake +0 -22
  392. data/tasks/rake/dailybuild.rake +0 -9
  393. data/tasks/rake/gem.rake +0 -63
  394. data/tasks/rake/git_workflow.rake +0 -134
  395. data/tasks/rake/metrics.rake +0 -14
  396. data/tasks/rake/sign.rake +0 -14
  397. data/tasks/rake/testbranch.rake +0 -16
  398. data/tasks/rake/yard.rake +0 -11
@@ -1,111 +1,140 @@
1
1
  #! /usr/bin/env ruby -S rspec
2
2
  require 'spec_helper'
3
3
 
4
- provider_class = Puppet::Type.type(:user).provider(:useradd)
5
-
6
- describe provider_class do
7
- before do
8
- @resource = stub("resource", :name => "myuser", :managehome? => nil)
9
- @resource.stubs(:should).returns "fakeval"
10
- @resource.stubs(:[]).returns "fakeval"
11
- @provider = provider_class.new(@resource)
4
+ describe Puppet::Type.type(:user).provider(:useradd) do
5
+
6
+ before :each do
7
+ described_class.stubs(:command).with(:password).returns '/usr/bin/chage'
8
+ described_class.stubs(:command).with(:add).returns '/usr/sbin/useradd'
9
+ described_class.stubs(:command).with(:modify).returns '/usr/sbin/usermod'
10
+ described_class.stubs(:command).with(:delete).returns '/usr/sbin/userdel'
12
11
  end
13
12
 
14
- # #1360
15
- it "should add -o when allowdupe is enabled and the user is being created" do
16
- @resource.expects(:allowdupe?).returns true
17
- @resource.expects(:system?).returns true
18
- @provider.stubs(:execute)
19
- @provider.expects(:execute).with { |args| args.include?("-o") }
20
- @provider.create
13
+ let(:resource) do
14
+ Puppet::Type.type(:user).new(
15
+ :name => 'myuser',
16
+ :managehome => :false,
17
+ :system => :false,
18
+ :provider => provider
19
+ )
21
20
  end
22
21
 
23
- it "should add -o when allowdupe is enabled and the uid is being modified" do
24
- @resource.expects(:allowdupe?).returns true
25
- @provider.expects(:execute).with { |args| args.include?("-o") }
22
+ let(:provider) { described_class.new(:name => 'myuser') }
26
23
 
27
- @provider.uid = 150
28
- end
24
+ describe "#create" do
25
+
26
+ it "should add -o when allowdupe is enabled and the user is being created" do
27
+ resource[:allowdupe] = true
28
+ provider.expects(:execute).with(['/usr/sbin/useradd', '-o', 'myuser'])
29
+ provider.create
30
+ end
31
+
32
+ describe "on systems that support has_system", :if => described_class.system_users? do
33
+ it "should add -r when system is enabled" do
34
+ resource[:system] = :true
35
+ provider.should be_system_users
36
+ provider.expects(:execute).with(['/usr/sbin/useradd', '-r', 'myuser'])
37
+ provider.create
38
+ end
39
+ end
40
+
41
+ describe "on systems that do not support has_system", :unless => described_class.system_users? do
42
+ it "should not add -r when system is enabled" do
43
+ resource[:system] = :true
44
+ provider.should_not be_system_users
45
+ provider.expects(:execute).with(['/usr/sbin/useradd', 'myuser'])
46
+ provider.create
47
+ end
48
+ end
29
49
 
30
- it "should add -r when system is enabled" do
31
- @resource.expects(:allowdupe?).returns true
32
- @resource.expects(:system?).returns true
33
- @provider.stubs(:execute)
34
- @provider.expects(:execute).with { |args| args.include?("-r") }
35
- @provider.create
50
+ it "should set password age rules" do
51
+ described_class.has_feature :manages_password_age
52
+ resource[:password_min_age] = 5
53
+ resource[:password_max_age] = 10
54
+ provider.expects(:execute).with(['/usr/sbin/useradd', 'myuser'])
55
+ provider.expects(:execute).with(['/usr/bin/chage', '-m', 5, '-M', 10, 'myuser'])
56
+ provider.create
57
+ end
36
58
  end
37
59
 
38
- it "should set password age rules" do
39
- provider_class.has_feature :manages_password_age
40
- @resource = Puppet::Type.type(:user).new :name => "myuser", :password_min_age => 5, :password_max_age => 10, :provider => :useradd
41
- @provider = provider_class.new(@resource)
42
- @provider.stubs(:execute)
43
- @provider.expects(:execute).with { |cmd, *args| args == ["-m", 5, "-M", 10, "myuser"] }
44
- @provider.create
60
+ describe "#uid=" do
61
+ it "should add -o when allowdupe is enabled and the uid is being modified" do
62
+ resource[:allowdupe] = :true
63
+ provider.expects(:execute).with(['/usr/sbin/usermod', '-u', 150, '-o', 'myuser'])
64
+ provider.uid = 150
65
+ end
45
66
  end
46
67
 
47
- describe "when checking to add allow dup" do
68
+ describe "#check_allow_dup" do
48
69
  it "should check allow dup" do
49
- @resource.expects(:allowdupe?)
50
- @provider.check_allow_dup
70
+ resource.expects(:allowdupe?)
71
+ provider.check_allow_dup
51
72
  end
52
73
 
53
74
  it "should return an array with a flag if dup is allowed" do
54
- @resource.stubs(:allowdupe?).returns true
55
- @provider.check_allow_dup.must == ["-o"]
75
+ resource[:allowdupe] = :true
76
+ provider.check_allow_dup.must == ["-o"]
56
77
  end
57
78
 
58
79
  it "should return an empty array if no dup is allowed" do
59
- @resource.stubs(:allowdupe?).returns false
60
- @provider.check_allow_dup.must == []
80
+ resource[:allowdupe] = :false
81
+ provider.check_allow_dup.must == []
61
82
  end
62
83
  end
63
84
 
64
- describe "when checking to add system users" do
85
+ describe "#check_system_users" do
65
86
  it "should check system users" do
66
- @resource.expects(:system?)
67
- @provider.check_system_users
87
+ described_class.expects(:system_users?).returns true
88
+ resource.expects(:system?)
89
+ provider.check_system_users
68
90
  end
69
91
 
70
92
  it "should return an array with a flag if it's a system user" do
71
- @resource.stubs(:system?).returns true
72
- @provider.check_system_users.must == ["-r"]
93
+ described_class.expects(:system_users?).returns true
94
+ resource[:system] = :true
95
+ provider.check_system_users.must == ["-r"]
73
96
  end
74
97
 
75
98
  it "should return an empty array if it's not a system user" do
76
- @resource.stubs(:system?).returns false
77
- @provider.check_system_users.must == []
99
+ described_class.expects(:system_users?).returns true
100
+ resource[:system] = :false
101
+ provider.check_system_users.must == []
102
+ end
103
+
104
+ it "should return an empty array if system user is not featured" do
105
+ described_class.expects(:system_users?).returns false
106
+ resource[:system] = :true
107
+ provider.check_system_users.must == []
78
108
  end
79
109
  end
80
110
 
81
- describe "when checking manage home" do
111
+ describe "#check_manage_home" do
82
112
  it "should check manage home" do
83
- @resource.expects(:managehome?)
84
- @provider.check_manage_home
113
+ resource.expects(:managehome?)
114
+ provider.check_manage_home
85
115
  end
86
116
 
87
117
  it "should return an array with -m flag if home is managed" do
88
- @resource.stubs(:managehome?).returns true
89
- @provider.check_manage_home.must == ["-m"]
118
+ resource[:managehome] = :true
119
+ provider.check_manage_home.must == ["-m"]
90
120
  end
91
-
121
+
92
122
  it "should return an array with -r flag if home is managed" do
93
- @resource.stubs(:managehome?).returns true
94
- @resource.stubs(:ensure) == :absent
95
- @provider.stubs(:command).returns("userdel")
96
- @provider.deletecmd.must == ["userdel", "-r", "fakeval"]
123
+ resource[:managehome] = :true
124
+ resource[:ensure] = :absent
125
+ provider.deletecmd.must == ['/usr/sbin/userdel', '-r', 'myuser']
97
126
  end
98
127
 
99
128
  it "should return an array with -M if home is not managed and on Redhat" do
100
- Facter.stubs(:value).with("operatingsystem").returns("RedHat")
101
- @resource.stubs(:managehome?).returns false
102
- @provider.check_manage_home.must == ["-M"]
129
+ Facter.stubs(:value).with(:operatingsystem).returns("RedHat")
130
+ resource[:managehome] = :false
131
+ provider.check_manage_home.must == ["-M"]
103
132
  end
104
133
 
105
134
  it "should return an empty array if home is not managed and not on Redhat" do
106
- Facter.stubs(:value).with("operatingsystem").returns("some OS")
107
- @resource.stubs(:managehome?).returns false
108
- @provider.check_manage_home.must == []
135
+ Facter.stubs(:value).with(:operatingsystem).returns("some OS")
136
+ resource[:managehome] = :false
137
+ provider.check_manage_home.must == []
109
138
  end
110
139
  end
111
140
 
@@ -116,107 +145,107 @@ describe provider_class do
116
145
  it "should return and array of flags and values"
117
146
  end
118
147
 
119
- describe "when calling addcmd" do
148
+ describe "#addcmd" do
120
149
  before do
121
- @resource.stubs(:allowdupe?).returns true
122
- @resource.stubs(:managehome?).returns true
123
- @resource.stubs(:system?).returns true
150
+ resource[:allowdupe] = :true
151
+ resource[:managehome] = :true
152
+ resource[:system] = :true
124
153
  end
125
154
 
126
155
  it "should call command with :add" do
127
- @provider.expects(:command).with(:add)
128
- @provider.addcmd
156
+ provider.expects(:command).with(:add)
157
+ provider.addcmd
129
158
  end
130
159
 
131
160
  it "should add properties" do
132
- @provider.expects(:add_properties).returns([])
133
- @provider.addcmd
161
+ provider.expects(:add_properties).returns(['-foo_add_properties'])
162
+ provider.addcmd.should include '-foo_add_properties'
134
163
  end
135
164
 
136
165
  it "should check and add if dup allowed" do
137
- @provider.expects(:check_allow_dup).returns([])
138
- @provider.addcmd
166
+ provider.expects(:check_allow_dup).returns(['-allow_dup_flag'])
167
+ provider.addcmd.should include '-allow_dup_flag'
139
168
  end
140
169
 
141
170
  it "should check and add if home is managed" do
142
- @provider.expects(:check_manage_home).returns([])
143
- @provider.addcmd
171
+ provider.expects(:check_manage_home).returns(['-manage_home_flag'])
172
+ provider.addcmd.should include '-manage_home_flag'
144
173
  end
145
174
 
146
175
  it "should add the resource :name" do
147
- @resource.expects(:[]).with(:name)
148
- @provider.addcmd
176
+ provider.addcmd.should include 'myuser'
149
177
  end
150
178
 
151
- it "should return an array with -r if system? is true" do
152
- resource = Puppet::Type.type(:user).new( :name => "bob", :system => true)
179
+ describe "on systems featuring system_users", :if => described_class.system_users? do
180
+ it "should return an array with -r if system? is true" do
181
+ resource[:system] = :true
182
+ provider.addcmd.should include("-r")
183
+ end
153
184
 
154
- provider_class.new( resource ).addcmd.should include("-r")
185
+ it "should return an array without -r if system? is false" do
186
+ resource[:system] = :false
187
+ provider.addcmd.should_not include("-r")
188
+ end
155
189
  end
156
190
 
157
- it "should return an array without -r if system? is false" do
158
- resource = Puppet::Type.type(:user).new( :name => "bob", :system => false)
159
-
160
- provider_class.new( resource ).addcmd.should_not include("-r")
191
+ describe "on systems not featuring system_users", :unless => described_class.system_users? do
192
+ [:false, :true].each do |system|
193
+ it "should return an array without -r if system? is #{system}" do
194
+ resource[:system] = system
195
+ provider.addcmd.should_not include("-r")
196
+ end
197
+ end
161
198
  end
162
199
 
163
200
  it "should return an array with full command" do
164
- @provider.stubs(:command).with(:add).returns("useradd")
165
- @provider.stubs(:add_properties).returns(["-G", "somegroup"])
166
- @resource.stubs(:[]).with(:name).returns("someuser")
167
- @resource.stubs(:[]).with(:expiry).returns("somedate")
168
- @provider.addcmd.must == ["useradd", "-G", "somegroup", "-o", "-m", '-e somedate', "-r", "someuser"]
201
+ described_class.expects(:system_users?).returns true
202
+ provider.stubs(:add_properties).returns(["-G", "somegroup"])
203
+ resource[:expiry] = "2012-08-18"
204
+
205
+ provider.addcmd.must == ["/usr/sbin/useradd", "-G", "somegroup", "-o", "-m", '-e 2012-08-18', "-r", "myuser"]
169
206
  end
170
207
 
171
208
  it "should return an array without -e if expiry is undefined full command" do
172
- @provider.stubs(:command).with(:add).returns("useradd")
173
- @provider.stubs(:add_properties).returns(["-G", "somegroup"])
174
- @resource.stubs(:[]).with(:name).returns("someuser")
175
- @resource.stubs(:[]).with(:expiry).returns nil
176
- @provider.addcmd.must == ["useradd", "-G", "somegroup", "-o", "-m", "-r", "someuser"]
209
+ described_class.expects(:system_users?).returns true
210
+ provider.stubs(:add_properties).returns(["-G", "somegroup"])
211
+ provider.addcmd.must == ["/usr/sbin/useradd", "-G", "somegroup", "-o", "-m", "-r", "myuser"]
177
212
  end
178
213
  end
179
214
 
180
- describe "when calling passcmd" do
215
+ describe "#passcmd" do
181
216
  before do
182
- @resource.stubs(:allowdupe?).returns true
183
- @resource.stubs(:managehome?).returns true
184
- @resource.stubs(:system?).returns true
217
+ resource[:allowdupe] = :true
218
+ resource[:managehome] = :true
219
+ resource[:system] = :true
220
+ described_class.has_feature :manages_password_age
185
221
  end
186
222
 
187
223
  it "should call command with :pass" do
188
- @provider.expects(:command).with(:password)
189
- @provider.passcmd
224
+ # command(:password) is only called inside passcmd if
225
+ # password_min_age or password_max_age is set
226
+ resource[:password_min_age] = 123
227
+ provider.expects(:command).with(:password)
228
+ provider.passcmd
190
229
  end
191
230
 
192
231
  it "should return nil if neither min nor max is set" do
193
- @resource.stubs(:should).with(:password_min_age).returns nil
194
- @resource.stubs(:should).with(:password_max_age).returns nil
195
- @provider.passcmd.must == nil
232
+ provider.passcmd.must be_nil
196
233
  end
197
234
 
198
235
  it "should return a chage command array with -m <value> and the user name if password_min_age is set" do
199
- @provider.stubs(:command).with(:password).returns("chage")
200
- @resource.stubs(:[]).with(:name).returns("someuser")
201
- @resource.stubs(:should).with(:password_min_age).returns 123
202
- @resource.stubs(:should).with(:password_max_age).returns nil
203
- @provider.passcmd.must == ['chage','-m',123,'someuser']
236
+ resource[:password_min_age] = 123
237
+ provider.passcmd.must == ['/usr/bin/chage','-m',123,'myuser']
204
238
  end
205
239
 
206
240
  it "should return a chage command array with -M <value> if password_max_age is set" do
207
- @provider.stubs(:command).with(:password).returns("chage")
208
- @resource.stubs(:[]).with(:name).returns("someuser")
209
- @resource.stubs(:should).with(:password_min_age).returns nil
210
- @resource.stubs(:should).with(:password_max_age).returns 999
211
- @provider.passcmd.must == ['chage','-M',999,'someuser']
241
+ resource[:password_max_age] = 999
242
+ provider.passcmd.must == ['/usr/bin/chage','-M',999,'myuser']
212
243
  end
213
244
 
214
245
  it "should return a chage command array with -M <value> -m <value> if both password_min_age and password_max_age are set" do
215
- @provider.stubs(:command).with(:password).returns("chage")
216
- @resource.stubs(:[]).with(:name).returns("someuser")
217
- @resource.stubs(:should).with(:password_min_age).returns 123
218
- @resource.stubs(:should).with(:password_max_age).returns 999
219
- @provider.passcmd.must == ['chage','-m',123,'-M',999,'someuser']
246
+ resource[:password_min_age] = 123
247
+ resource[:password_max_age] = 999
248
+ provider.passcmd.must == ['/usr/bin/chage','-m',123,'-M',999,'myuser']
220
249
  end
221
250
  end
222
251
  end
@@ -83,6 +83,17 @@ describe Puppet::Type.type(:user).provider(:windows_adsi) do
83
83
  provider.create
84
84
  end
85
85
 
86
+ it "should load the profile if managehome is set", :if => Puppet.features.microsoft_windows? do
87
+ resource[:password] = '0xDeadBeef'
88
+ resource[:managehome] = true
89
+
90
+ user = stub_everything 'user'
91
+ Puppet::Util::ADSI::User.expects(:create).with('testuser').returns user
92
+ Puppet::Util::Windows::User.expects(:load_profile).with('testuser', '0xDeadBeef')
93
+
94
+ provider.create
95
+ end
96
+
86
97
  it "should set a user's password" do
87
98
  provider.user.expects(:password=).with('plaintextbad')
88
99
 
@@ -125,6 +136,17 @@ describe Puppet::Type.type(:user).provider(:windows_adsi) do
125
136
  provider.delete
126
137
  end
127
138
 
139
+ it 'should delete the profile if managehome is set' do
140
+ resource[:managehome] = true
141
+
142
+ sid = 'S-A-B-C'
143
+ Puppet::Util::ADSI.expects(:sid_for_account).with('testuser').returns(sid)
144
+ Puppet::Util::ADSI::UserProfile.expects(:delete).with(sid)
145
+ connection.expects(:Delete).with('user', 'testuser')
146
+
147
+ provider.delete
148
+ end
149
+
128
150
  it "should commit the user when flushed" do
129
151
  provider.user.expects(:commit)
130
152
 
@@ -3,13 +3,23 @@ require 'spec_helper'
3
3
 
4
4
  describe Puppet::Type.type(:zone).provider(:solaris) do
5
5
  let(:resource) { Puppet::Type.type(:zone).new(:name => 'dummy', :path => '/', :provider => :solaris) }
6
- let(:provider) { resource.provider }
6
+ let(:provider) { described_class.new(resource) }
7
7
 
8
8
  context "#configure" do
9
9
  it "should add the create args to the create str" do
10
10
  resource.stubs(:properties).returns([])
11
11
  resource[:create_args] = "create_args"
12
- provider.expects(:setconfig).with("create -b create_args\nset zonepath=\/\ncommit\n")
12
+ provider.expects(:setconfig).with("create -b create_args")
13
+ provider.configure
14
+ end
15
+ it "should add the create args to the create str" do
16
+ iptype = stub "property"
17
+ iptype.stubs(:name).with().returns(:iptype)
18
+ iptype.stubs(:safe_insync?).with(iptype).returns(false)
19
+ provider.stubs(:properties).returns({:iptype => iptype})
20
+ resource.stubs(:properties).with().returns([iptype])
21
+ resource[:create_args] = "create_args"
22
+ provider.expects(:setconfig).with("create -b create_args\nset ip-type=shared")
13
23
  provider.configure
14
24
  end
15
25
  end
@@ -59,18 +69,127 @@ describe Puppet::Type.type(:zone).provider(:solaris) do
59
69
  end
60
70
  context "#setconfig" do
61
71
  it "should correctly set configuration" do
62
- provider.expects(:cfg).with('-z', 'dummy', "create -b create_args\nset zonepath=\/\ncommit\n").returns('')
63
- $CHILD_STATUS.stubs(:exitstatus).with().returns 0
64
- provider.setconfig("create -b create_args\nset zonepath=\/\ncommit\n")
72
+ provider.expects(:command).with(:cfg).returns('/usr/sbin/zonecfg')
73
+ provider.expects(:exec_cmd).with(:input => "set zonepath=/\ncommit\nexit", :cmd => '/usr/sbin/zonecfg -z dummy -f -').returns({:out=>'', :exit => 0})
74
+ provider.setconfig("set zonepath=\/")
75
+ provider.flush
65
76
  end
66
77
 
67
78
  it "should correctly warn on 'not allowed'" do
68
- provider.expects(:cfg).with('-z', 'dummy', 'set zonepath=/').returns("Zone z2 already installed; set zonepath not allowed.\n")
79
+ provider.expects(:command).with(:cfg).returns('/usr/sbin/zonecfg')
80
+ provider.expects(:exec_cmd).with(:input => "set zonepath=/\ncommit\nexit", :cmd => '/usr/sbin/zonecfg -z dummy -f -').returns({:out=>"Zone z2 already installed; set zonepath not allowed.\n", :exit => 0})
81
+ provider.setconfig("set zonepath=\/")
69
82
  expect {
70
- provider.setconfig("set zonepath=\/")
83
+ provider.flush
71
84
  }.to raise_error(ArgumentError, /Failed to apply configuration/)
85
+ end
86
+ end
87
+ context "#getconfig" do
88
+ zone_info =<<-EOF
89
+ zonename: dummy
90
+ zonepath: /dummy/z
91
+ brand: native
92
+ autoboot: true
93
+ bootargs:
94
+ pool:
95
+ limitpriv:
96
+ scheduling-class:
97
+ ip-type: shared
98
+ hostid:
99
+ net:
100
+ address: 1.1.1.1
101
+ physical: ex0001
102
+ defrouter not specified
103
+ net:
104
+ address: 1.1.1.2
105
+ physical: ex0002
106
+ defrouter not specified
107
+ EOF
108
+ it "should correctly parse zone info" do
109
+ provider.expects(:zonecfg).with(:info).returns(zone_info)
110
+ provider.getconfig.should == {
111
+ :brand=>"native",
112
+ :autoboot=>"true",
113
+ :"ip-type"=>"shared",
114
+ :zonename=>"dummy",
115
+ "net"=>[{:physical=>"ex0001", :address=>"1.1.1.1"}, {:physical=>"ex0002", :address=>"1.1.1.2"}],
116
+ :zonepath=>"/dummy/z"
117
+ }
118
+ end
119
+ end
120
+ context "#flush" do
121
+ it "should correctly execute pending commands" do
122
+ provider.expects(:command).with(:cfg).returns('/usr/sbin/zonecfg')
123
+ provider.expects(:exec_cmd).with(:input => "set iptype=shared\ncommit\nexit", :cmd => '/usr/sbin/zonecfg -z dummy -f -').returns({:out=>'', :exit => 0})
124
+ provider.setconfig("set iptype=shared")
125
+ provider.flush
126
+ end
127
+
128
+ it "should correctly raise error on failure" do
129
+ provider.expects(:command).with(:cfg).returns('/usr/sbin/zonecfg')
130
+ provider.expects(:exec_cmd).with(:input => "set iptype=shared\ncommit\nexit", :cmd => '/usr/sbin/zonecfg -z dummy -f -').returns({:out=>'', :exit => 1})
131
+ provider.setconfig("set iptype=shared")
132
+ expect {
133
+ provider.flush
134
+ }.to raise_error(ArgumentError, /Failed to apply/)
135
+ end
136
+ end
137
+ context "#start" do
138
+ it "should not require path if sysidcfg is specified" do
139
+ resource[:path] = '/mypath'
140
+ resource[:sysidcfg] = 'dummy'
141
+ File.stubs(:exists?).with('/mypath/root/etc/sysidcfg').returns true
142
+ File.stubs(:directory?).with('/mypath/root/etc').returns true
143
+ provider.expects(:zoneadm).with(:boot)
144
+ provider.start
145
+ end
72
146
 
147
+ it "should require path if sysidcfg is specified" do
148
+ resource.stubs(:[]).with(:path).returns nil
149
+ resource.stubs(:[]).with(:sysidcfg).returns 'dummy'
150
+ expect {
151
+ provider.start
152
+ }.to raise_error(Puppet::Error, /Path is required/)
153
+ end
154
+ end
155
+ context "#line2hash" do
156
+ it "should parse lines correctly" do
157
+ described_class.line2hash('0:dummy:running:/z::native:shared').should == {:ensure=>:running, :iptype=>"shared", :path=>"/z", :name=>"dummy", :id=>"0"}
158
+ end
159
+ it "should parse lines correctly(2)" do
160
+ described_class.line2hash('0:dummy:running:/z:ipkg:native:shared').should == {:ensure=>:running, :iptype=>"shared", :path=>"/z", :name=>"dummy", :id=>"0"}
161
+ end
162
+ it "should parse lines correctly(3)" do
163
+ described_class.line2hash('-:dummy:running:/z:ipkg:native:shared').should == {:ensure=>:running, :iptype=>"shared", :path=>"/z", :name=>"dummy"}
164
+ end
165
+ it "should parse lines correctly(3)" do
166
+ described_class.line2hash('-:dummy:running:/z:ipkg:native:exclusive').should == {:ensure=>:running, :iptype=>"exclusive", :path=>"/z", :name=>"dummy"}
73
167
  end
168
+ end
169
+ context "#multi_conf" do
170
+ it "should correctly add and remove properties" do
171
+ provider.stubs(:properties).with().returns({:ip => ['1.1.1.1', '2.2.2.2']})
172
+ should = ['1.1.1.1', '3.3.3.3']
173
+ p = Proc.new do |a, str|
174
+ case a
175
+ when :add; 'add:' + str
176
+ when :rm; 'rm:' + str
177
+ end
178
+ end
179
+ provider.multi_conf(:ip, should, &p).should == "rm:2.2.2.2\nadd:3.3.3.3"
180
+ end
181
+ end
182
+ context "single props" do
183
+ {:iptype => /set ip-type/, :autoboot => /set autoboot/, :path => /set zonepath/, :pool => /set pool/, :shares => /add rctl/}.each do |p, v|
184
+ it "#{p.to_s}: should correctly return conf string" do
185
+ provider.send(p.to_s + '_conf', 'dummy').should =~ v
186
+ end
187
+ it "#{p.to_s}: should correctly set property string" do
188
+ provider.expects((p.to_s + '_conf').intern).returns('dummy')
189
+ provider.expects(:setconfig).with('dummy').returns('dummy2')
190
+ provider.send(p.to_s + '=', 'dummy').should == 'dummy2'
191
+ end
74
192
 
193
+ end
75
194
  end
76
195
  end