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
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env rspec
2
2
  require 'spec_helper'
3
3
 
4
- describe Puppet::Type.type(:group) do
4
+ describe Puppet::Type.type(:group), :fails_on_windows => true do
5
5
  before do
6
6
  ENV["PATH"] += File::PATH_SEPARATOR + "/usr/sbin" unless ENV["PATH"].split(File::PATH_SEPARATOR).include?("/usr/sbin")
7
7
  @class = Puppet::Type.type(:group)
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env rspec
2
2
  require 'spec_helper'
3
3
 
4
- describe Puppet::Type.type(:mount) do
4
+ describe Puppet::Type.type(:mount), :fails_on_windows => true do
5
5
  it "should have a :refreshable feature that requires the :remount method" do
6
6
  Puppet::Type.type(:mount).provider_feature(:refreshable).methods.should == [:remount]
7
7
  end
@@ -16,7 +16,7 @@ describe Puppet::Type.type(:mount) do
16
16
  end
17
17
  end
18
18
 
19
- describe Puppet::Type.type(:mount), "when validating attributes" do
19
+ describe Puppet::Type.type(:mount), "when validating attributes", :fails_on_windows => true do
20
20
  [:name, :remounts, :provider].each do |param|
21
21
  it "should have a #{param} parameter" do
22
22
  Puppet::Type.type(:mount).attrtype(param).should == :param
@@ -30,7 +30,7 @@ describe Puppet::Type.type(:mount), "when validating attributes" do
30
30
  end
31
31
  end
32
32
 
33
- describe Puppet::Type.type(:mount)::Ensure, "when validating values" do
33
+ describe Puppet::Type.type(:mount)::Ensure, "when validating values", :fails_on_windows => true do
34
34
  before do
35
35
  @provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil
36
36
  Puppet::Type.type(:mount).defaultprovider.expects(:new).returns(@provider)
@@ -62,7 +62,7 @@ describe Puppet::Type.type(:mount)::Ensure, "when validating values" do
62
62
  end
63
63
  end
64
64
 
65
- describe Puppet::Type.type(:mount)::Ensure do
65
+ describe Puppet::Type.type(:mount)::Ensure, :fails_on_windows => true do
66
66
  before :each do
67
67
  provider_properties = {}
68
68
  @provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock, :property_hash => provider_properties
@@ -279,7 +279,7 @@ describe Puppet::Type.type(:mount)::Ensure do
279
279
  end
280
280
  end
281
281
 
282
- describe Puppet::Type.type(:mount), "when modifying an existing mount entry" do
282
+ describe Puppet::Type.type(:mount), "when modifying an existing mount entry", :fails_on_windows => true do
283
283
  before do
284
284
  @provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock, :remount => nil
285
285
  Puppet::Type.type(:mount).defaultprovider.stubs(:new).returns(@provider)
@@ -4,9 +4,11 @@ require 'spec_helper'
4
4
  require 'puppet/type'
5
5
 
6
6
  describe Puppet::Type.type(:file).attrclass(:noop) do
7
+ include PuppetSpec::Files
8
+
7
9
  before do
8
10
  Puppet.settings.stubs(:use)
9
- @file = Puppet::Type.newfile :path => "/what/ever"
11
+ @file = Puppet::Type.newfile :path => make_absolute("/what/ever")
10
12
  end
11
13
 
12
14
  it "should accept true as a value" do
@@ -27,7 +27,7 @@ describe Puppet::Type.type(:package) do
27
27
  end
28
28
 
29
29
  it "should default to being installed" do
30
- pkg = Puppet::Type.type(:package).new(:name => "yay")
30
+ pkg = Puppet::Type.type(:package).new(:name => "yay", :provider => :apt)
31
31
  pkg.should(:ensure).should == :present
32
32
  end
33
33
 
@@ -45,7 +45,12 @@ describe Puppet::Type.type(:package) do
45
45
 
46
46
  describe "when validating attribute values" do
47
47
  before do
