puppet 2.7.3 → 2.7.4

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 (337) hide show
  1. data/CHANGELOG +166 -0
  2. data/install.rb +27 -7
  3. data/lib/puppet/application/agent.rb +29 -29
  4. data/lib/puppet/application/doc.rb +1 -1
  5. data/lib/puppet/application/inspect.rb +9 -1
  6. data/lib/puppet/application/master.rb +2 -0
  7. data/lib/puppet/application/queue.rb +1 -1
  8. data/lib/puppet/application/resource.rb +3 -0
  9. data/lib/puppet/application.rb +4 -5
  10. data/lib/puppet/configurer.rb +1 -4
  11. data/lib/puppet/defaults.rb +45 -15
  12. data/lib/puppet/feature/base.rb +28 -17
  13. data/lib/puppet/feature/rails.rb +0 -3
  14. data/lib/puppet/feature/rubygems.rb +0 -3
  15. data/lib/puppet/file_bucket/dipper.rb +3 -2
  16. data/lib/puppet/file_bucket/file.rb +3 -3
  17. data/lib/puppet/file_serving/base.rb +4 -5
  18. data/lib/puppet/file_serving/configuration.rb +7 -13
  19. data/lib/puppet/file_serving/content.rb +0 -4
  20. data/lib/puppet/file_serving/fileset.rb +7 -6
  21. data/lib/puppet/file_serving/indirection_hooks.rb +1 -4
  22. data/lib/puppet/file_serving/metadata.rb +0 -4
  23. data/lib/puppet/file_serving/mount/file.rb +9 -12
  24. data/lib/puppet/file_serving/mount.rb +0 -5
  25. data/lib/puppet/file_serving/terminus_helper.rb +0 -4
  26. data/lib/puppet/file_serving.rb +0 -4
  27. data/lib/puppet/indirector/catalog/compiler.rb +0 -18
  28. data/lib/puppet/indirector/catalog/store_configs.rb +5 -0
  29. data/lib/puppet/indirector/direct_file_server.rb +0 -4
  30. data/lib/puppet/indirector/facts/facter.rb +2 -2
  31. data/lib/puppet/indirector/facts/store_configs.rb +5 -0
  32. data/lib/puppet/indirector/file_content/file.rb +0 -4
  33. data/lib/puppet/indirector/file_content/file_server.rb +0 -4
  34. data/lib/puppet/indirector/file_content/rest.rb +0 -4
  35. data/lib/puppet/indirector/file_metadata/file.rb +0 -4
  36. data/lib/puppet/indirector/file_metadata/file_server.rb +0 -4
  37. data/lib/puppet/indirector/file_metadata/rest.rb +0 -4
  38. data/lib/puppet/indirector/file_server.rb +1 -5
  39. data/lib/puppet/indirector/indirection.rb +3 -5
  40. data/lib/puppet/indirector/node/store_configs.rb +5 -0
  41. data/lib/puppet/indirector/request.rb +3 -1
  42. data/lib/puppet/indirector/resource/active_record.rb +97 -0
  43. data/lib/puppet/indirector/resource/store_configs.rb +3 -0
  44. data/lib/puppet/indirector/ssl_file.rb +5 -1
  45. data/lib/puppet/indirector/store_configs.rb +30 -0
  46. data/lib/puppet/indirector/yaml.rb +5 -0
  47. data/lib/puppet/indirector.rb +7 -0
  48. data/lib/puppet/network/client.rb +0 -5
  49. data/lib/puppet/network/http_pool.rb +0 -56
  50. data/lib/puppet/node/environment.rb +9 -11
  51. data/lib/puppet/parameter/path.rb +1 -5
  52. data/lib/puppet/parameter.rb +1 -7
  53. data/lib/puppet/parser/ast/collection.rb +2 -2
  54. data/lib/puppet/parser/ast/collexpr.rb +10 -39
  55. data/lib/puppet/parser/collector.rb +41 -90
  56. data/lib/puppet/parser/compiler.rb +0 -3
  57. data/lib/puppet/parser/functions/create_resources.rb +22 -10
  58. data/lib/puppet/parser/functions/versioncmp.rb +9 -6
  59. data/lib/puppet/parser/resource.rb +1 -1
  60. data/lib/puppet/parser/type_loader.rb +2 -1
  61. data/lib/puppet/provider/augeas/augeas.rb +5 -3
  62. data/lib/puppet/provider/cron/crontab.rb +2 -2
  63. data/lib/puppet/provider/exec/posix.rb +23 -96
  64. data/lib/puppet/provider/exec/shell.rb +11 -2
  65. data/lib/puppet/provider/exec/windows.rb +35 -0
  66. data/lib/puppet/provider/exec.rb +79 -0
  67. data/lib/puppet/provider/group/windows_adsi.rb +48 -0
  68. data/lib/puppet/provider/host/parsed.rb +3 -0
  69. data/lib/puppet/provider/macauthorization/macauthorization.rb +4 -4
  70. data/lib/puppet/provider/mount.rb +0 -3
  71. data/lib/puppet/provider/naginator.rb +0 -3
  72. data/lib/puppet/provider/package/appdmg.rb +0 -1
  73. data/lib/puppet/provider/package/apple.rb +3 -7
  74. data/lib/puppet/provider/package/apt.rb +0 -1
  75. data/lib/puppet/provider/package/aptitude.rb +0 -1
  76. data/lib/puppet/provider/package/aptrpm.rb +0 -1
  77. data/lib/puppet/provider/package/blastwave.rb +0 -1
  78. data/lib/puppet/provider/package/dpkg.rb +5 -6
  79. data/lib/puppet/provider/package/fink.rb +3 -4
  80. data/lib/puppet/provider/package/freebsd.rb +0 -1
  81. data/lib/puppet/provider/package/gem.rb +0 -1
  82. data/lib/puppet/provider/package/hpux.rb +3 -3
  83. data/lib/puppet/provider/package/macports.rb +0 -1
  84. data/lib/puppet/provider/package/msi.rb +82 -0
  85. data/lib/puppet/provider/package/openbsd.rb +18 -19
  86. data/lib/puppet/provider/package/pip.rb +0 -1
  87. data/lib/puppet/provider/package/pkg.rb +0 -1
  88. data/lib/puppet/provider/package/pkgdmg.rb +9 -7
  89. data/lib/puppet/provider/package/pkgutil.rb +0 -1
  90. data/lib/puppet/provider/package/ports.rb +0 -1
  91. data/lib/puppet/provider/package/portupgrade.rb +183 -193
  92. data/lib/puppet/provider/package/rpm.rb +1 -1
  93. data/lib/puppet/provider/package/sun.rb +0 -1
  94. data/lib/puppet/provider/package/sunfreeware.rb +0 -2
  95. data/lib/puppet/provider/package/up2date.rb +0 -1
  96. data/lib/puppet/provider/package/urpmi.rb +0 -1
  97. data/lib/puppet/provider/package/yum.rb +1 -1
  98. data/lib/puppet/provider/package.rb +4 -3
  99. data/lib/puppet/provider/service/systemd.rb +64 -0
  100. data/lib/puppet/provider/service/windows.rb +110 -0
  101. data/lib/puppet/provider/user/windows_adsi.rb +71 -0
  102. data/lib/puppet/rails/resource.rb +1 -1
  103. data/lib/puppet/relationship.rb +0 -3
  104. data/lib/puppet/reports/tagmail.rb +15 -11
  105. data/lib/puppet/resource/catalog.rb +17 -24
  106. data/lib/puppet/ssl/certificate_authority.rb +7 -5
  107. data/lib/puppet/ssl/host.rb +6 -10
  108. data/lib/puppet/type/augeas.rb +19 -13
  109. data/lib/puppet/type/cron.rb +13 -12
  110. data/lib/puppet/type/exec.rb +17 -17
  111. data/lib/puppet/type/file/content.rb +7 -3
  112. data/lib/puppet/type/file/source.rb +14 -9
  113. data/lib/puppet/type/file.rb +44 -23
  114. data/lib/puppet/type/filebucket.rb +13 -5
  115. data/lib/puppet/type/package.rb +14 -1
  116. data/lib/puppet/type/service.rb +11 -1
  117. data/lib/puppet/type/ssh_authorized_key.rb +3 -1
  118. data/lib/puppet/type.rb +8 -17
  119. data/lib/puppet/util/adsi.rb +278 -0
  120. data/lib/puppet/util/autoload.rb +0 -2
  121. data/lib/puppet/util/cacher.rb +15 -67
  122. data/lib/puppet/util/feature.rb +0 -3
  123. data/lib/puppet/util/graph.rb +0 -3
  124. data/lib/puppet/util/ldap/connection.rb +0 -3
  125. data/lib/puppet/util/ldap/generator.rb +0 -3
  126. data/lib/puppet/util/ldap.rb +0 -3
  127. data/lib/puppet/util/log_paths.rb +0 -3
  128. data/lib/puppet/util/network_device/cisco/device.rb +2 -1
  129. data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
  130. data/lib/puppet/util/pidlock.rb +5 -1
  131. data/lib/puppet/util/rdoc/parser.rb +3 -1
  132. data/lib/puppet/util/run_mode.rb +2 -2
  133. data/lib/puppet/util/settings/file_setting.rb +3 -2
  134. data/lib/puppet/util/settings.rb +4 -6
  135. data/lib/puppet/util/suidmanager.rb +62 -15
  136. data/lib/puppet/util.rb +113 -131
  137. data/lib/puppet.rb +1 -1
  138. data/spec/integration/application/doc_spec.rb +1 -1
  139. data/spec/integration/defaults_spec.rb +22 -17
  140. data/spec/integration/file_serving/content_spec.rb +0 -6
  141. data/spec/integration/file_serving/metadata_spec.rb +0 -6
  142. data/spec/integration/file_serving/terminus_helper_spec.rb +1 -1
  143. data/spec/integration/indirector/direct_file_server_spec.rb +5 -7
  144. data/spec/integration/indirector/file_content/file_server_spec.rb +2 -6
  145. data/spec/integration/indirector/file_metadata/file_server_spec.rb +1 -5
  146. data/spec/integration/network/server/webrick_spec.rb +6 -9
  147. data/spec/integration/node/facts_spec.rb +0 -6
  148. data/spec/integration/node_spec.rb +3 -4
  149. data/spec/integration/parser/compiler_spec.rb +2 -1
  150. data/spec/integration/parser/parser_spec.rb +2 -4
  151. data/spec/integration/provider/mount_spec.rb +1 -1
  152. data/spec/integration/provider/package_spec.rb +13 -3
  153. data/spec/integration/provider/ssh_authorized_key_spec.rb +4 -4
  154. data/spec/integration/reports_spec.rb +0 -4
  155. data/spec/integration/resource/catalog_spec.rb +0 -5
  156. data/spec/integration/ssl/certificate_authority_spec.rb +6 -14
  157. data/spec/integration/ssl/certificate_request_spec.rb +10 -17
  158. data/spec/integration/ssl/certificate_revocation_list_spec.rb +8 -13
  159. data/spec/integration/ssl/host_spec.rb +8 -14
  160. data/spec/integration/transaction/report_spec.rb +0 -5
  161. data/spec/integration/transaction_spec.rb +11 -13
  162. data/spec/integration/type/file_spec.rb +16 -16
  163. data/spec/integration/type/tidy_spec.rb +1 -1
  164. data/spec/integration/util/settings_spec.rb +2 -2
  165. data/spec/integration/util_spec.rb +13 -0
  166. data/spec/lib/puppet_spec/files.rb +18 -10
  167. data/spec/shared_behaviours/file_server_terminus.rb +1 -5
  168. data/spec/shared_behaviours/file_serving.rb +0 -4
  169. data/spec/shared_behaviours/memory_terminus.rb +0 -4
  170. data/spec/shared_behaviours/path_parameters.rb +20 -18
  171. data/spec/shared_behaviours/store_configs_terminus.rb +21 -0
  172. data/spec/spec_helper.rb +31 -0
  173. data/spec/unit/agent_spec.rb +0 -4
  174. data/spec/unit/application/apply_spec.rb +8 -2
  175. data/spec/unit/application/certificate_spec.rb +2 -0
  176. data/spec/unit/application/device_spec.rb +8 -6
  177. data/spec/unit/application/inspect_spec.rb +2 -1
  178. data/spec/unit/application/master_spec.rb +7 -2
  179. data/spec/unit/application/queue_spec.rb +3 -4
  180. data/spec/unit/application/resource_spec.rb +26 -0
  181. data/spec/unit/application/secret_agent_spec.rb +3 -1
  182. data/spec/unit/application_spec.rb +4 -0
  183. data/spec/unit/configurer/downloader_spec.rb +4 -3
  184. data/spec/unit/configurer_spec.rb +11 -4
  185. data/spec/unit/daemon_spec.rb +3 -1
  186. data/spec/unit/face/ca_spec.rb +1 -1
  187. data/spec/unit/face/node_spec.rb +5 -1
  188. data/spec/unit/face/secret_agent_spec.rb +3 -1
  189. data/spec/unit/file_bucket/dipper_spec.rb +4 -4
  190. data/spec/unit/file_bucket/file_spec.rb +9 -3
  191. data/spec/unit/file_serving/configuration_spec.rb +26 -37
  192. data/spec/unit/file_serving/fileset_spec.rb +71 -55
  193. data/spec/unit/file_serving/indirection_hooks_spec.rb +0 -4
  194. data/spec/unit/file_serving/mount/file_spec.rb +163 -169
  195. data/spec/unit/file_serving/terminus_helper_spec.rb +0 -4
  196. data/spec/unit/indirector/catalog/compiler_spec.rb +0 -22
  197. data/spec/unit/indirector/catalog/store_configs_spec.rb +17 -0
  198. data/spec/unit/indirector/certificate/ca_spec.rb +0 -4
  199. data/spec/unit/indirector/certificate/file_spec.rb +0 -4
  200. data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -5
  201. data/spec/unit/indirector/certificate_request/file_spec.rb +0 -4
  202. data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +0 -4
  203. data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +0 -4
  204. data/spec/unit/indirector/certificate_status/file_spec.rb +1 -1
  205. data/spec/unit/indirector/direct_file_server_spec.rb +0 -4
  206. data/spec/unit/indirector/facts/facter_spec.rb +0 -4
  207. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +3 -0
  208. data/spec/unit/indirector/facts/store_configs_spec.rb +17 -0
  209. data/spec/unit/indirector/file_bucket_file/file_spec.rb +3 -3
  210. data/spec/unit/indirector/file_content/file_server_spec.rb +0 -4
  211. data/spec/unit/indirector/file_content/file_spec.rb +0 -4
  212. data/spec/unit/indirector/file_metadata/file_server_spec.rb +0 -4
  213. data/spec/unit/indirector/file_metadata/file_spec.rb +0 -4
  214. data/spec/unit/indirector/file_server_spec.rb +1 -5
  215. data/spec/unit/indirector/indirection_spec.rb +0 -4
  216. data/spec/unit/indirector/key/ca_spec.rb +0 -4
  217. data/spec/unit/indirector/key/file_spec.rb +0 -4
  218. data/spec/unit/indirector/node/store_configs_spec.rb +16 -0
  219. data/spec/unit/indirector/report/processor_spec.rb +0 -4
  220. data/spec/unit/indirector/resource/active_record_spec.rb +192 -0
  221. data/spec/unit/indirector/resource/ral_spec.rb +1 -1
  222. data/spec/unit/indirector/resource/store_configs_spec.rb +12 -0
  223. data/spec/unit/indirector/resource_type/parser_spec.rb +3 -3
  224. data/spec/unit/indirector/ssl_file_spec.rb +25 -6
  225. data/spec/unit/indirector/store_configs_spec.rb +8 -0
  226. data/spec/unit/indirector/yaml_spec.rb +14 -0
  227. data/spec/unit/module_spec.rb +2 -2
  228. data/spec/unit/network/handler/fileserver_spec.rb +5 -5
  229. data/spec/unit/network/http/mongrel_spec.rb +0 -4
  230. data/spec/unit/network/http/webrick_spec.rb +5 -9
  231. data/spec/unit/network/http_pool_spec.rb +4 -75
  232. data/spec/unit/network/http_spec.rb +0 -4
  233. data/spec/unit/network/server_spec.rb +0 -4
  234. data/spec/unit/node/environment_spec.rb +18 -31
  235. data/spec/unit/node/facts_spec.rb +0 -4
  236. data/spec/unit/node_spec.rb +1 -8
  237. data/spec/unit/other/selinux_spec.rb +3 -1
  238. data/spec/unit/parameter_spec.rb +0 -10
  239. data/spec/unit/parser/ast/collexpr_spec.rb +17 -13
  240. data/spec/unit/parser/collector_spec.rb +147 -263
  241. data/spec/unit/parser/compiler_spec.rb +3 -1
  242. data/spec/unit/parser/files_spec.rb +7 -4
  243. data/spec/unit/parser/functions/extlookup_spec.rb +6 -3
  244. data/spec/unit/parser/functions/sprintf_spec.rb +2 -1
  245. data/spec/unit/parser/type_loader_spec.rb +7 -7
  246. data/spec/unit/property_spec.rb +1 -1
  247. data/spec/unit/provider/augeas/augeas_spec.rb +14 -0
  248. data/spec/unit/provider/exec/posix_spec.rb +102 -106
  249. data/spec/unit/provider/exec/shell_spec.rb +1 -1
  250. data/spec/unit/provider/exec/windows_spec.rb +119 -0
  251. data/spec/unit/provider/group/ldap_spec.rb +0 -4
  252. data/spec/unit/provider/group/windows_adsi_spec.rb +79 -0
  253. data/spec/unit/provider/ldap_spec.rb +0 -4
  254. data/spec/unit/provider/macauthorization_spec.rb +5 -0
  255. data/spec/unit/provider/mount/parsed_spec.rb +1 -5
  256. data/spec/unit/provider/package/msi_spec.rb +170 -0
  257. data/spec/unit/provider/service/redhat_spec.rb +2 -0
  258. data/spec/unit/provider/service/smf_spec.rb +3 -0
  259. data/spec/unit/provider/service/systemd_spec.rb +25 -0
  260. data/spec/unit/provider/service/windows_spec.rb +166 -0
  261. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -2
  262. data/spec/unit/provider/user/ldap_spec.rb +0 -4
  263. data/spec/unit/provider/user/user_role_add_spec.rb +1 -1
  264. data/spec/unit/provider/user/useradd_spec.rb +1 -1
  265. data/spec/unit/provider/user/windows_adsi_spec.rb +110 -0
  266. data/spec/unit/relationship_spec.rb +0 -4
  267. data/spec/unit/resource/catalog_spec.rb +37 -25
  268. data/spec/unit/resource/status_spec.rb +4 -2
  269. data/spec/unit/resource_spec.rb +5 -5
  270. data/spec/unit/simple_graph_spec.rb +0 -4
  271. data/spec/unit/ssl/certificate_authority_spec.rb +2 -2
  272. data/spec/unit/ssl/host_spec.rb +12 -13
  273. data/spec/unit/ssl/inventory_spec.rb +2 -2
  274. data/spec/unit/sslcertificates/ca_spec.rb +6 -10
  275. data/spec/unit/transaction/event_manager_spec.rb +4 -2
  276. data/spec/unit/transaction/event_spec.rb +3 -1
  277. data/spec/unit/transaction/report_spec.rb +2 -6
  278. data/spec/unit/transaction/resource_harness_spec.rb +9 -5
  279. data/spec/unit/transaction_spec.rb +3 -1
  280. data/spec/unit/type/cron_spec.rb +1 -1
  281. data/spec/unit/type/exec_spec.rb +80 -47
  282. data/spec/unit/type/file/checksum_spec.rb +9 -8
  283. data/spec/unit/type/file/content_spec.rb +2 -1
  284. data/spec/unit/type/file/selinux_spec.rb +10 -8
  285. data/spec/unit/type/file/source_spec.rb +18 -36
  286. data/spec/unit/type/file_spec.rb +170 -217
  287. data/spec/unit/type/group_spec.rb +1 -1
  288. data/spec/unit/type/mount_spec.rb +5 -5
  289. data/spec/unit/type/noop_metaparam_spec.rb +3 -1
  290. data/spec/unit/type/package_spec.rb +15 -3
  291. data/spec/unit/type/resources_spec.rb +2 -2
  292. data/spec/unit/type/service_spec.rb +19 -4
  293. data/spec/unit/type/ssh_authorized_key_spec.rb +10 -4
  294. data/spec/unit/type/tidy_spec.rb +3 -1
  295. data/spec/unit/type/user_spec.rb +1 -1
  296. data/spec/unit/type_spec.rb +29 -34
  297. data/spec/unit/util/adsi_spec.rb +202 -0
  298. data/spec/unit/util/autoload_spec.rb +23 -19
  299. data/spec/unit/util/backups_spec.rb +16 -13
  300. data/spec/unit/util/cacher_spec.rb +64 -141
  301. data/spec/unit/util/checksums_spec.rb +0 -4
  302. data/spec/unit/util/constant_inflector_spec.rb +0 -4
  303. data/spec/unit/util/execution_stub_spec.rb +1 -1
  304. data/spec/unit/util/ldap/connection_spec.rb +0 -4
  305. data/spec/unit/util/ldap/generator_spec.rb +0 -4
  306. data/spec/unit/util/ldap/manager_spec.rb +0 -4
  307. data/spec/unit/util/log_spec.rb +4 -2
  308. data/spec/unit/util/logging_spec.rb +2 -2
  309. data/spec/unit/util/nagios_maker_spec.rb +0 -4
  310. data/spec/unit/util/network_device/cisco/device_spec.rb +2 -1
  311. data/spec/unit/util/network_device/cisco/facts_spec.rb +3 -1
  312. data/spec/unit/util/network_device/config_spec.rb +5 -3
  313. data/spec/unit/util/rdoc/parser_spec.rb +7 -1
  314. data/spec/unit/util/run_mode_spec.rb +6 -2
  315. data/spec/unit/util/settings/file_setting_spec.rb +29 -2
  316. data/spec/unit/util/settings_spec.rb +28 -15
  317. data/spec/unit/util/storage_spec.rb +1 -1
  318. data/spec/unit/util/suidmanager_spec.rb +310 -0
  319. data/spec/unit/util/tagging_spec.rb +0 -4
  320. data/spec/unit/util_spec.rb +335 -0
  321. data/test/language/ast/variable.rb +0 -4
  322. data/test/lib/puppettest/support/resources.rb +0 -4
  323. data/test/lib/puppettest/testcase.rb +0 -4
  324. data/test/lib/puppettest.rb +0 -1
  325. data/test/network/handler/master.rb +0 -5
  326. data/test/network/server/webrick.rb +5 -22
  327. data/test/ral/manager/attributes.rb +0 -4
  328. data/test/ral/manager/instances.rb +0 -4
  329. data/test/ral/manager/manager.rb +0 -4
  330. data/test/ral/providers/cron/crontab.rb +1 -0
  331. data/test/ral/providers/service/base.rb +0 -4
  332. data/test/ral/type/filesources.rb +0 -1
  333. data/test/ral/type/resources.rb +0 -4
  334. data/test/util/utiltest.rb +0 -13
  335. metadata +36 -9
  336. data/spec/unit/network/client_spec.rb +0 -45
  337. data/test/puppet/tc_suidmanager.rb +0 -120
