chef 11.18.12-x86-mingw32 → 12.0.0.alpha.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (307) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +10 -0
  3. data/README.md +1 -1
  4. data/distro/common/html/_sources/index.txt +5 -2
  5. data/distro/common/html/_sources/knife_serve.txt +19 -0
  6. data/distro/common/html/_sources/knife_ssl_check.txt +2 -2
  7. data/distro/common/html/_sources/knife_ssl_fetch.txt +2 -2
  8. data/distro/common/html/_static/basic.css +1 -1
  9. data/distro/common/html/_static/doctools.js +1 -1
  10. data/distro/common/html/_static/searchtools.js +1 -1
  11. data/distro/common/html/_static/websupport.js +1 -1
  12. data/distro/common/html/ctl_chef_client.html +19 -9
  13. data/distro/common/html/ctl_chef_server.html +7 -1
  14. data/distro/common/html/ctl_chef_shell.html +3 -4
  15. data/distro/common/html/ctl_chef_solo.html +12 -7
  16. data/distro/common/html/index.html +19 -12
  17. data/distro/common/html/knife.html +1 -2
  18. data/distro/common/html/knife_bootstrap.html +16 -5
  19. data/distro/common/html/knife_client.html +8 -5
  20. data/distro/common/html/knife_common_options.html +11 -12
  21. data/distro/common/html/knife_configure.html +2 -3
  22. data/distro/common/html/knife_cookbook.html +16 -17
  23. data/distro/common/html/knife_cookbook_site.html +19 -18
  24. data/distro/common/html/knife_data_bag.html +6 -7
  25. data/distro/common/html/knife_delete.html +2 -3
  26. data/distro/common/html/knife_deps.html +2 -3
  27. data/distro/common/html/knife_diff.html +3 -4
  28. data/distro/common/html/knife_download.html +6 -7
  29. data/distro/common/html/knife_edit.html +0 -1
  30. data/distro/common/html/knife_environment.html +3 -4
  31. data/distro/common/html/knife_exec.html +0 -1
  32. data/distro/common/html/knife_index_rebuild.html +0 -1
  33. data/distro/common/html/knife_list.html +5 -6
  34. data/distro/common/html/knife_node.html +13 -6
  35. data/distro/common/html/knife_raw.html +0 -1
  36. data/distro/common/html/knife_recipe_list.html +0 -1
  37. data/distro/common/html/knife_role.html +1 -2
  38. data/distro/common/html/knife_search.html +2 -3
  39. data/distro/common/html/knife_serve.html +79 -0
  40. data/distro/common/html/knife_show.html +1 -2
  41. data/distro/common/html/knife_ssh.html +2 -3
  42. data/distro/common/html/knife_ssl_check.html +12 -9
  43. data/distro/common/html/knife_ssl_fetch.html +9 -10
  44. data/distro/common/html/knife_status.html +2 -3
  45. data/distro/common/html/knife_tag.html +0 -1
  46. data/distro/common/html/knife_upload.html +3 -4
  47. data/distro/common/html/knife_user.html +2 -3
  48. data/distro/common/html/knife_using.html +0 -1
  49. data/distro/common/html/knife_xargs.html +3 -4
  50. data/distro/common/html/search.html +0 -1
  51. data/distro/common/html/searchindex.js +1 -1
  52. data/lib/chef/api_client.rb +1 -1
  53. data/lib/chef/application.rb +24 -67
  54. data/lib/chef/application/client.rb +1 -1
  55. data/lib/chef/application/knife.rb +1 -1
  56. data/lib/chef/chef_fs/chef_fs_data_store.rb +2 -3
  57. data/lib/chef/chef_fs/command_line.rb +2 -3
  58. data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -5
  59. data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -2
  60. data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -2
  61. data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +2 -2
  62. data/lib/chef/chef_fs/file_system/rest_list_dir.rb +2 -3
  63. data/lib/chef/chef_fs/file_system/rest_list_entry.rb +4 -5
  64. data/lib/chef/config.rb +26 -2
  65. data/lib/chef/config_fetcher.rb +1 -1
  66. data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
  67. data/lib/chef/cookbook/metadata.rb +1 -1
  68. data/lib/chef/cookbook/synchronizer.rb +50 -8
  69. data/lib/chef/cookbook_uploader.rb +9 -23
  70. data/lib/chef/cookbook_version.rb +3 -2
  71. data/lib/chef/data_bag.rb +1 -1
  72. data/lib/chef/data_bag_item.rb +1 -1
  73. data/lib/chef/dsl/recipe.rb +1 -14
  74. data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
  75. data/lib/chef/environment.rb +1 -1
  76. data/lib/chef/exceptions.rb +2 -24
  77. data/lib/chef/file_content_management/tempfile.rb +8 -1
  78. data/lib/chef/formatters/base.rb +0 -7
  79. data/lib/chef/http.rb +12 -19
  80. data/lib/chef/http/json_input.rb +12 -1
  81. data/lib/chef/json_compat.rb +45 -64
  82. data/lib/chef/knife.rb +2 -5
  83. data/lib/chef/knife/bootstrap.rb +2 -2
  84. data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
  85. data/lib/chef/knife/bootstrap/centos5-gems.erb +2 -2
  86. data/lib/chef/knife/bootstrap/chef-aix.erb +2 -2
  87. data/lib/chef/knife/bootstrap/chef-full.erb +2 -2
  88. data/lib/chef/knife/bootstrap/fedora13-gems.erb +2 -2
  89. data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
  90. data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +2 -2
  91. data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +2 -2
  92. data/lib/chef/knife/cookbook_site_download.rb +1 -1
  93. data/lib/chef/knife/cookbook_site_install.rb +10 -34
  94. data/lib/chef/knife/cookbook_site_list.rb +1 -1
  95. data/lib/chef/knife/cookbook_site_search.rb +1 -1
  96. data/lib/chef/knife/cookbook_site_share.rb +3 -3
  97. data/lib/chef/knife/cookbook_site_show.rb +3 -3
  98. data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
  99. data/lib/chef/knife/cookbook_upload.rb +1 -1
  100. data/lib/chef/knife/core/subcommand_loader.rb +0 -24
  101. data/lib/chef/knife/core/ui.rb +8 -7
  102. data/lib/chef/knife/deps.rb +2 -3
  103. data/lib/chef/knife/serve.rb +2 -1
  104. data/lib/chef/local_mode.rb +105 -0
  105. data/lib/chef/mixin/file_class.rb +1 -4
  106. data/lib/chef/mixin/shell_out.rb +15 -0
  107. data/lib/chef/mixin/windows_architecture_helper.rb +0 -16
  108. data/lib/chef/node.rb +1 -1
  109. data/lib/chef/platform/query_helpers.rb +1 -5
  110. data/lib/chef/policy_builder/expand_node_object.rb +3 -0
  111. data/lib/chef/provider.rb +2 -0
  112. data/lib/chef/provider/cookbook_file.rb +0 -1
  113. data/lib/chef/provider/deploy.rb +0 -1
  114. data/lib/chef/provider/deploy/revision.rb +1 -1
  115. data/lib/chef/provider/env.rb +10 -25
  116. data/lib/chef/provider/env/windows.rb +23 -10
  117. data/lib/chef/provider/execute.rb +0 -3
  118. data/lib/chef/provider/file.rb +0 -3
  119. data/lib/chef/provider/git.rb +0 -6
  120. data/lib/chef/provider/group/dscl.rb +9 -27
  121. data/lib/chef/provider/group/gpasswd.rb +0 -3
  122. data/lib/chef/provider/group/groupmod.rb +0 -4
  123. data/lib/chef/provider/group/suse.rb +0 -3
  124. data/lib/chef/provider/group/usermod.rb +0 -3
  125. data/lib/chef/provider/link.rb +22 -5
  126. data/lib/chef/provider/log.rb +15 -4
  127. data/lib/chef/provider/mdadm.rb +0 -3
  128. data/lib/chef/provider/mount/mount.rb +0 -2
  129. data/lib/chef/provider/mount/solaris.rb +0 -2
  130. data/lib/chef/provider/package.rb +0 -1
  131. data/lib/chef/provider/package/apt.rb +0 -3
  132. data/lib/chef/provider/package/dpkg.rb +0 -1
  133. data/lib/chef/provider/package/easy_install.rb +0 -4
  134. data/lib/chef/provider/package/freebsd/base.rb +0 -3
  135. data/lib/chef/provider/package/freebsd/pkgng.rb +0 -2
  136. data/lib/chef/provider/package/freebsd/port.rb +0 -2
  137. data/lib/chef/provider/package/ips.rb +0 -3
  138. data/lib/chef/provider/package/paludis.rb +0 -5
  139. data/lib/chef/provider/package/portage.rb +0 -2
  140. data/lib/chef/provider/package/rpm.rb +2 -4
  141. data/lib/chef/provider/package/rubygems.rb +0 -4
  142. data/lib/chef/provider/package/smartos.rb +0 -3
  143. data/lib/chef/provider/package/windows/msi.rb +0 -2
  144. data/lib/chef/provider/package/yum.rb +0 -4
  145. data/lib/chef/provider/package/zypper.rb +0 -3
  146. data/lib/chef/provider/registry_key.rb +0 -2
  147. data/lib/chef/provider/remote_directory.rb +0 -1
  148. data/lib/chef/provider/remote_file.rb +0 -1
  149. data/lib/chef/provider/remote_file/cache_control_data.rb +1 -3
  150. data/lib/chef/provider/remote_file/content.rb +0 -1
  151. data/lib/chef/provider/remote_file/fetcher.rb +0 -2
  152. data/lib/chef/provider/remote_file/ftp.rb +0 -1
  153. data/lib/chef/provider/resource_update.rb +0 -3
  154. data/lib/chef/provider/service/freebsd.rb +0 -3
  155. data/lib/chef/provider/service/init.rb +0 -3
  156. data/lib/chef/provider/service/macosx.rb +0 -1
  157. data/lib/chef/provider/service/redhat.rb +0 -2
  158. data/lib/chef/provider/service/simple.rb +0 -3
  159. data/lib/chef/provider/service/solaris.rb +0 -3
  160. data/lib/chef/provider/service/systemd.rb +15 -14
  161. data/lib/chef/provider/service/windows.rb +0 -3
  162. data/lib/chef/provider/subversion.rb +0 -2
  163. data/lib/chef/provider/template.rb +0 -2
  164. data/lib/chef/provider/template/content.rb +0 -1
  165. data/lib/chef/provider/user/dscl.rb +156 -549
  166. data/lib/chef/provider/user/solaris.rb +0 -1
  167. data/lib/chef/provider/user/useradd.rb +0 -3
  168. data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
  169. data/lib/chef/providers.rb +0 -1
  170. data/lib/chef/resource.rb +1 -4
  171. data/lib/chef/resource/freebsd_package.rb +2 -10
  172. data/lib/chef/resource/lwrp_base.rb +1 -12
  173. data/lib/chef/resource/user.rb +0 -18
  174. data/lib/chef/resource_collection.rb +1 -1
  175. data/lib/chef/resource_reporter.rb +10 -10
  176. data/lib/chef/resources.rb +0 -1
  177. data/lib/chef/role.rb +3 -3
  178. data/lib/chef/run_list.rb +1 -1
  179. data/lib/chef/tasks/chef_repo.rake +131 -264
  180. data/lib/chef/user.rb +1 -1
  181. data/lib/chef/util/path_helper.rb +2 -2
  182. data/lib/chef/version.rb +9 -1
  183. data/lib/chef/win32/api/system.rb +0 -9
  184. data/spec/data/bootstrap/test-hints.erb +1 -1
  185. data/spec/data/bootstrap/test.erb +1 -1
  186. data/spec/functional/dsl/reboot_pending_spec.rb +53 -58
  187. data/spec/functional/knife/cookbook_delete_spec.rb +3 -3
  188. data/spec/functional/knife/exec_spec.rb +1 -1
  189. data/spec/functional/mixin/shell_out_spec.rb +48 -0
  190. data/spec/functional/resource/base.rb +0 -10
  191. data/spec/functional/resource/group_spec.rb +1 -5
  192. data/spec/functional/resource/link_spec.rb +8 -0
  193. data/spec/functional/resource/{user/useradd_spec.rb → user_spec.rb} +1 -1
  194. data/spec/integration/knife/chef_fs_data_store_spec.rb +3 -3
  195. data/spec/integration/knife/chef_repo_path_spec.rb +1 -6
  196. data/spec/integration/knife/chef_repository_file_system_spec.rb +1 -1
  197. data/spec/integration/knife/chefignore_spec.rb +1 -1
  198. data/spec/integration/knife/common_options_spec.rb +50 -3
  199. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +1 -1
  200. data/spec/integration/knife/delete_spec.rb +1 -1
  201. data/spec/integration/knife/deps_spec.rb +1 -1
  202. data/spec/integration/knife/diff_spec.rb +3 -3
  203. data/spec/integration/knife/download_spec.rb +3 -3
  204. data/spec/integration/knife/list_spec.rb +1 -1
  205. data/spec/integration/knife/raw_spec.rb +1 -11
  206. data/spec/integration/knife/redirection_spec.rb +1 -1
  207. data/spec/integration/knife/serve_spec.rb +2 -2
  208. data/spec/integration/knife/show_spec.rb +1 -1
  209. data/spec/integration/knife/upload_spec.rb +9 -9
  210. data/spec/spec_helper.rb +0 -9
  211. data/spec/support/pedant/pedant_config.rb +2 -1
  212. data/spec/support/pedant/run_pedant.rb +2 -1
  213. data/spec/support/platform_helpers.rb +5 -24
  214. data/spec/support/shared/integration/integration_helper.rb +2 -1
  215. data/spec/support/shared/matchers.rb +17 -0
  216. data/spec/tiny_server.rb +1 -2
  217. data/spec/unit/api_client_spec.rb +3 -3
  218. data/spec/unit/application_spec.rb +9 -32
  219. data/spec/unit/config_fetcher_spec.rb +1 -1
  220. data/spec/unit/cookbook/metadata_spec.rb +3 -7
  221. data/spec/unit/cookbook/synchronizer_spec.rb +441 -226
  222. data/spec/unit/cookbook_loader_spec.rb +1 -1
  223. data/spec/unit/cookbook_uploader_spec.rb +160 -0
  224. data/spec/unit/cookbook_version_spec.rb +0 -4
  225. data/spec/unit/data_bag_item_spec.rb +1 -5
  226. data/spec/unit/data_bag_spec.rb +1 -5
  227. data/spec/unit/deprecation_spec.rb +1 -1
  228. data/spec/unit/dsl/recipe_spec.rb +12 -0
  229. data/spec/unit/encrypted_data_bag_item_spec.rb +7 -14
  230. data/spec/unit/environment_spec.rb +3 -7
  231. data/spec/unit/exceptions_spec.rb +0 -6
  232. data/spec/unit/http/json_input_spec.rb +128 -0
  233. data/spec/unit/json_compat_spec.rb +17 -58
  234. data/spec/unit/knife/client_create_spec.rb +3 -3
  235. data/spec/unit/knife/configure_client_spec.rb +6 -5
  236. data/spec/unit/knife/cookbook_delete_spec.rb +1 -1
  237. data/spec/unit/knife/cookbook_download_spec.rb +5 -5
  238. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -0
  239. data/spec/unit/knife/cookbook_metadata_spec.rb +1 -1
  240. data/spec/unit/knife/cookbook_site_download_spec.rb +10 -11
  241. data/spec/unit/knife/cookbook_site_install_spec.rb +116 -161
  242. data/spec/unit/knife/cookbook_site_share_spec.rb +8 -8
  243. data/spec/unit/knife/cookbook_upload_spec.rb +3 -2
  244. data/spec/unit/knife/core/bootstrap_context_spec.rb +3 -3
  245. data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -66
  246. data/spec/unit/knife/data_bag_from_file_spec.rb +2 -1
  247. data/spec/unit/knife/tag_create_spec.rb +3 -3
  248. data/spec/unit/knife/tag_delete_spec.rb +3 -3
  249. data/spec/unit/knife/user_create_spec.rb +1 -1
  250. data/spec/unit/knife_spec.rb +14 -14
  251. data/spec/unit/lwrp_spec.rb +1 -21
  252. data/spec/unit/mixin/shell_out_spec.rb +92 -0
  253. data/spec/unit/node_spec.rb +0 -4
  254. data/spec/unit/platform/query_helpers_spec.rb +0 -23
  255. data/spec/unit/provider/env/windows_spec.rb +34 -70
  256. data/spec/unit/provider/env_spec.rb +11 -76
  257. data/spec/unit/provider/group/dscl_spec.rb +1 -38
  258. data/spec/unit/provider/log_spec.rb +18 -0
  259. data/spec/unit/provider/package/rpm_spec.rb +0 -12
  260. data/spec/unit/provider/remote_file/cache_control_data_spec.rb +1 -1
  261. data/spec/unit/provider/service/systemd_service_spec.rb +44 -27
  262. data/spec/unit/provider/user/dscl_spec.rb +264 -660
  263. data/spec/unit/provider/user/useradd_spec.rb +0 -1
  264. data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +2 -2
  265. data/spec/unit/provider_spec.rb +12 -0
  266. data/spec/unit/recipe_spec.rb +0 -41
  267. data/spec/unit/resource_collection_spec.rb +1 -5
  268. data/spec/unit/resource_reporter_spec.rb +3 -51
  269. data/spec/unit/resource_spec.rb +3 -14
  270. data/spec/unit/rest_spec.rb +1 -4
  271. data/spec/unit/role_spec.rb +0 -10
  272. data/spec/unit/run_list_spec.rb +1 -5
  273. data/spec/unit/user_spec.rb +1 -5
  274. metadata +20 -100
  275. data/lib/chef/mixin/windows_env_helper.rb +0 -56
  276. data/lib/chef/provider/dsc_script.rb +0 -175
  277. data/lib/chef/resource/dsc_script.rb +0 -126
  278. data/lib/chef/streaming_cookbook_uploader.rb +0 -205
  279. data/lib/chef/util/dsc/configuration_generator.rb +0 -115
  280. data/lib/chef/util/dsc/lcm_output_parser.rb +0 -133
  281. data/lib/chef/util/dsc/local_configuration_manager.rb +0 -141
  282. data/lib/chef/util/dsc/resource_info.rb +0 -26
  283. data/lib/chef/util/powershell/cmdlet.rb +0 -136
  284. data/lib/chef/util/powershell/cmdlet_result.rb +0 -46
  285. data/spec/data/mac_users/10.7-8.plist.xml +0 -559
  286. data/spec/data/mac_users/10.7-8.shadow.xml +0 -11
  287. data/spec/data/mac_users/10.7.plist.xml +0 -559
  288. data/spec/data/mac_users/10.7.shadow.xml +0 -11
  289. data/spec/data/mac_users/10.8.plist.xml +0 -559
  290. data/spec/data/mac_users/10.8.shadow.xml +0 -21
  291. data/spec/data/mac_users/10.9.plist.xml +0 -560
  292. data/spec/data/mac_users/10.9.shadow.xml +0 -21
  293. data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +0 -51
  294. data/spec/functional/resource/dsc_script_spec.rb +0 -382
  295. data/spec/functional/resource/env_spec.rb +0 -182
  296. data/spec/functional/resource/user/dscl_spec.rb +0 -199
  297. data/spec/functional/util/powershell/cmdlet_spec.rb +0 -113
  298. data/spec/support/lib/chef/resource/zen_follower.rb +0 -46
  299. data/spec/support/shared/shared_examples.rb +0 -10
  300. data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +0 -63
  301. data/spec/unit/formatters/base_spec.rb +0 -48
  302. data/spec/unit/provider/dsc_script_spec.rb +0 -174
  303. data/spec/unit/resource/dsc_script_spec.rb +0 -98
  304. data/spec/unit/util/dsc/configuration_generator_spec.rb +0 -171
  305. data/spec/unit/util/dsc/lcm_output_parser_spec.rb +0 -169
  306. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +0 -139
  307. data/spec/unit/util/powershell/cmdlet_spec.rb +0 -106
