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
@@ -254,6 +254,7 @@ describe content do
254
254
  @content.should = "{md5}foo"
255
255
  @content.resource.bucket.class.any_instance.stubs(:getfile).returns "foo"
256
256
  @content.write(@fh)
257
+ @fh.close
257
258
  end
258
259
 
259
260
  describe "from actual content" do
@@ -298,7 +299,7 @@ describe content do
298
299
  end
299
300
  end
300
301
 
301
- describe "from local source" do
302
+ describe "from local source", :fails_on_windows => true do
302
303
  before(:each) do
303
304
  @resource = Puppet::Type.type(:file).new :path => @filename, :backup => false
304
305
  @sourcename = tmpfile('source')
@@ -1,12 +1,14 @@
1
1
  #!/usr/bin/env rspec
2
2
  require 'spec_helper'
3
3
 
4
-
5
4
  [:seluser, :selrole, :seltype, :selrange].each do |param|
6
5
  property = Puppet::Type.type(:file).attrclass(param)
7
6
  describe property do
7
+ include PuppetSpec::Files
8
+
8
9
  before do
9
- @resource = Puppet::Type.type(:file).new :path => "/my/file"
10
+ @path = make_absolute("/my/file")
11
+ @resource = Puppet::Type.type(:file).new :path => @path
10
12
  @sel = property.new :resource => @resource
11
13
  end
12
14
 
@@ -18,14 +20,14 @@ require 'spec_helper'
18
20
  it "should retrieve nil for #{param} if there is no SELinux support" do
19
21
  stat = stub 'stat', :ftype => "foo"
20
22
  @resource.expects(:stat).returns stat
21
- @sel.expects(:get_selinux_current_context).with("/my/file").returns nil
23
+ @sel.expects(:get_selinux_current_context).with(@path).returns nil
22
24
  @sel.retrieve.should be_nil
23
25
  end
24
26
 
25
27
  it "should retrieve #{param} if a SELinux context is found with a range" do
26
28
  stat = stub 'stat', :ftype => "foo"
27
29
  @resource.expects(:stat).returns stat
28
- @sel.expects(:get_selinux_current_context).with("/my/file").returns "user_u:role_r:type_t:s0"
30
+ @sel.expects(:get_selinux_current_context).with(@path).returns "user_u:role_r:type_t:s0"
29
31
  expectedresult = case param
30
32
  when :seluser; "user_u"
31
33
  when :selrole; "role_r"
@@ -38,7 +40,7 @@ require 'spec_helper'
38
40
  it "should retrieve #{param} if a SELinux context is found without a range" do
39
41
  stat = stub 'stat', :ftype => "foo"
40
42
  @resource.expects(:stat).returns stat
41
- @sel.expects(:get_selinux_current_context).with("/my/file").returns "user_u:role_r:type_t"
43
+ @sel.expects(:get_selinux_current_context).with(@path).returns "user_u:role_r:type_t"
42
44
  expectedresult = case param
43
45
  when :seluser; "user_u"
44
46
  when :selrole; "role_r"
@@ -49,13 +51,13 @@ require 'spec_helper'
49
51
  end
50
52
 
51
53
  it "should handle no default gracefully" do
52
- @sel.expects(:get_selinux_default_context).with("/my/file").returns nil
54
+ @sel.expects(:get_selinux_default_context).with(@path).returns nil
53
55
  @sel.default.must be_nil
54
56
  end
55
57
 
56
58
  it "should be able to detect matchpathcon defaults" do
57
59
  @sel.stubs(:debug)
58
- @sel.expects(:get_selinux_default_context).with("/my/file").returns "user_u:role_r:type_t:s0"
60
+ @sel.expects(:get_selinux_default_context).with(@path).returns "user_u:role_r:type_t:s0"
59
61
  expectedresult = case param
60
62
  when :seluser; "user_u"
61
63
  when :selrole; "role_r"
@@ -73,7 +75,7 @@ require 'spec_helper'
73
75
  it "should be able to set a new context" do
74
76
  stat = stub 'stat', :ftype => "foo"
75
77
  @sel.should = %w{newone}
76
- @sel.expects(:set_selinux_context).with("/my/file", ["newone"], param)
78
+ @sel.expects(:set_selinux_context).with(@path, ["newone"], param)
77
79
  @sel.sync