48
- @provider = stub 'provider', :class => Puppet::Type.type(:package).defaultprovider, :clear => nil
48
+ @provider = stub(
49
+ 'provider',
50
+ :class => Puppet::Type.type(:package).defaultprovider,
51
+ :clear => nil,
52
+ :validate_source => nil
53
+ )
49
54
  Puppet::Type.type(:package).defaultprovider.expects(:new).returns(@provider)
50
55
  end
51
56
 
@@ -105,7 +110,14 @@ describe Puppet::Type.type(:package) do
105
110
 
106
111
  describe Puppet::Type.type(:package) do
107
112
  before :each do
108
- @provider = stub 'provider', :class => Puppet::Type.type(:package).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock
113
+ @provider = stub(
114
+ 'provider',
115
+ :class => Puppet::Type.type(:package).defaultprovider,
116
+ :clear => nil,
117
+ :satisfies? => true,
118
+ :name => :mock,
119
+ :validate_source => nil
120
+ )
109
121
  Puppet::Type.type(:package).defaultprovider.stubs(:new).returns(@provider)
110
122
  Puppet::Type.type(:package).defaultprovider.stubs(:instances).returns([])
111
123
  @package = Puppet::Type.type(:package).new(:name => "yay")
@@ -51,7 +51,7 @@ describe resources do
51
51
  @resources.generate.collect { |r| r.ref }.should_not include(@host1.ref)
52
52
  end
53
53
 
54
- it "should not include the skipped users", :'fails_on_ruby_1.9.2' => true do
54
+ it "should not include the skipped users", :'fails_on_ruby_1.9.2' => true, :fails_on_windows => true do
55
55
  res = Puppet::Type.type(:resources).new :name => :user, :purge => true
56
56
  res.catalog = Puppet::Resource::Catalog.new
57
57
 
@@ -72,7 +72,7 @@ describe resources do
72
72
  end
73
73
  end
74
74
 
75
- describe "when the instance's do not have an ensure property" do
75
+ describe "when the instance's do not have an ensure property", :fails_on_windows => true do
76
76
  it "should not be included in the generated resources" do
77
77
  @no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo')
78
78
  Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource]
@@ -57,6 +57,21 @@ describe Puppet::Type.type(:service), "when validating attribute values" do
57
57
  Puppet::Type.type(:service).new(:name => "yay", :enable => :false)
58
58
  end
59
59
 
60
+ it "should support :manual as a value to :enable on Windows" do
61
+ Puppet.features.stubs(:microsoft_windows?).returns true
62
+
63
+ Puppet::Type.type(:service).new(:name => "yay", :enable => :manual)
64
+ end
65
+
66
+ it "should not support :manual as a value to :enable when not on Windows" do
67
+ Puppet.features.stubs(:microsoft_windows?).returns false
68
+
69
+ expect { Puppet::Type.type(:service).new(:name => "yay", :enable => :manual) }.to raise_error(
70
+ Puppet::Error,
71
+ /Setting enable to manual is only supported on Microsoft Windows\./
72
+ )
73
+ end
74
+
60
75
  it "should support :true as a value to :hasstatus" do
61
76
  Puppet::Type.type(:service).new(:name => "yay", :hasstatus => :true)
62
77
  end
@@ -91,17 +106,17 @@ describe Puppet::Type.type(:service), "when validating attribute values" do
91
106
  svc.should(:enable).should be_nil
92
107
  end
93
108
 
94
- it "should split paths on ':'" do
109
+ it "should split paths on '#{File::PATH_SEPARATOR}'" do
95
110
  FileTest.stubs(:exist?).returns(true)
96
111
  FileTest.stubs(:directory?).returns(true)
97
- svc = Puppet::Type.type(:service).new(:name => "yay", :path => "/one/two:/three/four")
112
+ svc = Puppet::Type.type(:service).new(:name => "yay", :path => "/one/two#{File::PATH_SEPARATOR}/three/four")
98
113
  svc[:path].should == %w{/one/two /three/four}
99
114
  end
100
115
 