@@ -0,0 +1,335 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Puppet::Util do
6
+ describe "#absolute_path?" do
7
+ it "should default to the platform of the local system" do
8
+ Puppet.features.stubs(:posix?).returns(true)
9
+ Puppet.features.stubs(:microsoft_windows?).returns(false)
10
+
11
+ Puppet::Util.should be_absolute_path('/foo')
12
+ Puppet::Util.should_not be_absolute_path('C:/foo')
13
+
14
+ Puppet.features.stubs(:posix?).returns(false)
15
+ Puppet.features.stubs(:microsoft_windows?).returns(true)
16
+
17
+ Puppet::Util.should be_absolute_path('C:/foo')
18
+ Puppet::Util.should_not be_absolute_path('/foo')
19
+ end
20
+
21
+ describe "when using platform :posix" do
22
+ %w[/ /foo /foo/../bar //foo //Server/Foo/Bar //?/C:/foo/bar /\Server/Foo].each do |path|
23
+ it "should return true for #{path}" do
24
+ Puppet::Util.should be_absolute_path(path, :posix)
25
+ end
26
+ end
27
+
28
+ %w[. ./foo \foo C:/foo \\Server\Foo\Bar \\?\C:\foo\bar \/?/foo\bar \/Server/foo].each do |path|
29
+ it "should return false for #{path}" do
30
+ Puppet::Util.should_not be_absolute_path(path, :posix)
31
+ end
32
+ end
33
+ end
34
+
35
+ describe "when using platform :windows" do
36
+ %w[C:/foo C:\foo \\\\Server\Foo\Bar \\\\?\C:\foo\bar //Server/Foo/Bar //?/C:/foo/bar /\?\C:/foo\bar \/Server\Foo/Bar].each do |path|
37
+ it "should return true for #{path}" do
38
+ Puppet::Util.should be_absolute_path(path, :windows)
39
+ end
40
+ end
41
+
42
+ %w[/ . ./foo \foo /foo /foo/../bar //foo C:foo/bar].each do |path|
43
+ it "should return false for #{path}" do
44
+ Puppet::Util.should_not be_absolute_path(path, :windows)
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "execution methods" do
51
+ let(:pid) { 5501 }
52
+ let(:null_file) { Puppet.features.microsoft_windows? ? 'NUL' : '/dev/null' }
53
+
54
+ describe "#execute_posix" do
55
+ before :each do
56
+ # Most of the things this method does are bad to do during specs. :/
57
+ Kernel.stubs(:fork).returns(pid).yields
58
+ Process.stubs(:setsid)
59
+ Kernel.stubs(:exec)
60
+ Puppet::Util::SUIDManager.stubs(:change_user)
61
+ Puppet::Util::SUIDManager.stubs(:change_group)
62
+
63
+ $stdin.stubs(:reopen)
64
+ $stdout.stubs(:reopen)
65
+ $stderr.stubs(:reopen)
66
+
67
+ @stdin = File.open(null_file, 'r')
68
+ @stdout = Tempfile.new('stdout')
69
+ @stderr = File.open(null_file, 'w')
70
+ end
71
+
72
+ it "should fork a child process to execute the command" do
73
+ Kernel.expects(:fork).returns(pid).yields
74
+ Kernel.expects(:exec).with('test command')
75
+
76
+ Puppet::Util.execute_posix('test command', {}, @stdin, @stdout, @stderr)
77
+ end
78
+
79
+ it "should start a new session group" do
80
+ Process.expects(:setsid)
81
+
82
+ Puppet::Util.execute_posix('test command', {}, @stdin, @stdout, @stderr)
83
+ end
84
+
85
+ it "should close all open file descriptors except stdin/stdout/stderr" do
86
+ # This is ugly, but I can't really think of a better way to do it without
87
+ # letting it actually close fds, which seems risky
88
+ (0..2).each {|n| IO.expects(:new).with(n).never}
89
+ (3..256).each {|n| IO.expects(:new).with(n).returns mock('io', :close) }
90
+
91
+ Puppet::Util.execute_posix('test command', {}, @stdin, @stdout, @stderr)
92
+ end
93
+
94
+ it "should permanently change to the correct user and group if specified" do
95
+ Puppet::Util::SUIDManager.expects(:change_group).with(55, true)
96
+ Puppet::Util::SUIDManager.expects(:change_user).with(50, true)
97
+
98
+ Puppet::Util.execute_posix('test command', {:uid => 50, :gid => 55}, @stdin, @stdout, @stderr)
99
+ end
100
+
101
+ it "should exit failure if there is a problem execing the command" do
102
+ Kernel.expects(:exec).with('test command').raises("failed to execute!")
103
+ Puppet::Util.stubs(:puts)
104
+ Puppet::Util.expects(:exit!).with(1)
105
+
106
+ Puppet::Util.execute_posix('test command', {}, @stdin, @stdout, @stderr)
107
+ end
108
+
109
+ it "should properly execute commands specified as arrays" do
110
+ Kernel.expects(:exec).with('test command', 'with', 'arguments')
111
+
112
+ Puppet::Util.execute_posix(['test command', 'with', 'arguments'], {:uid => 50, :gid => 55}, @stdin, @stdout, @stderr)
113
+ end
114
+
115
+ it "should return the pid of the child process" do
116
+ Puppet::Util.execute_posix('test command', {}, @stdin, @stdout, @stderr).should == pid
117
+ end
118
+ end
119
+
120
+ describe "#execute_windows" do
121
+ let(:proc_info_stub) { stub 'processinfo', :process_id => pid }
122
+
123
+ before :each do
124
+ Process.stubs(:create).returns(proc_info_stub)
125
+ Process.stubs(:waitpid2).with(pid).returns([pid, 0])
126
+
127
+ @stdin = File.open(null_file, 'r')
128
+ @stdout = Tempfile.new('stdout')
129
+ @stderr = File.open(null_file, 'w')
130
+ end
131
+
132
+ it "should create a new process for the command" do
133
+ Process.expects(:create).with(
134
+ :command_line => "test command",
135
+ :startup_info => {:stdin => @stdin, :stdout => @stdout, :stderr => @stderr}
136
+ ).returns(proc_info_stub)
137
+
138
+ Puppet::Util.execute_windows('test command', {}, @stdin, @stdout, @stderr)
139
+ end
140
+
141
+ it "should return the pid of the child process" do
142
+ Puppet::Util.execute_windows('test command', {}, @stdin, @stdout, @stderr).should == pid
143
+ end
144
+
145
+ it "should quote arguments containing spaces if command is specified as an array" do
146
+ Process.expects(:create).with do |args|
147
+ args[:command_line] == '"test command" with some "arguments \"with spaces"'
148
+ end.returns(proc_info_stub)
149
+
150
+ Puppet::Util.execute_windows(['test command', 'with', 'some', 'arguments "with spaces'], {}, @stdin, @stdout, @stderr)
151
+ end
152
+ end
153
+
154
+ describe "#execute" do
155
+ before :each do
156
+ Process.stubs(:waitpid2).with(pid).returns([pid, 0])
157
+ end
158
+
159
+ describe "when an execution stub is specified" do
160
+ before :each do
161
+ Puppet::Util::ExecutionStub.set do |command,args,stdin,stdout,stderr|
162
+ "execution stub output"
163
+ end
164
+ end
165
+
166
+ it "should call the block on the stub" do
167
+ Puppet::Util.execute("/usr/bin/run_my_execute_stub").should == "execution stub output"
168
+ end
169
+
170
+ it "should not actually execute anything" do
171
+ Puppet::Util.expects(:execute_posix).never
172
+ Puppet::Util.expects(:execute_windows).never
173
+
174
+ Puppet::Util.execute("/usr/bin/run_my_execute_stub")
175
+ end
176
+ end
177
+
178
+ describe "when setting up input and output files" do
179
+ include PuppetSpec::Files
180
+ let(:executor) { Puppet.features.microsoft_windows? ? 'execute_windows' : 'execute_posix' }
181
+
182
+ before :each do
183
+ Puppet::Util.stubs(:wait_for_output)
184
+ end
185
+
186
+ it "should set stdin to the stdinfile if specified" do
187
+ input = tmpfile('stdin')
188
+ FileUtils.touch(input)
189
+
190
+ Puppet::Util.expects(executor).with do |_,_,stdin,_,_|
191
+ stdin.path == input
192
+ end.returns(pid)
193
+
194
+ Puppet::Util.execute('test command', :stdinfile => input)
195
+ end
196
+
197
+ it "should set stdin to the null file if not specified" do
198
+ Puppet::Util.expects(executor).with do |_,_,stdin,_,_|
199
+ stdin.path == null_file
200
+ end.returns(pid)
201
+
202
+ Puppet::Util.execute('test command')
203
+ end
204
+
205
+ describe "when squelch is set" do
206
+ it "should set stdout and stderr to the null file" do
207
+ Puppet::Util.expects(executor).with do |_,_,_,stdout,stderr|
208
+ stdout.path == null_file and stderr.path == null_file
209
+ end.returns(pid)
210
+
211
+ Puppet::Util.execute('test command', :squelch => true)
212
+ end
213
+ end
214
+
215
+ describe "when squelch is not set" do
216
+ it "should set stdout to a temporary output file" do
217
+ outfile = Tempfile.new('stdout')
218
+ Tempfile.stubs(:new).returns(outfile)
219
+
220
+ Puppet::Util.expects(executor).with do |_,_,_,stdout,_|
221
+ stdout.path == outfile.path
222
+ end.returns(pid)
223
+
224
+ Puppet::Util.execute('test command', :squelch => false)
225
+ end
226
+
227
+ it "should set stderr to the same file as stdout if combine is true" do
228
+ outfile = Tempfile.new('stdout')
229
+ Tempfile.stubs(:new).returns(outfile)
230
+
231
+ Puppet::Util.expects(executor).with do |_,_,_,stdout,stderr|
232
+ stdout.path == outfile.path and stderr.path == outfile.path
233
+ end.returns(pid)
234
+
235
+ Puppet::Util.execute('test command', :squelch => false, :combine => true)
236
+ end
237
+
238
+ it "should set stderr to the null device if combine is false" do
239
+ outfile = Tempfile.new('stdout')
240
+ Tempfile.stubs(:new).returns(outfile)
241
+
242
+ Puppet::Util.expects(executor).with do |_,_,_,stdout,stderr|
243
+ stdout.path == outfile.path and stderr.path == null_file
244
+ end.returns(pid)
245
+
246
+ Puppet::Util.execute('test command', :squelch => false, :combine => false)
247
+ end
248
+ end
249
+ end
250
+ end
251
+
252
+ describe "after execution" do
253
+ let(:executor) { Puppet.features.microsoft_windows? ? 'execute_windows' : 'execute_posix' }
254
+ before :each do
255
+ Process.stubs(:waitpid2).with(pid).returns([pid, 0])
256
+
257
+ Puppet::Util.stubs(executor).returns(pid)
258
+ end
259
+
260
+ it "should wait for the child process to exit" do
261
+ Puppet::Util.stubs(:wait_for_output)
262
+
263
+ Process.expects(:waitpid2).with(pid).returns([pid, 0])
264
+
265
+ Puppet::Util.execute('test command')
266
+ end
267
+
268
+ it "should close the stdin/stdout/stderr files used by the child" do
269
+ stdin = mock 'file', :close
270
+ stdout = mock 'file', :close
271
+ stderr = mock 'file', :close
272
+
273
+ File.expects(:open).
274
+ times(3).
275
+ returns(stdin).
276
+ then.returns(stdout).
277
+ then.returns(stderr)
278
+
279
+ Puppet::Util.execute('test command', :squelch => true)
280
+ end
281
+
282
+ it "should read and return the output if squelch is false" do
283
+ stdout = Tempfile.new('test')
284
+ Tempfile.stubs(:new).returns(stdout)
285
+ stdout.write("My expected command output")
286
+
287
+ Puppet::Util.execute('test command').should == "My expected command output"
288
+ end
289
+
290
+ it "should not read the output if squelch is true" do
291
+ stdout = Tempfile.new('test')
292
+ Tempfile.stubs(:new).returns(stdout)
293
+ stdout.write("My expected command output")
294
+
295
+ Puppet::Util.execute('test command', :squelch => true).should == nil
296
+ end
297
+
298
+ it "should delete the file used for output if squelch is false" do
299
+ stdout = Tempfile.new('test')
300
+ path = stdout.path
301
+ Tempfile.stubs(:new).returns(stdout)
302
+
303
+ Puppet::Util.execute('test command')
304
+
305
+ File.should_not be_exist(path)
306
+ end
307
+
308
+ it "should raise an error if failonfail is true and the child failed" do
309
+ child_status = stub('child_status', :exitstatus => 1)
310
+
311
+ Process.expects(:waitpid2).with(pid).returns([pid, child_status])
312
+
313
+ expect {
314
+ Puppet::Util.execute('fail command', :failonfail => true)
315
+ }.to raise_error(Puppet::ExecutionFailure, /Execution of 'fail command' returned 1/)
316
+ end
317
+
318
+ it "should not raise an error if failonfail is false and the child failed" do
319
+ Process.expects(:waitpid2).with(pid).returns([pid, 1])
320
+
321
+ expect {
322
+ Puppet::Util.execute('fail command', :failonfail => false)
323
+ }.not_to raise_error
324
+ end
325
+
326
+ it "should not raise an error if failonfail is true and the child succeeded" do
327
+ Process.expects(:waitpid2).with(pid).returns([pid, 0])
328
+
329
+ expect {
330
+ Puppet::Util.execute('fail command', :failonfail => true)
331
+ }.not_to raise_error
332
+ end
333
+ end
334
+ end
335
+ end
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- #
3
- # Created by Luke A. Kanies on 2007-0419.
4
- # Copyright (c) 2006. All rights reserved.
5
-
6
2
  require File.expand_path(File.dirname(__FILE__) + '/../../lib/puppettest')
7
3
 
8
4
  require 'puppettest'
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- #
3
- # Created by Luke A. Kanies on 2006-11-29.
4
- # Copyright (c) 2006. All rights reserved.
5
-
6
2
  module PuppetTest::Support::Resources
7
3
  def tree_resource(name)
8
4
  Puppet::Type.type(:file).new :title => name, :path => "/tmp/#{name}", :mode => 0755
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- #
3
- # Created by Luke A. Kanies on 2007-03-05.
4
- # Copyright (c) 2007. All rights reserved.
5
-
6
2
  require 'puppettest'
7
3
  require 'puppettest/runnable_test'
8
4
  require 'test/unit'
@@ -280,7 +280,6 @@ module PuppetTest
280
280
  Puppet::Util::Storage.clear
281
281
  Puppet.clear
282
282
  Puppet.settings.clear
283
- Puppet::Util::Cacher.expire
284
283
 
285
284
  @memoryatend = Puppet::Util.memory
286
285
  diff = @memoryatend - @memoryatstart
@@ -16,11 +16,6 @@ class TestMaster < Test::Unit::TestCase
16
16
  Puppet::Resource::Catalog.indirection.stubs(:find).returns(@catalog)
17
17
  end
18
18
 
19
- def teardown
20
- super
21
- Puppet::Util::Cacher.expire
22
- end
23
-
24
19
  def test_freshness_is_always_now
25
20
  now1 = mock 'now1'
26
21
  Time.stubs(:now).returns(now1)
@@ -11,24 +11,17 @@ class TestWebrickServer < Test::Unit::TestCase
11
11
 
12
12
  def setup
13
13
  Puppet::Util::SUIDManager.stubs(:asuser).yields
14
+ Puppet::SSL::Host.instance_variable_set(:@localhost, nil)
14
15
  super
15
16
  end
16
17
 
17
- def teardown
18
- super
19
- Puppet::Network::HttpPool.clear_http_instances
20
- end
21
-
22
18
  # Make sure we can create a server, and that it knows how to create its
23
19
  # certs by default.
24
20
  def test_basics
25
21
  server = nil
26
22
  assert_raise(Puppet::Error, "server succeeded with no cert") do
27
-
28
- server = Puppet::Network::HTTPServer::WEBrick.new(
29
-
23
+ server = Puppet::Network::HTTPServer::WEBrick.new(
30
24
  :Port => @@port,
31
-
32
25
  :Handlers => {
33
26
  :Status => nil
34
27
  }
@@ -36,11 +29,8 @@ class TestWebrickServer < Test::Unit::TestCase
36
29
  end
37
30
 
38
31
  assert_nothing_raised("Could not create simple server") do
39
-
40
- server = Puppet::Network::HTTPServer::WEBrick.new(
41
-
32
+ server = Puppet::Network::HTTPServer::WEBrick.new(
42
33
  :Port => @@port,
43
-
44
34
  :Handlers => {
45
35
  :CA => {}, # so that certs autogenerate
46
36
  :Status => nil
@@ -76,11 +66,8 @@ class TestWebrickServer < Test::Unit::TestCase
76
66
  client = nil
77
67
 
78
68
  assert_nothing_raised {
79
-
80
- client = Puppet::Network::Client.status.new(
81
-
69
+ client = Puppet::Network::Client.status.new(
82
70
  :Server => "localhost",
83
-
84
71
  :Port => @@port
85
72
  )
86
73
  }
@@ -91,17 +78,13 @@ class TestWebrickServer < Test::Unit::TestCase
91
78
  server = nil
92
79
  Puppet[:certdnsnames] = "localhost"
93
80
  assert_nothing_raised {
94
-
95
- server = Puppet::Network::HTTPServer::WEBrick.new(
96
-
81
+ server = Puppet::Network::HTTPServer::WEBrick.new(
97
82
  :Port => @@port,
98
-
99
83
  :Handlers => {
100
84
  :CA => {}, # so that certs autogenerate
101
85
  :Status => nil
102
86
  }
103
87
  )
104
-
105
88
  }
106
89
 
107
90
  pid = fork {
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- #
3
- # Created by Luke A. Kanies on 2007-02-05.
4
- # Copyright (c) 2007. All rights reserved.
5
-
6
2
  require File.expand_path(File.dirname(__FILE__) + '/../../lib/puppettest')
7
3
 
8
4
  require 'puppettest'
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- #
3
- # Created by Luke A. Kanies on 2007-06-10.
4
- # Copyright (c) 2007. All rights reserved.
5
-
6
2
  require File.expand_path(File.dirname(__FILE__) + '/../../lib/puppettest')
7
3
 
8
4
  require 'puppettest'
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- #
3
- # Created by Luke A. Kanies on 2006-11-29.
4
- # Copyright (c) 2006. All rights reserved.
5
-
6
2
  require File.expand_path(File.dirname(__FILE__) + '/../../lib/puppettest')
7
3
 
8
4
  require 'puppettest'
@@ -378,6 +378,7 @@ class TestCronParsedProvider < Test::Unit::TestCase
378
378
  target = @provider.target_object(@me)
379
379
 
380
380
  [
381
+ " FOO=var",
381
382
  "* * * * * /some/command",
382
383
  "0,30 * * * * /some/command",
383
384
  "0-30 * * * * /some/command",
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- #
3
- # Created by Luke A. Kanies on 2007-01-28.
4
- # Copyright (c) 2007. All rights reserved.
5
-
6
2
  require File.expand_path(File.dirname(__FILE__) + '/../../../lib/puppettest')
7
3
 
8
4
  require 'puppettest'
@@ -26,7 +26,6 @@ class TestFileSources < Test::Unit::TestCase
26
26
 
27
27
  def teardown
28
28
  super
29
- Puppet::Network::HttpPool.clear_http_instances
30
29
  end
31
30
 
32
31
  def use_storage
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- #
3
- # Created by Luke Kanies on 2006-12-12.
4
- # Copyright (c) 2006. All rights reserved.
5
-
6
2
  require File.expand_path(File.dirname(__FILE__) + '/../../lib/puppettest')
7
3
 
8
4
  require 'puppettest'
@@ -219,18 +219,5 @@ class TestPuppetUtil < Test::Unit::TestCase
219
219
  end
220
220
 
221
221
  end
222
-
223
- # Check whether execute accepts strings in addition to arrays.
224
- def test_string_exec
225
- cmd = "/bin/echo howdy"
226
- output = nil
227
- assert_raise(ArgumentError) {
228
- output = Puppet::Util.execute(cmd)
229
- }
230
- #assert_equal("howdy\n", output)
231
- #assert_raise(RuntimeError) {
232
- # Puppet::Util.execute(cmd, 0, 0)
233
- #}
234
- end
235
222
  end
236
223