78
80
  end
79
81
 
@@ -3,9 +3,13 @@ require 'spec_helper'
3
3
 
4
4
  source = Puppet::Type.type(:file).attrclass(:source)
5
5
  describe Puppet::Type.type(:file).attrclass(:source) do
6
+ include PuppetSpec::Files
7
+
6
8
  before do
7
9
  # Wow that's a messy interface to the resource.
8
10
  @resource = stub 'resource', :[]= => nil, :property => nil, :catalog => stub("catalog", :dependent_data_expired? => false), :line => 0, :file => ''
11
+ @foobar = make_absolute("/foo/bar")
12
+ @feebooz = make_absolute("/fee/booz")
9
13
  end
10
14
 
11
15
  it "should be a subclass of Parameter" do
@@ -27,15 +31,7 @@ describe Puppet::Type.type(:file).attrclass(:source) do
27
31
  end
28
32
  end
29
33
 
30
- it "should have a method for retrieving its metadata" do
31
- source.new(:resource => @resource).must respond_to(:metadata)
32
- end
33
-
34
- it "should have a method for setting its metadata" do
35
- source.new(:resource => @resource).must respond_to(:metadata=)
36
- end
37
-
38
- describe "when returning the metadata" do
34
+ describe "when returning the metadata", :fails_on_windows => true do
39
35
  before do
40
36
  @metadata = stub 'metadata', :source= => nil
41
37
  end
@@ -52,58 +48,44 @@ describe Puppet::Type.type(:file).attrclass(:source) do
52
48
  end
53
49
 
54
50
  it "should collect its metadata using the Metadata class if it is not already set" do
55
- @source = source.new(:resource => @resource, :value => "/foo/bar")
56
- Puppet::FileServing::Metadata.indirection.expects(:find).with("/foo/bar").returns @metadata
51
+ @source = source.new(:resource => @resource, :value => @foobar)
52
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar).returns @metadata
57
53
  @source.metadata
58
54
  end
59
55
 
60
56
  it "should use the metadata from the first found source" do
61
57
  metadata = stub 'metadata', :source= => nil
62
- @source = source.new(:resource => @resource, :value => ["/foo/bar", "/fee/booz"])
63
- Puppet::FileServing::Metadata.indirection.expects(:find).with("/foo/bar").returns nil
64
- Puppet::FileServing::Metadata.indirection.expects(:find).with("/fee/booz").returns metadata
58
+ @source = source.new(:resource => @resource, :value => [@foobar, @feebooz])
59
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar).returns nil
60
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@feebooz).returns metadata
65
61
  @source.metadata.should equal(metadata)
66
62
  end
67
63
 
68
64
  it "should store the found source as the metadata's source" do
69
65
  metadata = mock 'metadata'
70
- @source = source.new(:resource => @resource, :value => "/foo/bar")
71
- Puppet::FileServing::Metadata.indirection.expects(:find).with("/foo/bar").returns metadata
66
+ @source = source.new(:resource => @resource, :value => @foobar)
67
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar).returns metadata
72
68
 
73
- metadata.expects(:source=).with("/foo/bar")
69
+ metadata.expects(:source=).with(@foobar)
74
70
  @source.metadata
75
71
  end
76
72
 
77
73
  it "should fail intelligently if an exception is encountered while querying for metadata" do
78
- @source = source.new(:resource => @resource, :value => "/foo/bar")
79
- Puppet::FileServing::Metadata.indirection.expects(:find).with("/foo/bar").raises RuntimeError
74
+ @source = source.new(:resource => @resource, :value => @foobar)
75
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar).raises RuntimeError
80
76
 
81
77
  @source.expects(:fail).raises ArgumentError
82
78
  lambda { @source.metadata }.should raise_error(ArgumentError)
83
79
  end
84
80
 
85
81
  it "should fail if no specified sources can be found" do
86
- @source = source.new(:resource => @resource, :value => "/foo/bar")
87
- Puppet::FileServing::Metadata.indirection.expects(:find).with("/foo/bar").returns nil
82
+ @source = source.new(:resource => @resource, :value => @foobar)
83
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar).returns nil
88
84
 