101
- it "should accept arrays of paths joined by ':'" do
116
+ it "should accept arrays of paths joined by '#{File::PATH_SEPARATOR}'" do
102
117
  FileTest.stubs(:exist?).returns(true)
103
118
  FileTest.stubs(:directory?).returns(true)
104
- svc = Puppet::Type.type(:service).new(:name => "yay", :path => ["/one:/two", "/three:/four"])
119
+ svc = Puppet::Type.type(:service).new(:name => "yay", :path => ["/one#{File::PATH_SEPARATOR}/two", "/three#{File::PATH_SEPARATOR}/four"])
105
120
  svc[:path].should == %w{/one /two /three /four}
106
121
  end
107
122
  end
@@ -3,7 +3,9 @@ require 'spec_helper'
3
3
 
4
4
  ssh_authorized_key = Puppet::Type.type(:ssh_authorized_key)
5
5
 
6
- describe ssh_authorized_key do
6
+ describe ssh_authorized_key, :unless => Puppet.features.microsoft_windows? do
7
+ include PuppetSpec::Files
8
+
7
9
  before do
8
10
  @class = Puppet::Type.type(:ssh_authorized_key)
9
11
 
@@ -11,7 +13,7 @@ describe ssh_authorized_key do
11
13
  @class.stubs(:defaultprovider).returns(@provider_class)
12
14
  @class.stubs(:provider).returns(@provider_class)
13
15
 
14
- @provider = stub 'provider', :class => @provider_class, :file_path => "/tmp/whatever", :clear => nil
16
+ @provider = stub 'provider', :class => @provider_class, :file_path => make_absolute("/tmp/whatever"), :clear => nil
15
17
  @provider_class.stubs(:new).returns(@provider)
16
18
  @catalog = Puppet::Resource::Catalog.new
17
19
  end
@@ -134,6 +136,10 @@ describe ssh_authorized_key do
134
136
  proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'command="command"')}.should_not raise_error
135
137
  end
136
138
 
139
+ it "should support key-value pairs where value consist of multiple items" do
140
+ proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'from="*.domain1,host1.domain2"')}.should_not raise_error
141
+ end
142
+
137
143
  it "should support environments as options" do
138
144
  proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'environment="NAME=value"')}.should_not raise_error
139
145
  end
@@ -142,7 +148,7 @@ describe ssh_authorized_key do
142
148
  proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ['cert-authority','environment="NAME=value"'])}.should_not raise_error
143
149
  end
144
150
 
145
- it "should not support a comma separated lists" do
151
+ it "should not support a comma separated list" do
146
152
  proc { @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => 'cert-authority,no-port-forwarding')}.should raise_error(Puppet::Error, /must be provided as an array/)
147
153
  end
148
154
 
@@ -155,7 +161,7 @@ describe ssh_authorized_key do
155
161
  resource.property(:options).is_to_s(["a","b","c"]).should == "a,b,c"
156
162
  end
157
163
 
158
- it "property should return well formed string of arrays from is_to_s" do
164
+ it "property should return well formed string of arrays from should_to_s" do
159
165
  resource = @class.new(:name => "whev", :type => :rsa, :user => "nobody", :options => ["a","b","c"])
160
166
  resource.property(:options).should_to_s(["a","b","c"]).should == "a,b,c"
161
167
  end
@@ -5,8 +5,10 @@ require 'puppet/file_bucket/dipper'
5
5
  tidy = Puppet::Type.type(:tidy)
6
6
 
7
7
  describe tidy do
8
+ include PuppetSpec::Files
9
+
8
10
  before do
9
- @basepath = Puppet.features.posix? ? "/what/ever" : "C:/tmp"
11
+ @basepath = make_absolute("/what/ever")
10
12
  Puppet.settings.stubs(:use)
11
13
 
12
14
  # for an unknown reason some of these specs fails when run individually
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
 
4
4
  user = Puppet::Type.type(:user)
5
5
 
6
- describe user do
6
+ describe user, :fails_on_windows => true do
7
7
  before do