@@ -1,182 +0,0 @@
1
- #
2
- # Author:: Adam Edwards (<adamed@getchef.com>)
3
- # Copyright:: Copyright (c) 2014 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require 'spec_helper'
20
-
21
- describe Chef::Resource::Env, :windows_only do
22
- context 'when running on Windows' do
23
- let(:chef_env_test_lower_case) { 'chefenvtest' }
24
- let(:chef_env_test_mixed_case) { 'chefENVtest' }
25
- let(:env_value1) { 'value1' }
26
- let(:env_value2) { 'value2' }
27
-
28
- let(:env_value_expandable) { '%SystemRoot%' }
29
- let(:test_run_context) {
30
- node = Chef::Node.new
31
- node.default['platform'] = 'windows'
32
- node.default['platform_version'] = '6.1'
33
- empty_events = Chef::EventDispatch::Dispatcher.new
34
- Chef::RunContext.new(node, {}, empty_events)
35
- }
36
- let(:test_resource) {
37
- Chef::Resource::Env.new('unknown', test_run_context)
38
- }
39
-
40
- before(:each) do
41
- resource_lower = Chef::Resource::Env.new(chef_env_test_lower_case, test_run_context)
42
- resource_lower.run_action(:delete)
43
- resource_mixed = Chef::Resource::Env.new(chef_env_test_mixed_case, test_run_context)
44
- resource_mixed.run_action(:delete)
45
- end
46
-
47
- context "when the create action is invoked" do
48
- it 'should create an environment variable for action create' do
49
- expect(ENV[chef_env_test_lower_case]).to eq(nil)
50
- test_resource.key_name(chef_env_test_lower_case)
51
- test_resource.value(env_value1)
52
- test_resource.run_action(:create)
53
- expect(ENV[chef_env_test_lower_case]).to eq(env_value1)
54
- end
55
-
56
- it "should modify an existing variable's value to a new value" do
57
- test_resource.key_name(chef_env_test_lower_case)
58
- test_resource.value(env_value1)
59
- test_resource.run_action(:create)
60
- expect(ENV[chef_env_test_lower_case]).to eq(env_value1)
61
- test_resource.value(env_value2)
62
- test_resource.run_action(:create)
63
- expect(ENV[chef_env_test_lower_case]).to eq(env_value2)
64
- end
65
-
66
- it "should modify an existing variable's value to a new value if the variable name case differs from the existing variable" do
67
- test_resource.key_name(chef_env_test_lower_case)
68
- test_resource.value(env_value1)
69
- test_resource.run_action(:create)
70
- expect(ENV[chef_env_test_lower_case]).to eq(env_value1)
71
- test_resource.key_name(chef_env_test_mixed_case)
72
- test_resource.value(env_value2)
73
- test_resource.run_action(:create)
74
- expect(ENV[chef_env_test_lower_case]).to eq(env_value2)
75
- end
76
-
77
- it 'should not expand environment variables if the variable is not PATH' do
78
- expect(ENV[chef_env_test_lower_case]).to eq(nil)
79
- test_resource.key_name(chef_env_test_lower_case)
80
- test_resource.value(env_value_expandable)
81
- test_resource.run_action(:create)
82
- expect(ENV[chef_env_test_lower_case]).to eq(env_value_expandable)
83
- end
84
- end
85
-
86
- context "when the modify action is invoked" do
87
- it "should raise an exception for modify if the variable doesn't exist" do
88
- expect(ENV[chef_env_test_lower_case]).to eq(nil)
89
- test_resource.key_name(chef_env_test_lower_case)
90
- test_resource.value(env_value1)
91
- expect {test_resource.run_action(:modify) }.to raise_error(Chef::Exceptions::Env)
92
- end
93
-
94
- it "should modify an existing variable's value to a new value" do
95
- test_resource.key_name(chef_env_test_lower_case)
96
- test_resource.value(env_value1)
97
- test_resource.run_action(:create)
98
- expect(ENV[chef_env_test_lower_case]).to eq(env_value1)
99
- test_resource.value(env_value2)
100
- test_resource.run_action(:modify)
101
- expect(ENV[chef_env_test_lower_case]).to eq(env_value2)
102
- end
103
-
104
- # This examlpe covers Chef Issue #1754
105
- it "should modify an existing variable's value to a new value if the variable name case differs from the existing variable" do
106
- test_resource.key_name(chef_env_test_lower_case)
107
- test_resource.value(env_value1)
108
- test_resource.run_action(:create)
109
- expect(ENV[chef_env_test_lower_case]).to eq(env_value1)
110
- test_resource.key_name(chef_env_test_mixed_case)
111
- test_resource.value(env_value2)
112
- test_resource.run_action(:modify)
113
- expect(ENV[chef_env_test_lower_case]).to eq(env_value2)
114
- end
115
-
116
- it 'should not expand environment variables if the variable is not PATH' do
117
- test_resource.key_name(chef_env_test_lower_case)
118
- test_resource.value(env_value1)
119
- test_resource.run_action(:create)
120
- expect(ENV[chef_env_test_lower_case]).to eq(env_value1)
121
- test_resource.value(env_value_expandable)
122
- test_resource.run_action(:modify)
123
- expect(ENV[chef_env_test_lower_case]).to eq(env_value_expandable)
124
- end
125
-
126
- context 'when using PATH' do
127
- let(:random_name) { Time.now.to_i }
128
- let(:env_val) { "#{env_value_expandable}_#{random_name}"}
129
- let!(:path_before) { test_resource.provider_for_action(test_resource.action).env_value('PATH') || '' }
130
- let!(:env_path_before) { ENV['PATH'] }
131
-
132
- it 'should expand PATH' do
133
- path_before.should_not include(env_val)
134
- test_resource.key_name('PATH')
135
- test_resource.value("#{path_before};#{env_val}")
136
- test_resource.run_action(:create)
137
- ENV['PATH'].should_not include(env_val)
138
- ENV['PATH'].should include("#{random_name}")
139
- end
140
-
141
- after(:each) do
142
- # cleanup so we don't flood the path
143
- test_resource.key_name('PATH')
144
- test_resource.value(path_before)
145
- test_resource.run_action(:create)
146
- ENV['PATH'] = env_path_before
147
- end
148
- end
149
-
150
- end
151
-
152
- context "when the delete action is invoked" do
153
- it "should delete an environment variable" do
154
- test_resource.key_name(chef_env_test_lower_case)
155
- test_resource.value(env_value1)
156
- test_resource.run_action(:create)
157
- expect(ENV[chef_env_test_lower_case]).to eq(env_value1)
158
- test_resource.run_action(:delete)
159
- expect(ENV[chef_env_test_lower_case]).to eq(nil)
160
- end
161
-
162
- it "should not raise an exception when a non-existent environment variable is deleted" do
163
- expect(ENV[chef_env_test_lower_case]).to eq(nil)
164
- test_resource.key_name(chef_env_test_lower_case)
165
- test_resource.value(env_value1)
166
- expect{test_resource.run_action(:delete)}.not_to raise_error
167
- expect(ENV[chef_env_test_lower_case]).to eq(nil)
168
- end
169
-
170
- it "should delete an existing variable's value to a new value if the specified variable name case differs from the existing variable" do
171
- test_resource.key_name(chef_env_test_lower_case)
172
- test_resource.value(env_value1)
173
- test_resource.run_action(:create)
174
- expect(ENV[chef_env_test_lower_case]).to eq(env_value1)
175
- test_resource.key_name(chef_env_test_mixed_case)
176
- test_resource.run_action(:delete)
177
- expect(ENV[chef_env_test_lower_case]).to eq(nil)
178
- expect(ENV[chef_env_test_mixed_case]).to eq(nil)
179
- end
180
- end
181
- end
182
- end
@@ -1,199 +0,0 @@
1
- #
2
- # Copyright:: Copyright (c) 2014 Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require 'spec_helper'
19
- require 'chef/mixin/shell_out'
20
-
21
- metadata = {
22
- :unix_only => true,
23
- :requires_root => true,
24
- :provider => {:user => Chef::Provider::User::Dscl},
25
- :not_supported_on_mac_osx_106 => true,
26
- }
27
-
28
- describe "Chef::Resource::User with Chef::Provider::User::Dscl provider", metadata do
29
- include Chef::Mixin::ShellOut
30
-
31
- def clean_user
32
- begin
33
- shell_out!("/usr/bin/dscl . -delete '/Users/#{username}'")
34
- rescue Mixlib::ShellOut::ShellCommandFailed
35
- # Raised when the user is already cleaned
36
- end
37
- end
38
-
39
- def user_should_exist
40
- shell_out("/usr/bin/dscl . -ls /Users").stdout.should include username
41
- end
42
-
43
- def check_password(pass)
44
- # In order to test the password we use dscl passwd command since
45
- # that's the only command that gets the user password from CLI.
46
- shell_out("dscl . -passwd /Users/greatchef #{pass} new_password").exitstatus.should == 0
47
- # Now reset the password back
48
- shell_out("dscl . -passwd /Users/greatchef new_password #{pass}").exitstatus.should == 0
49
- end
50
-
51
- let(:node) do
52
- n = Chef::Node.new
53
- n.consume_external_attrs(OHAI_SYSTEM.data.dup, {})
54
- n
55
- end
56
-
57
- let(:events) do
58
- Chef::EventDispatch::Dispatcher.new
59
- end
60
-
61
- let(:run_context) do
62
- Chef::RunContext.new(node, {}, events)
63
- end
64
-
65
- let(:username) do
66
- "greatchef"
67
- end
68
-
69
- let(:uid) { nil }
70
- let(:gid) { 20 }
71
- let(:home) { nil }
72
- let(:manage_home) { false }
73
- let(:password) { "XXXYYYZZZ" }
74
- let(:comment) { "Great Chef" }
75
- let(:shell) { "/bin/bash" }
76
- let(:salt) { nil }
77
- let(:iterations) { nil }
78
-
79
- let(:user_resource) do
80
- r = Chef::Resource::User.new("TEST USER RESOURCE", run_context)
81
- r.username(username)
82
- r.uid(uid)
83
- r.gid(gid)
84
- r.home(home)
85
- r.shell(shell)
86
- r.comment(comment)
87
- r.manage_home(manage_home)
88
- r.password(password)
89
- r.salt(salt)
90
- r.iterations(iterations)
91
- r
92
- end
93
-
94
- before do
95
- clean_user
96
- end
97
-
98
- after(:each) do
99
- clean_user
100
- end
101
-
102
- describe "action :create" do
103
- it "should create the user" do
104
- user_resource.run_action(:create)
105
- user_should_exist
106
- check_password(password)
107
- end
108
- end
109
-
110
- describe "when user exists" do
111
- before do
112
- existing_resource = user_resource.dup
113
- existing_resource.run_action(:create)
114
- user_should_exist
115
- end
116
-
117
- describe "when password is updated" do
118
- it "should update the password of the user" do
119
- user_resource.password("mykitchen")
120
- user_resource.run_action(:create)
121
- check_password("mykitchen")
122
- end
123
- end
124
- end
125
-
126
- describe "when password is being set via shadow hash" do
127
- let(:password) {
128
- if node[:platform_version].start_with?("10.7.")
129
- # On Mac 10.7 we only need to set the password
130
- "c9b3bd1a0cde797eef0eff16c580dab996ba3a21961cccc\
131
- d0f5e65c61558243e50b1a490088bd4824e3b35562d383ca02260398\
132
- ef1979b302212ec1c5383d1d05fc8d843"
133
- else
134
- "c734b6e4787c3727bb35e29fdd92b97c\
135
- 1de12df509577a045728255ec7c6c5f5\
136
- c18efa05ed02b682ffa7ebc05119900e\
137
- b1d4880833aa7a190afc13e2bf0936b8\
138
- 20123e8c98f0f9bcac2a629d9163caac\
139
- 9464a8c234f3919082400b4f939bb77b\
140
- c5adbbac718b7eb99463a7b679571e0f\
141
- 1c9fef2ef08d0b9e9c2bcf644eed2ffc"
142
- end
143
- }
144
-
145
- let(:iterations) { 25000 }
146
- let(:salt) { "9e2e7d5ee473b496fd24cf0bbfcaedfcb291ee21740e570d1e917e874f8788ca" }
147
-
148
- it "action :create should create the user" do
149
- user_resource.run_action(:create)
150
- user_should_exist
151
- check_password("soawesome")
152
- end
153
-
154
- describe "when user exists" do
155
- before do
156
- existing_resource = user_resource.dup
157
- existing_resource.run_action(:create)
158
- user_should_exist
159
- end
160
-
161
- describe "when password is updated" do
162
- it "should update the password of the user" do
163
- user_resource.password("mykitchen")
164
- user_resource.run_action(:create)
165
- check_password("mykitchen")
166
- end
167
- end
168
- end
169
- end
170
-
171
- describe "when a user is member of some groups" do
172
- let(:groups) { ["staff", "operator"] }
173
-
174
- before do
175
- existing_resource = user_resource.dup
176
- existing_resource.run_action(:create)
177
-
178
- groups.each do |group|
179
- shell_out!("/usr/bin/dscl . -append '/Groups/#{group}' GroupMembership #{username}")
180
- end
181
- end
182
-
183
- after do
184
- groups.each do |group|
185
- # Do not raise an error when user is correctly removed
186
- shell_out("/usr/bin/dscl . -delete '/Groups/#{group}' GroupMembership #{username}")
187
- end
188
- end
189
-
190
- it ":remove action removes the user from the groups and deletes the user"do
191
- user_resource.run_action(:remove)
192
- groups.each do |group|
193
- # Do not raise an error when group is empty
194
- shell_out("dscl . read /Groups/staff GroupMembership").stdout.should_not include(group)
195
- end
196
- end
197
- end
198
-
199
- end
@@ -1,113 +0,0 @@
1
- #
2
- # Author:: Adam Edwards (<adamed@getchef.com>)
3
- #
4
- # Copyright:: 2014, Chef Software, Inc.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require File.expand_path('../../../../spec_helper', __FILE__)
20
-
21
- describe Chef::Util::Powershell::Cmdlet, :windows_only do
22
- before(:all) do
23
- ohai = Ohai::System.new
24
- ohai.load_plugins
25
- ohai.run_plugins(true, ['platform', 'kernel'])
26
- @node = Chef::Node.new
27
- @node.consume_external_attrs(ohai.data, {})
28
- end
29
- let(:cmd_output_format) { :text }
30
- let(:simple_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, 'get-childitem', cmd_output_format, {:depth => 2}) }
31
- let(:invalid_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, 'get-idontexist', cmd_output_format) }
32
- let(:cmdlet_get_item_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, 'get-item', cmd_output_format, {:depth => 2}) }
33
- let(:cmdlet_alias_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, 'alias', cmd_output_format, {:depth => 2}) }
34
- let(:etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" }
35
- let(:architecture_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "$env:PROCESSOR_ARCHITECTURE")}
36
-
37
- it "executes a simple process" do
38
- result = simple_cmdlet.run
39
- expect(result.succeeded?).to eq(true)
40
- end
41
-
42
- it "#run does not raise a PowershellCmdletException exception if the command cannot be executed" do
43
- expect {invalid_cmdlet.run}.not_to raise_error
44
- end
45
-
46
- it "#run! raises a PowershellCmdletException exception if the command cannot be executed" do
47
- expect {invalid_cmdlet.run!}.to raise_error(Chef::Exceptions::PowershellCmdletException)
48
- end
49
-
50
- it "executes a 64-bit command on a 64-bit OS, 32-bit otherwise" do
51
- os_arch = ENV['PROCESSOR_ARCHITEW6432']
52
- if os_arch.nil?
53
- os_arch = ENV['PROCESSOR_ARCHITECTURE']
54
- end
55
-
56
- result = architecture_cmdlet.run
57
- execution_arch = result.return_value
58
- execution_arch.strip!
59
- expect(execution_arch).to eq(os_arch)
60
- end
61
-
62
- it "passes command line switches to the command" do
63
- result = cmdlet_alias_requires_switch_or_argument.run({:name => 'ls'})
64
- expect(result.succeeded?).to eq(true)
65
- end
66
-
67
- it "passes command line arguments to the command" do
68
- result = cmdlet_alias_requires_switch_or_argument.run({},{},'ls')
69
- expect(result.succeeded?).to eq(true)
70
- end
71
-
72
- it "passes command line arguments and switches to the command" do
73
- result = cmdlet_get_item_requires_switch_or_argument.run({:path => etc_directory},{},' | select-object -property fullname | format-table -hidetableheaders')
74
- expect(result.succeeded?).to eq(true)
75
- returned_directory = result.return_value
76
- returned_directory.strip!
77
- expect(returned_directory).to eq(etc_directory)
78
- end
79
-
80
- it "passes execution options to the command" do
81
- result = cmdlet_get_item_requires_switch_or_argument.run({},{:cwd => etc_directory},'. | select-object -property fullname | format-table -hidetableheaders')
82
- expect(result.succeeded?).to eq(true)
83
- returned_directory = result.return_value
84
- returned_directory.strip!
85
- expect(returned_directory).to eq(etc_directory)
86
- end
87
-
88
- context "when returning json" do
89
- let(:cmd_output_format) { :json }
90
- it "returns json format data", :windows_powershell_dsc_only do
91
- result = cmdlet_alias_requires_switch_or_argument.run({},{},'ls')
92
- expect(result.succeeded?).to eq(true)
93
- expect(lambda{Chef::JSONCompat.parse(result.return_value)}).not_to raise_error
94
- end
95
- end
96
-
97
- context "when returning Ruby objects" do
98
- let(:cmd_output_format) { :object }
99
- it "returns object format data", :windows_powershell_dsc_only do
100
- result = simple_cmdlet.run({},{:cwd => etc_directory}, 'hosts')
101
- expect(result.succeeded?).to eq(true)
102
- data = result.return_value
103
- expect(data['Name']).to eq('hosts')
104
- end
105
- end
106
-
107
- context "when constructor is given invalid arguments" do
108
- let(:cmd_output_format) { :invalid }
109
- it "throws an exception if an invalid format is passed to the constructor" do
110
- expect(lambda{simple_cmdlet}).to raise_error
111
- end
112
- end
113
- end