89
85
  @source.expects(:fail).raises RuntimeError
90
86
 
91
87
  lambda { @source.metadata }.should raise_error(RuntimeError)
92
88
  end
93
-
94
- it "should expire the metadata appropriately" do
95
- expirer = stub 'expired', :dependent_data_expired? => true
96
-
97
- metadata = stub 'metadata', :source= => nil
98
- Puppet::FileServing::Metadata.indirection.expects(:find).with("/fee/booz").returns metadata
99
-
100
- @source = source.new(:resource => @resource, :value => ["/fee/booz"])
101
- @source.metadata = "foo"
102
-
103
- @source.stubs(:expirer).returns expirer
104
-
105
- @source.metadata.should_not == "foo"
106
- end
107
89
  end
108
90
 
109
91
  it "should have a method for setting the desired values on the resource" do
@@ -113,7 +95,7 @@ describe Puppet::Type.type(:file).attrclass(:source) do
113
95
  describe "when copying the source values" do
114
96
  before do
115
97
 
116
- @resource = Puppet::Type.type(:file).new :path => "/foo/bar"
98
+ @resource = Puppet::Type.type(:file).new :path => @foobar
117
99
 
118
100
  @source = source.new(:resource => @resource)
119
101
  @metadata = stub 'metadata', :owner => 100, :group => 200, :mode => 123, :checksum => "{md5}asdfasdf", :ftype => "file"
@@ -37,7 +37,6 @@ describe Puppet::Type.type(:file) do
37
37
  end
38
38
 
39
39
  describe "#write" do
40
-
41
40
  it "should propagate failures encountered when renaming the temporary file" do
42
41
  File.stubs(:open)
43
42
 
@@ -92,7 +91,6 @@ describe Puppet::Type.type(:file) do
92
91
 
93
92
  lambda { @file.write :NOTUSED }.should_not raise_error(Puppet::Error)
94
93
  end
95
-
96
94
  end
97
95
  end
98
96
 
@@ -152,255 +150,204 @@ describe Puppet::Type.type(:file) do
152
150
  end
153
151
 
154
152
  describe "when using POSIX filenames" do
155
- describe "on POSIX systems" do
156
- before do
157
- Puppet.features.stubs(:posix?).returns(true)
158
- Puppet.features.stubs(:microsoft_windows?).returns(false)
159
- end
160
-
161
- it "should autorequire its parent directory" do
162
- file = Puppet::Type::File.new(:path => "/foo/bar")
163
- dir = Puppet::Type::File.new(:path => "/foo")
164
- @catalog.add_resource file
165
- @catalog.add_resource dir
166
- reqs = file.autorequire
167
- reqs[0].source.must == dir
168
- reqs[0].target.must == file
169
- end
170
-
171
- it "should autorequire its nearest ancestor directory" do
172
- file = Puppet::Type::File.new(:path => "/foo/bar/baz")
173
- dir = Puppet::Type::File.new(:path => "/foo")
174
- root = Puppet::Type::File.new(:path => "/")
175
- @catalog.add_resource file
176
- @catalog.add_resource dir
177
- @catalog.add_resource root
178
- reqs = file.autorequire
179
- reqs.length.must == 1
180
- reqs[0].source.must == dir
181
- reqs[0].target.must == file
182
- end
183
-
184
- it "should not autorequire anything when there is no nearest ancestor directory" do
185
- file = Puppet::Type::File.new(:path => "/foo/bar/baz")
186
- @catalog.add_resource file
187
- file.autorequire.should be_empty
188
- end
189
-
190
- it "should not autorequire its parent dir if its parent dir is itself" do
191
- file = Puppet::Type::File.new(:path => "/")
192
- @catalog.add_resource file
193
- file.autorequire.should be_empty
194
- end
195
-
196
- it "should remove trailing slashes" do
197
- file = Puppet::Type::File.new(:path => "/foo/bar/baz/")
198
- file[:path].should == "/foo/bar/baz"
199
- end
200
-
201
- it "should remove double slashes" do
202
- file = Puppet::Type::File.new(:path => "/foo/bar//baz")
203
- file[:path].should == "/foo/bar/baz"
204
- end
153
+ it "should autorequire its parent directory" do
154
+ file = Puppet::Type::File.new(:path => "/foo/bar")
155
+ dir = Puppet::Type::File.new(:path => "/foo")
156
+ @catalog.add_resource file
157
+ @catalog.add_resource dir
158
+ reqs = file.autorequire
159
+ reqs[0].source.must == dir
160
+ reqs[0].target.must == file
161
+ end
205
162
 