8
8
  ENV["PATH"] += File::PATH_SEPARATOR + "/usr/sbin" unless ENV["PATH"].split(File::PATH_SEPARATOR).include?("/usr/sbin")
9
9
  @provider = stub 'provider'
@@ -1,10 +1,8 @@
1
1
  #!/usr/bin/env rspec
2
2
  require 'spec_helper'
3
3
 
4
- describe Puppet::Type do
5
- it "should include the Cacher module" do
6
- Puppet::Type.ancestors.should be_include(Puppet::Util::Cacher)
7
- end
4
+ describe Puppet::Type, :fails_on_windows => true do
5
+ include PuppetSpec::Files
8
6
 
9
7
  it "should consider a parameter to be valid if it is a valid parameter" do
10
8
  Puppet::Type.type(:mount).should be_valid_parameter(:path)
@@ -18,18 +16,6 @@ describe Puppet::Type do
18
16
  Puppet::Type.type(:mount).should be_valid_parameter(:noop)
19
17
  end
20
18
 
21
- it "should use its catalog as its expirer" do
22
- catalog = Puppet::Resource::Catalog.new
23
- resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
24
- resource.catalog = catalog
25
- resource.expirer.should equal(catalog)
26
- end
27
-
28
- it "should do nothing when asked to expire when it has no catalog" do
29
- resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
30
- lambda { resource.expire }.should_not raise_error
31
- end
32
-
33
19
  it "should be able to retrieve a property by name" do
34
20
  resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
35
21
  resource.property(:fstype).must be_instance_of(Puppet::Type.type(:mount).attrclass(:fstype))
@@ -309,7 +295,8 @@ describe Puppet::Type do
309
295
  end
310
296
 
311
297
  it "should use the Resource Type's namevar to determine how to find the name in the hash" do
312
- Puppet::Type.type(:file).new(:path => "/yay").title.should == "/yay"
298
+ yay = make_absolute('/yay')
299
+ Puppet::Type.type(:file).new(:path => yay).title.should == yay
313
300
  end
314
301
 
315
302
  [:catalog].each do |param|
@@ -373,11 +360,11 @@ describe Puppet::Type do
373
360
  end
374
361
 
375
362
  # This one is really hard to test :/
376
- it "should each default immediately if no value is provided" do
363
+ it "should set each default immediately if no value is provided" do
377
364
  defaults = []
378
- Puppet::Type.type(:package).any_instance.stubs(:set_default).with { |value| defaults << value; true }
365
+ Puppet::Type.type(:service).any_instance.stubs(:set_default).with { |value| defaults << value; true }
379
366
 
380
- Puppet::Type.type(:package).new :name => "whatever"
367
+ Puppet::Type.type(:service).new :name => "whatever"
381
368
 
382
369
  defaults[0].should == :provider
383
370
  end
@@ -387,7 +374,7 @@ describe Puppet::Type do
387
374
  end
388
375
 
389
376
  it "should delete the name via the namevar from the originally provided parameters" do
390
- Puppet::Type.type(:file).new(:name => "/foo").original_parameters[:path].should be_nil
377
+ Puppet::Type.type(:file).new(:name => make_absolute('/foo')).original_parameters[:path].should be_nil
391
378
  end
392
379
  end
393
380
 
@@ -471,7 +458,7 @@ describe Puppet::Type do
471
458
  end
472
459
 
473
460
  it "should provide a value for 'ensure' even if no desired value is provided" do
474
- @resource = Puppet::Type.type(:file).new(:path => "/my/file/that/can't/exist")
461
+ @resource = Puppet::Type.type(:file).new(:path => make_absolute("/my/file/that/can't/exist"))
475
462
  end
476
463
 
477
464
  it "should not call retrieve on non-ensure properties if the resource is absent and should consider the property absent" do
@@ -513,8 +500,8 @@ describe Puppet::Type do
513
500
  before do
514
501
  @catalog = Puppet::Resource::Catalog.new
515
502
  @container = Puppet::Type.type(:component).new(:name => "container")