206
- it "should remove trailing double slashes" do
207
- file = Puppet::Type::File.new(:path => "/foo/bar/baz//")
208
- file[:path].should == "/foo/bar/baz"
209
- end
163
+ it "should autorequire its nearest ancestor directory" do
164
+ file = Puppet::Type::File.new(:path => "/foo/bar/baz")
165
+ dir = Puppet::Type::File.new(:path => "/foo")
166
+ root = Puppet::Type::File.new(:path => "/")
167
+ @catalog.add_resource file
168
+ @catalog.add_resource dir
169
+ @catalog.add_resource root
170
+ reqs = file.autorequire
171
+ reqs.length.must == 1
172
+ reqs[0].source.must == dir
173
+ reqs[0].target.must == file
174
+ end
210
175
 
211
- it "should leave a single slash alone" do
212
- file = Puppet::Type::File.new(:path => "/")
213
- file[:path].should == "/"
214
- end
176
+ it "should not autorequire anything when there is no nearest ancestor directory" do
177
+ file = Puppet::Type::File.new(:path => "/foo/bar/baz")
178
+ @catalog.add_resource file
179
+ file.autorequire.should be_empty
180
+ end
215
181
 
216
- it "should accept a double-slash at the start of the path" do
217
- expect {
218
- file = Puppet::Type::File.new(:path => "//tmp/xxx")
219
- # REVISIT: This should be wrong, later. See the next test.
220
- # --daniel 2011-01-31
221
- file[:path].should == '/tmp/xxx'
222
- }.should_not raise_error
223
- end
182
+ it "should not autorequire its parent dir if its parent dir is itself" do
183
+ file = Puppet::Type::File.new(:path => "/")
184
+ @catalog.add_resource file
185
+ file.autorequire.should be_empty
186
+ end
224
187
 
225
- # REVISIT: This is pending, because I don't want to try and audit the
226
- # entire codebase to make sure we get this right. POSIX treats two (and
227
- # exactly two) '/' characters at the start of the path specially.
228
- #
229
- # See sections 3.2 and 4.11, which allow DomainOS to be all special like
230
- # and still have the POSIX branding and all. --daniel 2011-01-31
231
- it "should preserve the double-slash at the start of the path"
188
+ it "should remove trailing slashes" do
189
+ file = Puppet::Type::File.new(:path => "/foo/bar/baz/")
190
+ file[:path].should == "/foo/bar/baz"
232
191
  end
233
192
 
234
- describe "on Microsoft Windows systems" do
235
- before do
236
- Puppet.features.stubs(:posix?).returns(false)
237
- Puppet.features.stubs(:microsoft_windows?).returns(true)
238
- end
193
+ it "should remove double slashes" do
194
+ file = Puppet::Type::File.new(:path => "/foo/bar//baz")
195
+ file[:path].should == "/foo/bar/baz"
196
+ end
239
197
 
240
- it "should refuse to work" do
241
- lambda { Puppet::Type::File.new(:path => "/foo/bar") }.should raise_error(Puppet::Error)
242
- end
198
+ it "should remove trailing double slashes" do
199
+ file = Puppet::Type::File.new(:path => "/foo/bar/baz//")
200
+ file[:path].should == "/foo/bar/baz"
243
201
  end
244
- end
245
202
 
246
- describe "when using Microsoft Windows filenames", :if => Puppet.features.microsoft_windows? do
247
- describe "on Microsoft Windows systems" do
248
- before do
249
- Puppet.features.stubs(:posix?).returns(false)
250
- Puppet.features.stubs(:microsoft_windows?).returns(true)
251
- end
203
+ it "should leave a single slash alone" do
204
+ file = Puppet::Type::File.new(:path => "/")
205
+ file[:path].should == "/"
206
+ end
252
207
 