516
- @one = Puppet::Type.type(:file).new(:path => "/file/one")
517
- @two = Puppet::Type.type(:file).new(:path => "/file/two")
503
+ @one = Puppet::Type.type(:file).new(:path => make_absolute("/file/one"))
504
+ @two = Puppet::Type.type(:file).new(:path => make_absolute("/file/two"))
518
505
 
519
506
  @catalog.add_resource @container
520
507
  @catalog.add_resource @one
@@ -541,7 +528,9 @@ describe Puppet::Type do
541
528
  end
542
529
  end
543
530
 
544
- describe Puppet::Type::RelationshipMetaparam do
531
+ describe Puppet::Type::RelationshipMetaparam, :fails_on_windows => true do
532
+ include PuppetSpec::Files
533
+
545
534
  it "should be a subclass of Puppet::Parameter" do
546
535
  Puppet::Type::RelationshipMetaparam.superclass.should equal(Puppet::Parameter)
547
536
  end
@@ -550,14 +539,15 @@ describe Puppet::Type::RelationshipMetaparam do
550
539
  Puppet::Type::RelationshipMetaparam.should respond_to(:subclasses)
551
540
  end
552
541
 
553
- describe "when munging relationships" do
542
+ describe "when munging relationships", :'fails_on_windows' => true do
554
543
  before do
555
- @resource = Puppet::Type.type(:mount).new :name => "/foo"
544
+ @path = make_absolute('/foo')
545
+ @resource = Puppet::Type.type(:mount).new :name => @path
556
546
  @metaparam = Puppet::Type.metaparamclass(:require).new :resource => @resource
557
547
  end
558
548
 
559
549
  it "should accept Puppet::Resource instances" do
560
- ref = Puppet::Resource.new(:file, "/foo")
550
+ ref = Puppet::Resource.new(:file, @path)
561
551
  @metaparam.munge(ref)[0].should equal(ref)
562
552
  end
563
553
 
@@ -585,18 +575,22 @@ describe Puppet::Type::RelationshipMetaparam do
585
575
  end
586
576
  end
587
577
 
588
- describe Puppet::Type.metaparamclass(:check) do
578
+ describe Puppet::Type.metaparamclass(:check), :fails_on_windows => true do
579
+ include PuppetSpec::Files
580
+
589
581
  it "should warn and create an instance of ':audit'" do
590
- file = Puppet::Type.type(:file).new :path => "/foo"
582
+ file = Puppet::Type.type(:file).new :path => make_absolute('/foo')
591
583
  file.expects(:warning)
592
584
  file[:check] = :mode
593
585
  file[:audit].should == [:mode]
594
586
  end
595
587
  end
596
588
 
597
- describe Puppet::Type.metaparamclass(:audit) do
589
+ describe Puppet::Type.metaparamclass(:audit), :fails_on_windows => true do
590
+ include PuppetSpec::Files
591
+
598
592
  before do
599
- @resource = Puppet::Type.type(:file).new :path => "/foo"
593
+ @resource = Puppet::Type.type(:file).new :path => make_absolute('/foo')
600
594
  end
601
595
 
602
596
  it "should default to being nil" do
@@ -642,8 +636,9 @@ describe Puppet::Type.metaparamclass(:audit) do
642
636
  Puppet::Type.type(:file).stubs(:title_patterns).returns(
643
637
  [ [ /(.*)/, [ [:path, lambda{|x| x} ] ] ] ]
644
638
  )
645
- res = Puppet::Type.type(:file).new( :title => '/my/file', :path => '/my/file', :owner => 'root', :content => 'hello' )
646
- res.uniqueness_key.should == [ nil, 'root', '/my/file']
639
+ myfile = make_absolute('/my/file')
640
+ res = Puppet::Type.type(:file).new( :title => myfile, :path => myfile, :owner => 'root', :content => 'hello' )
641
+ res.uniqueness_key.should == [ nil, 'root', myfile]
647
642
  end
648
643
  end
649
644
  end
@@ -0,0 +1,202 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'spec_helper'
4
+
5
+ require 'puppet/util/adsi'
6
+
7
+ describe Puppet::Util::ADSI do
8
+ let(:connection) { stub 'connection' }
9
+
10
+ before(:each) do
11
+ Puppet::Util::ADSI.instance_variable_set(:@computer_name, 'testcomputername')
12
+ Puppet::Util::ADSI.stubs(:connect).returns connection
13
+ end
14
+
15
+ it "should generate the correct URI for a resource" do
16
+ Puppet::Util::ADSI.uri('test', 'user').should == "WinNT://testcomputername/test,user"
17
+ end
18
+
19
+ it "should be able to get the name of the computer" do
20
+ Puppet::Util::ADSI.computer_name.should == 'testcomputername'
21
+ end
22
+
23
+ it "should be able to provide the correct WinNT base URI for the computer" do
24
+ Puppet::Util::ADSI.computer_uri.should == "WinNT://testcomputername"
25
+ end
26
+
27
+ describe Puppet::Util::ADSI::User do
28
+ let(:username) { 'testuser' }
29
+
30
+ it "should generate the correct URI" do
31
+ Puppet::Util::ADSI::User.uri(username).should == "WinNT://testcomputername/#{username},user"
32
+ end
33
+
34
+ it "should be able to create a user" do
35
+ adsi_user = stub('adsi')
36
+
37
+ connection.expects(:Create).with('user', username).returns(adsi_user)
38
+
39
+ user = Puppet::Util::ADSI::User.create(username)
40
+
41
+ user.should be_a(Puppet::Util::ADSI::User)
42
+ user.native_user.should == adsi_user
43
+ end
44
+
45
+ it "should be able to check the existence of a user" do
46
+ Puppet::Util::ADSI.expects(:connect).with("WinNT://testcomputername/#{username},user").returns connection
47
+ Puppet::Util::ADSI::User.exists?(username).should be_true
48
+ end
49
+
50
+ it "should be able to delete a user" do
51
+ connection.expects(:Delete).with('user', username)
52
+
53
+ Puppet::Util::ADSI::User.delete(username)
54
+ end
55
+
56
+ describe "an instance" do
57
+ let(:adsi_user) { stub 'user' }
58
+ let(:user) { Puppet::Util::ADSI::User.new(username, adsi_user) }
59
+
60
+ it "should provide its groups as a list of names" do
61
+ names = ["group1", "group2"]
62
+
63
+ groups = names.map { |name| mock('group', :Name => name) }
64
+
65
+ adsi_user.expects(:Groups).returns(groups)
66
+
67
+ user.groups.should =~ names
68
+ end
69
+
70
+ it "should be able to test whether a given password is correct" do
71
+ Puppet::Util::ADSI::User.expects(:logon).with(username, 'pwdwrong').returns(false)
72
+ Puppet::Util::ADSI::User.expects(:logon).with(username, 'pwdright').returns(true)
73
+
74
+ user.password_is?('pwdwrong').should be_false
75
+ user.password_is?('pwdright').should be_true
76
+ end
77
+
78
+ it "should be able to set a password" do
79
+ adsi_user.expects(:SetPassword).with('pwd')
80
+ adsi_user.expects(:SetInfo).at_least_once
81
+
82
+ flagname = "UserFlags"
83
+ fADS_UF_DONT_EXPIRE_PASSWD = 0x10000
84
+
85
+ adsi_user.expects(:Get).with(flagname).returns(0)
86
+ adsi_user.expects(:Put).with(flagname, fADS_UF_DONT_EXPIRE_PASSWD)
87
+
88
+ user.password = 'pwd'
89
+ end
90
+
91
+ it "should generate the correct URI" do
92
+ user.uri.should == "WinNT://testcomputername/#{username},user"
93
+ end
94
+
95
+ describe "when given a set of groups to which to add the user" do
96
+ let(:groups_to_set) { 'group1,group2' }
97
+
98
+ before(:each) do
99
+ user.expects(:groups).returns ['group2', 'group3']
100
+ end
101
+
102
+ describe "if membership is specified as inclusive" do
103
+ it "should add the user to those groups, and remove it from groups not in the list" do
104
+ group1 = stub 'group1'
105
+ group1.expects(:Add).with("WinNT://testcomputername/#{username},user")
106
+
107
+ group3 = stub 'group1'
108
+ group3.expects(:Remove).with("WinNT://testcomputername/#{username},user")
109
+
110
+ Puppet::Util::ADSI.expects(:connect).with('WinNT://testcomputername/group1,group').returns group1
111
+ Puppet::Util::ADSI.expects(:connect).with('WinNT://testcomputername/group3,group').returns group3
112
+
113
+ user.set_groups(groups_to_set, false)
114
+ end
115
+ end
116
+
117
+ describe "if membership is specified as minimum" do
118
+ it "should add the user to the specified groups without affecting its other memberships" do
119
+ group1 = stub 'group1'
120
+ group1.expects(:Add).with("WinNT://testcomputername/#{username},user")
121
+
122
+ Puppet::Util::ADSI.expects(:connect).with('WinNT://testcomputername/group1,group').returns group1
123
+
124
+ user.set_groups(groups_to_set, true)
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
130
+
131
+ describe Puppet::Util::ADSI::Group do
132
+ let(:groupname) { 'testgroup' }
133
+
134
+ describe "an instance" do
135
+ let(:adsi_group) { stub 'group' }
136
+ let(:group) { Puppet::Util::ADSI::Group.new(groupname, adsi_group) }
137
+
138
+ it "should be able to add a member" do
139
+ adsi_group.expects(:Add).with("WinNT://testcomputername/someone,user")
140
+
141
+ group.add_member('someone')
142
+ end
143
+
144
+ it "should be able to remove a member" do
145
+ adsi_group.expects(:Remove).with("WinNT://testcomputername/someone,user")
146
+
147
+ group.remove_member('someone')
148
+ end
149
+
150
+ it "should provide its groups as a list of names" do
151
+ names = ['user1', 'user2']
152
+
153
+ users = names.map { |name| mock('user', :Name => name) }
154
+
155
+ adsi_group.expects(:Members).returns(users)
156
+
157
+ group.members.should =~ names
158
+ end
159
+
160
+ it "should be able to add a list of users to a group" do
161
+ names = ['user1', 'user2']
162
+ adsi_group.expects(:Members).returns names.map{|n| stub(:Name => n)}
163
+
164
+ adsi_group.expects(:Remove).with('WinNT://testcomputername/user1,user')
165
+ adsi_group.expects(:Add).with('WinNT://testcomputername/user3,user')
166
+
167
+ group.set_members(['user2', 'user3'])
168
+ end
169
+
170
+ it "should generate the correct URI" do
171
+ group.uri.should == "WinNT://testcomputername/#{groupname},group"
172
+ end
173
+ end
174
+
175
+ it "should generate the correct URI" do
176
+ Puppet::Util::ADSI::Group.uri("people").should == "WinNT://testcomputername/people,group"
177
+ end
178
+
179
+ it "should be able to create a group" do
180
+ adsi_group = stub("adsi")
181
+
182
+ connection.expects(:Create).with('group', groupname).returns(adsi_group)
183
+
184
+ group = Puppet::Util::ADSI::Group.create(groupname)
185
+
186
+ group.should be_a(Puppet::Util::ADSI::Group)
187
+ group.native_group.should == adsi_group
188
+ end
189
+
190
+ it "should be able to confirm the existence of a group" do
191
+ Puppet::Util::ADSI.expects(:connect).with("WinNT://testcomputername/#{groupname},group").returns connection
192
+
193
+ Puppet::Util::ADSI::Group.exists?(groupname).should be_true
194
+ end
195
+
196
+ it "should be able to delete a group" do
197
+ connection.expects(:Delete).with('group', groupname)
198
+
199
+ Puppet::Util::ADSI::Group.delete(groupname)
200
+ end
201
+ end
202
+ end
@@ -4,43 +4,47 @@ require 'spec_helper'
4
4
  require 'puppet/util/autoload'