253
- it "should autorequire its parent directory" do
254
- file = Puppet::Type::File.new(:path => "X:/foo/bar")
255
- dir = Puppet::Type::File.new(:path => "X:/foo")
256
- @catalog.add_resource file
257
- @catalog.add_resource dir
258
- reqs = file.autorequire
259
- reqs[0].source.must == dir
260
- reqs[0].target.must == file
261
- end
208
+ it "should accept a double-slash at the start of the path" do
209
+ expect {
210
+ file = Puppet::Type::File.new(:path => "//tmp/xxx")
211
+ # REVISIT: This should be wrong, later. See the next test.
212
+ # --daniel 2011-01-31
213
+ file[:path].should == '/tmp/xxx'
214
+ }.should_not raise_error
215
+ end
262
216
 
263
- it "should autorequire its nearest ancestor directory" do
264
- file = Puppet::Type::File.new(:path => "X:/foo/bar/baz")
265
- dir = Puppet::Type::File.new(:path => "X:/foo")
266
- root = Puppet::Type::File.new(:path => "X:/")
267
- @catalog.add_resource file
268
- @catalog.add_resource dir
269
- @catalog.add_resource root
270
- reqs = file.autorequire
271
- reqs.length.must == 1
272
- reqs[0].source.must == dir
273
- reqs[0].target.must == file
274
- end
217
+ # REVISIT: This is pending, because I don't want to try and audit the
218
+ # entire codebase to make sure we get this right. POSIX treats two (and
219
+ # exactly two) '/' characters at the start of the path specially.
220
+ #
221
+ # See sections 3.2 and 4.11, which allow DomainOS to be all special like
222
+ # and still have the POSIX branding and all. --daniel 2011-01-31
223
+ it "should preserve the double-slash at the start of the path"
224
+ end
275
225
 
276
- it "should not autorequire anything when there is no nearest ancestor directory" do
277
- file = Puppet::Type::File.new(:path => "X:/foo/bar/baz")
278
- @catalog.add_resource file
279
- file.autorequire.should be_empty
280
- end
226
+ describe "when using Microsoft Windows filenames" do
227
+ it "should autorequire its parent directory" do
228
+ file = Puppet::Type::File.new(:path => "X:/foo/bar")
229
+ dir = Puppet::Type::File.new(:path => "X:/foo")
230
+ @catalog.add_resource file
231
+ @catalog.add_resource dir
232
+ reqs = file.autorequire
233
+ reqs[0].source.must == dir
234
+ reqs[0].target.must == file
235
+ end
281
236
 
282
- it "should not autorequire its parent dir if its parent dir is itself" do
283
- file = Puppet::Type::File.new(:path => "X:/")
284
- @catalog.add_resource file
285
- file.autorequire.should be_empty
286
- end
237
+ it "should autorequire its nearest ancestor directory" do
238
+ file = Puppet::Type::File.new(:path => "X:/foo/bar/baz")
239
+ dir = Puppet::Type::File.new(:path => "X:/foo")
240
+ root = Puppet::Type::File.new(:path => "X:/")
241
+ @catalog.add_resource file
242
+ @catalog.add_resource dir
243
+ @catalog.add_resource root
244
+ reqs = file.autorequire
245
+ reqs.length.must == 1
246
+ reqs[0].source.must == dir
247
+ reqs[0].target.must == file
248
+ end
287
249
 
288
- it "should remove trailing slashes" do
289
- file = Puppet::Type::File.new(:path => "X:/foo/bar/baz/")
290
- file[:path].should == "X:/foo/bar/baz"
291
- end
250
+ it "should not autorequire anything when there is no nearest ancestor directory" do
251
+ file = Puppet::Type::File.new(:path => "X:/foo/bar/baz")
252
+ @catalog.add_resource file
253
+ file.autorequire.should be_empty
254
+ end
292
255
 
293
- it "should remove double slashes" do
294
- file = Puppet::Type::File.new(:path => "X:/foo/bar//baz")
295
- file[:path].should == "X:/foo/bar/baz"
296
- end
256
+ it "should not autorequire its parent dir if its parent dir is itself" do
257
+ file = Puppet::Type::File.new(:path => "X:/")
258
+ @catalog.add_resource file
259
+ file.autorequire.should be_empty
260
+ end
297
261
 
298
- it "should remove trailing double slashes" do
299
- file = Puppet::Type::File.new(:path => "X:/foo/bar/baz//")
300
- file[:path].should == "X:/foo/bar/baz"
301
- end
262
+ it "should remove trailing slashes" do
263
+ file = Puppet::Type::File.new(:path => "X:/foo/bar/baz/")
264
+ file[:path].should == "X:/foo/bar/baz"
265
+ end
302
266
 
303
- it "should leave a drive letter with a slash alone", :'fails_on_ruby_1.9.2' => true do
304
- file = Puppet::Type::File.new(:path => "X:/")
305
- file[:path].should == "X:/"
306
- end
267
+ it "should remove double slashes" do
268
+ file = Puppet::Type::File.new(:path => "X:/foo/bar//baz")
269
+ file[:path].should == "X:/foo/bar/baz"
270
+ end
307
271
 
308
- it "should add a slash to a drive letter", :'fails_on_ruby_1.9.2' => true do
309
- file = Puppet::Type::File.new(:path => "X:")
310
- file[:path].should == "X:/"
311
- end
272
+ it "should remove trailing double slashes" do
273
+ file = Puppet::Type::File.new(:path => "X:/foo/bar/baz//")
274
+ file[:path].should == "X:/foo/bar/baz"
312
275
  end
313
276
 
314
- describe "on POSIX systems" do
315
- before do
316
- Puppet.features.stubs(:posix?).returns(true)
317
- Puppet.features.stubs(:microsoft_windows?).returns(false)
318
- end
277
+ it "should leave a drive letter with a slash alone", :'fails_on_ruby_1.9.2' => true do
278
+ file = Puppet::Type::File.new(:path => "X:/")
279
+ file[:path].should == "X:/"
280
+ end
319
281
 
320
- it "should refuse to work" do
321
- lambda { Puppet::Type::File.new(:path => "X:/foo/bar") }.should raise_error(Puppet::Error)
322
- end
282
+ it "should not accept a drive letter without a slash", :'fails_on_ruby_1.9.2' => true do
283
+ lambda { Puppet::Type::File.new(:path => "X:") }.should raise_error(/File paths must be fully qualified/)
323
284
  end
324
285
  end
325
286
 
326
- describe "when using UNC filenames" do
327
- describe "on Microsoft Windows systems", :if => Puppet.features.microsoft_windows?, :'fails_on_ruby_1.9.2' => true do
328
- before do
329
- Puppet.features.stubs(:posix?).returns(false)
330
- Puppet.features.stubs(:microsoft_windows?).returns(true)
331
- end
332
-
333
- it "should autorequire its parent directory" do
334
- file = Puppet::Type::File.new(:path => "//server/foo/bar")
335
- dir = Puppet::Type::File.new(:path => "//server/foo")
336
- @catalog.add_resource file
337
- @catalog.add_resource dir
338
- reqs = file.autorequire
339
- reqs[0].source.must == dir
340
- reqs[0].target.must == file
341
- end
342
-
343
- it "should autorequire its nearest ancestor directory" do
344
- file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/qux")
345
- dir = Puppet::Type::File.new(:path => "//server/foo/bar")
346
- root = Puppet::Type::File.new(:path => "//server/foo")
347
- @catalog.add_resource file
348
- @catalog.add_resource dir
349
- @catalog.add_resource root
350
- reqs = file.autorequire
351
- reqs.length.must == 1
352
- reqs[0].source.must == dir
353
- reqs[0].target.must == file
354
- end
287
+ describe "when using UNC filenames", :'fails_on_ruby_1.9.2' => true do
288
+ before :each do
289
+ pending("UNC file paths not yet supported")
290
+ end
355
291
 
356
- it "should not autorequire anything when there is no nearest ancestor directory" do
357
- file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/qux")
358
- @catalog.add_resource file
359
- file.autorequire.should be_empty
360
- end
292
+ it "should autorequire its parent directory" do
293
+ file = Puppet::Type::File.new(:path => "//server/foo/bar")
294
+ dir = Puppet::Type::File.new(:path => "//server/foo")
295
+ @catalog.add_resource file
296
+ @catalog.add_resource dir
297
+ reqs = file.autorequire
298
+ reqs[0].source.must == dir
299
+ reqs[0].target.must == file
300
+ end
361
301
 