5
5
 
6
6
  describe Puppet::Util::Autoload do
7
+ include PuppetSpec::Files
8
+
7
9
  before do
8
10
  @autoload = Puppet::Util::Autoload.new("foo", "tmp")
9
11
 
10
12
  @autoload.stubs(:eachdir).yields "/my/dir"
11
13
  end
12
14
 
13
- it "should use the Cacher module" do
14
- Puppet::Util::Autoload.ancestors.should be_include(Puppet::Util::Cacher)
15
- end
16
-
17
15
  describe "when building the search path" do
16
+ before :each do
17
+ @dira = make_absolute('/a')
18
+ @dirb = make_absolute('/b')
19
+ @dirc = make_absolute('/c')
20
+ end
21
+
18
22
  it "should collect all of the plugins and lib directories that exist in the current environment's module path" do
19
23
  Puppet.settings.expects(:value).with(:environment).returns "foo"
20
- Puppet.settings.expects(:value).with(:modulepath, :foo).returns "/a:/b:/c"
21
- Dir.expects(:entries).with("/a").returns %w{one two}
22
- Dir.expects(:entries).with("/b").returns %w{one two}
24
+ Puppet.settings.expects(:value).with(:modulepath, :foo).returns "#{@dira}#{File::PATH_SEPARATOR}#{@dirb}#{File::PATH_SEPARATOR}#{@dirc}"
25
+ Dir.expects(:entries).with(@dira).returns %w{one two}
26
+ Dir.expects(:entries).with(@dirb).returns %w{one two}
23
27
 
24
28
  FileTest.stubs(:directory?).returns false
25
- FileTest.expects(:directory?).with("/a").returns true
26
- FileTest.expects(:directory?).with("/b").returns true
27
- %w{/a/one/plugins /a/two/lib /b/one/plugins /b/two/lib}.each do |d|
29
+ FileTest.expects(:directory?).with(@dira).returns true
30
+ FileTest.expects(:directory?).with(@dirb).returns true
31
+ ["#{@dira}/one/plugins", "#{@dira}/two/lib", "#{@dirb}/one/plugins", "#{@dirb}/two/lib"].each do |d|
28
32
  FileTest.expects(:directory?).with(d).returns true
29
33
  end
30
34
 
31
- @autoload.module_directories.should == %w{/a/one/plugins /a/two/lib /b/one/plugins /b/two/lib}
35
+ @autoload.module_directories.should == ["#{@dira}/one/plugins", "#{@dira}/two/lib", "#{@dirb}/one/plugins", "#{@dirb}/two/lib"]
32
36
  end
33
37
 
34
38
  it "should not look for lib directories in directories starting with '.'" do
35
39
  Puppet.settings.expects(:value).with(:environment).returns "foo"
36
- Puppet.settings.expects(:value).with(:modulepath, :foo).returns "/a"
37
- Dir.expects(:entries).with("/a").returns %w{. ..}
38
-
39
- FileTest.expects(:directory?).with("/a").returns true
40
- FileTest.expects(:directory?).with("/a/./lib").never
41
- FileTest.expects(:directory?).with("/a/./plugins").never
42
- FileTest.expects(:directory?).with("/a/../lib").never
43
- FileTest.expects(:directory?).with("/a/../plugins").never
40
+ Puppet.settings.expects(:value).with(:modulepath, :foo).returns @dira
41
+ Dir.expects(:entries).with(@dira).returns %w{. ..}
42
+
43
+ FileTest.expects(:directory?).with(@dira).returns true
44
+ FileTest.expects(:directory?).with("#{@dira}/./lib").never
45
+ FileTest.expects(:directory?).with("#{@dira}/./plugins").never
46
+ FileTest.expects(:directory?).with("#{@dira}/../lib").never
47
+ FileTest.expects(:directory?).with("#{@dira}/../plugins").never
44
48
 
45
49
  @autoload.module_directories
46
50
  end