362
- it "should not autorequire its parent dir if its parent dir is itself" do
363
- file = Puppet::Type::File.new(:path => "//server/foo")
364
- @catalog.add_resource file
365
- puts file.autorequire
366
- file.autorequire.should be_empty
367
- end
302
+ it "should autorequire its nearest ancestor directory" do
303
+ file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/qux")
304
+ dir = Puppet::Type::File.new(:path => "//server/foo/bar")
305
+ root = Puppet::Type::File.new(:path => "//server/foo")
306
+ @catalog.add_resource file
307
+ @catalog.add_resource dir
308
+ @catalog.add_resource root
309
+ reqs = file.autorequire
310
+ reqs.length.must == 1
311
+ reqs[0].source.must == dir
312
+ reqs[0].target.must == file
313
+ end
368
314
 
369
- it "should remove trailing slashes" do
370
- file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/")
371
- file[:path].should == "//server/foo/bar/baz"
372
- end
315
+ it "should not autorequire anything when there is no nearest ancestor directory" do
316
+ file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/qux")
317
+ @catalog.add_resource file
318
+ file.autorequire.should be_empty
319
+ end
373
320
 
374
- it "should remove double slashes" do
375
- file = Puppet::Type::File.new(:path => "//server/foo/bar//baz")
376
- file[:path].should == "//server/foo/bar/baz"
377
- end
321
+ it "should not autorequire its parent dir if its parent dir is itself" do
322
+ file = Puppet::Type::File.new(:path => "//server/foo")
323
+ @catalog.add_resource file
324
+ puts file.autorequire
325
+ file.autorequire.should be_empty
326
+ end
378
327
 
379
- it "should remove trailing double slashes" do
380
- file = Puppet::Type::File.new(:path => "//server/foo/bar/baz//")
381
- file[:path].should == "//server/foo/bar/baz"
382
- end
328
+ it "should remove trailing slashes" do
329
+ file = Puppet::Type::File.new(:path => "//server/foo/bar/baz/")
330
+ file[:path].should == "//server/foo/bar/baz"
331
+ end
383
332
 
384
- it "should remove a trailing slash from a sharename" do
385
- file = Puppet::Type::File.new(:path => "//server/foo/")
386
- file[:path].should == "//server/foo"
387
- end
333
+ it "should remove double slashes" do
334
+ file = Puppet::Type::File.new(:path => "//server/foo/bar//baz")
335
+ file[:path].should == "//server/foo/bar/baz"
336
+ end
388
337
 
389
- it "should not modify a sharename" do
390
- file = Puppet::Type::File.new(:path => "//server/foo")
391
- file[:path].should == "//server/foo"
392
- end
338
+ it "should remove trailing double slashes" do
339
+ file = Puppet::Type::File.new(:path => "//server/foo/bar/baz//")
340
+ file[:path].should == "//server/foo/bar/baz"
393
341
  end
394
342
 
395
- describe "on POSIX systems" do
396
- before do
397
- Puppet.features.stubs(:posix?).returns(true)
398
- Puppet.features.stubs(:microsoft_windows?).returns(false)
399
- end
343
+ it "should remove a trailing slash from a sharename" do
344
+ file = Puppet::Type::File.new(:path => "//server/foo/")
345
+ file[:path].should == "//server/foo"
346
+ end
400
347
 
401
- it "should refuse to work" do
402
- lambda { Puppet::Type::File.new(:path => "X:/foo/bar") }.should raise_error(Puppet::Error)
403
- end
348
+ it "should not modify a sharename" do
349
+ file = Puppet::Type::File.new(:path => "//server/foo")
350
+ file[:path].should == "//server/foo"
404
351
  end
405
352
  end
406
353
 
@@ -1238,4 +1185,10 @@ describe Puppet::Type.type(:file) do
1238
1185
  @file[:checksum].should be :md5lite
1239
1186
  end
1240
1187
  end
1188
+
1189
+ describe ".instances" do
1190
+ it 'should return an empty array' do
1191
+ Puppet::Type::File.instances.should == []
1192
+ end
1193
+ end
1241
1194
  end