chef 15.4.45-universal-mingw32 → 15.5.9-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -3
  3. data/Rakefile +5 -3
  4. data/chef.gemspec +2 -1
  5. data/ext/win32-eventlog/Rakefile +9 -1
  6. data/ext/win32-eventlog/{chef-log.man → chef-log.man.erb} +4 -4
  7. data/lib/chef/application.rb +2 -2
  8. data/lib/chef/application/client.rb +1 -1
  9. data/lib/chef/application/knife.rb +1 -0
  10. data/lib/chef/application/solo.rb +1 -1
  11. data/lib/chef/chef_class.rb +1 -6
  12. data/lib/chef/chef_fs.rb +1 -1
  13. data/lib/chef/chef_fs/file_pattern.rb +1 -1
  14. data/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb +2 -2
  15. data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +2 -2
  16. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb +1 -1
  17. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +7 -1
  18. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +4 -3
  19. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +3 -3
  20. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb +1 -1
  21. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -3
  22. data/lib/chef/chef_fs/knife.rb +1 -1
  23. data/lib/chef/chef_fs/path_utils.rb +2 -2
  24. data/lib/chef/client.rb +4 -5
  25. data/lib/chef/config.rb +3 -2
  26. data/lib/chef/cookbook/chefignore.rb +16 -11
  27. data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
  28. data/lib/chef/cookbook/syntax_check.rb +5 -3
  29. data/lib/chef/cookbook_loader.rb +3 -3
  30. data/lib/chef/cookbook_uploader.rb +1 -1
  31. data/lib/chef/data_collector.rb +2 -2
  32. data/lib/chef/data_collector/run_end_message.rb +1 -0
  33. data/lib/chef/deprecated.rb +4 -0
  34. data/lib/chef/dsl/core.rb +1 -1
  35. data/lib/chef/dsl/platform_introspection.rb +9 -18
  36. data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
  37. data/lib/chef/file_content_management/deploy.rb +3 -3
  38. data/lib/chef/file_content_management/deploy/mv_windows.rb +2 -2
  39. data/lib/chef/file_content_management/tempfile.rb +1 -1
  40. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +2 -2
  41. data/lib/chef/http.rb +1 -1
  42. data/lib/chef/http/socketless_chef_zero_client.rb +1 -1
  43. data/lib/chef/knife.rb +4 -3
  44. data/lib/chef/knife/config_get.rb +2 -1
  45. data/lib/chef/knife/configure.rb +1 -1
  46. data/lib/chef/knife/cookbook_metadata_from_file.rb +6 -0
  47. data/lib/chef/knife/core/generic_presenter.rb +1 -1
  48. data/lib/chef/knife/core/status_presenter.rb +1 -1
  49. data/lib/chef/knife/ssh.rb +6 -0
  50. data/lib/chef/local_mode.rb +1 -1
  51. data/lib/chef/mash.rb +21 -232
  52. data/lib/chef/mixin/file_class.rb +2 -2
  53. data/lib/chef/mixin/lazy_module_include.rb +1 -1
  54. data/lib/chef/mixin/path_sanity.rb +3 -39
  55. data/lib/chef/mixin/securable.rb +1 -1
  56. data/lib/chef/mixin/shell_out.rb +4 -5
  57. data/lib/chef/mixin/template.rb +1 -1
  58. data/lib/chef/mixin/user_context.rb +3 -3
  59. data/lib/chef/mixin/which.rb +10 -38
  60. data/lib/chef/mixin/windows_architecture_helper.rb +6 -6
  61. data/lib/chef/mixin/windows_env_helper.rb +5 -5
  62. data/lib/chef/node/attribute.rb +2 -2
  63. data/lib/chef/node_map.rb +17 -4
  64. data/lib/chef/platform/query_helpers.rb +4 -2
  65. data/lib/chef/platform/rebooter.rb +1 -1
  66. data/lib/chef/platform/service_helpers.rb +14 -85
  67. data/lib/chef/provider.rb +2 -0
  68. data/lib/chef/provider/file.rb +2 -2
  69. data/lib/chef/provider/ifconfig/redhat.rb +1 -1
  70. data/lib/chef/provider/link.rb +3 -3
  71. data/lib/chef/provider/mount/solaris.rb +1 -1
  72. data/lib/chef/provider/package/yum.rb +1 -1
  73. data/lib/chef/provider/registry_key.rb +1 -1
  74. data/lib/chef/provider/remote_directory.rb +3 -3
  75. data/lib/chef/provider/remote_file/fetcher.rb +2 -2
  76. data/lib/chef/provider/remote_file/local_file.rb +1 -1
  77. data/lib/chef/provider/script.rb +3 -3
  78. data/lib/chef/provider/service.rb +5 -2
  79. data/lib/chef/provider/service/arch.rb +1 -1
  80. data/lib/chef/provider/service/debian.rb +4 -4
  81. data/lib/chef/provider/service/init.rb +1 -1
  82. data/lib/chef/provider/service/insserv.rb +4 -4
  83. data/lib/chef/provider/service/invokercd.rb +4 -4
  84. data/lib/chef/provider/service/redhat.rb +4 -4
  85. data/lib/chef/provider/service/systemd.rb +19 -3
  86. data/lib/chef/provider/service/upstart.rb +3 -3
  87. data/lib/chef/provider/subversion.rb +1 -1
  88. data/lib/chef/provider/systemd_unit.rb +26 -2
  89. data/lib/chef/provider/windows_path.rb +3 -3
  90. data/lib/chef/provider/windows_task.rb +4 -4
  91. data/lib/chef/resource.rb +1 -0
  92. data/lib/chef/resource/bash.rb +2 -0
  93. data/lib/chef/resource/batch.rb +2 -0
  94. data/lib/chef/resource/breakpoint.rb +3 -1
  95. data/lib/chef/resource/build_essential.rb +3 -3
  96. data/lib/chef/resource/chef_sleep.rb +70 -0
  97. data/lib/chef/resource/cookbook_file.rb +2 -1
  98. data/lib/chef/resource/csh.rb +2 -0
  99. data/lib/chef/resource/directory.rb +2 -0
  100. data/lib/chef/resource/dmg_package.rb +1 -1
  101. data/lib/chef/resource/dnf_package.rb +1 -1
  102. data/lib/chef/resource/execute.rb +2 -0
  103. data/lib/chef/resource/file.rb +2 -1
  104. data/lib/chef/resource/git.rb +2 -0
  105. data/lib/chef/resource/group.rb +1 -1
  106. data/lib/chef/resource/homebrew_package.rb +1 -1
  107. data/lib/chef/resource/http_request.rb +2 -0
  108. data/lib/chef/resource/ifconfig.rb +3 -1
  109. data/lib/chef/resource/ksh.rb +2 -0
  110. data/lib/chef/resource/link.rb +4 -2
  111. data/lib/chef/resource/locale.rb +1 -1
  112. data/lib/chef/resource/log.rb +2 -0
  113. data/lib/chef/resource/ohai.rb +2 -0
  114. data/lib/chef/resource/perl.rb +2 -0
  115. data/lib/chef/resource/python.rb +2 -0
  116. data/lib/chef/resource/reboot.rb +2 -0
  117. data/lib/chef/resource/registry_key.rb +2 -0
  118. data/lib/chef/resource/remote_directory.rb +3 -2
  119. data/lib/chef/resource/remote_file.rb +1 -0
  120. data/lib/chef/resource/ruby.rb +2 -0
  121. data/lib/chef/resource/ruby_block.rb +2 -0
  122. data/lib/chef/resource/scm.rb +2 -0
  123. data/lib/chef/resource/script.rb +2 -0
  124. data/lib/chef/resource/service.rb +9 -1
  125. data/lib/chef/resource/solaris_package.rb +1 -1
  126. data/lib/chef/resource/subversion.rb +2 -0
  127. data/lib/chef/resource/sudo.rb +1 -1
  128. data/lib/chef/resource/systemd_unit.rb +1 -0
  129. data/lib/chef/resource/template.rb +2 -0
  130. data/lib/chef/resource/user.rb +2 -0
  131. data/lib/chef/resource/user/aix_user.rb +2 -0
  132. data/lib/chef/resource/user/linux_user.rb +2 -0
  133. data/lib/chef/resource/user/pw_user.rb +2 -0
  134. data/lib/chef/resource/user/solaris_user.rb +2 -0
  135. data/lib/chef/resource/user/windows_user.rb +2 -0
  136. data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
  137. data/lib/chef/resource/windows_ad_join.rb +1 -1
  138. data/lib/chef/resource/windows_env.rb +1 -1
  139. data/lib/chef/resource/windows_feature.rb +2 -2
  140. data/lib/chef/resource/windows_feature_powershell.rb +1 -1
  141. data/lib/chef/resource/windows_firewall_rule.rb +11 -6
  142. data/lib/chef/resource/windows_script.rb +3 -1
  143. data/lib/chef/resource/yum_package.rb +1 -1
  144. data/lib/chef/resource_reporter.rb +1 -1
  145. data/lib/chef/resources.rb +1 -0
  146. data/lib/chef/run_context.rb +1 -1
  147. data/lib/chef/run_lock.rb +5 -5
  148. data/lib/chef/search/query.rb +0 -3
  149. data/lib/chef/train_transport.rb +3 -1
  150. data/lib/chef/util/powershell/ps_credential.rb +2 -2
  151. data/lib/chef/util/selinux.rb +1 -1
  152. data/lib/chef/util/windows/logon_session.rb +2 -2
  153. data/lib/chef/version.rb +1 -1
  154. data/lib/chef/win32/eventlog.rb +2 -2
  155. data/spec/data/cookbooks/starter/chefignore +8 -0
  156. data/spec/data/cookbooks/starter/files/sample.txt +1 -0
  157. data/spec/data/cookbooks/starter/metadata.rb +2 -0
  158. data/spec/data/cookbooks/starter/recipes/default.rb +4 -0
  159. data/spec/functional/event_loggers/windows_eventlog_spec.rb +1 -1
  160. data/spec/functional/mixin/user_context_spec.rb +2 -2
  161. data/spec/functional/rebooter_spec.rb +1 -1
  162. data/spec/functional/resource/cookbook_file_spec.rb +2 -2
  163. data/spec/functional/resource/template_spec.rb +1 -1
  164. data/spec/functional/version_spec.rb +1 -1
  165. data/spec/functional/win32/crypto_spec.rb +1 -1
  166. data/spec/functional/win32/security_spec.rb +1 -1
  167. data/spec/functional/win32/service_manager_spec.rb +1 -1
  168. data/spec/functional/win32/sid_spec.rb +2 -2
  169. data/spec/functional/win32/version_info_spec.rb +1 -1
  170. data/spec/functional/win32/versions_spec.rb +1 -1
  171. data/spec/integration/knife/config_get_profile_spec.rb +2 -2
  172. data/spec/integration/knife/config_get_spec.rb +9 -2
  173. data/spec/integration/knife/config_list_profiles_spec.rb +2 -2
  174. data/spec/integration/knife/config_use_profile_spec.rb +2 -2
  175. data/spec/integration/knife/list_spec.rb +2 -2
  176. data/spec/integration/solo/solo_spec.rb +1 -1
  177. data/spec/support/matchers/leak.rb +1 -1
  178. data/spec/support/mock/platform.rb +1 -1
  179. data/spec/support/platform_helpers.rb +2 -0
  180. data/spec/support/shared/integration/integration_helper.rb +1 -1
  181. data/spec/support/shared/integration/knife_support.rb +1 -1
  182. data/spec/support/shared/unit/provider/file.rb +4 -4
  183. data/spec/unit/application/client_spec.rb +2 -2
  184. data/spec/unit/application/knife_spec.rb +17 -0
  185. data/spec/unit/application_spec.rb +1 -1
  186. data/spec/unit/chef_fs/file_pattern_spec.rb +2 -2
  187. data/spec/unit/chef_fs/path_util_spec.rb +3 -3
  188. data/spec/unit/client_spec.rb +2 -2
  189. data/spec/unit/cookbook/chefignore_spec.rb +31 -11
  190. data/spec/unit/cookbook/cookbook_version_loader_spec.rb +1 -1
  191. data/spec/unit/cookbook/syntax_check_spec.rb +2 -2
  192. data/spec/unit/cookbook_loader_spec.rb +2 -2
  193. data/spec/unit/cookbook_uploader_spec.rb +6 -1
  194. data/spec/unit/data_bag_spec.rb +2 -2
  195. data/spec/unit/data_collector_spec.rb +7 -0
  196. data/spec/unit/dsl/platform_introspection_spec.rb +31 -1
  197. data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +1 -1
  198. data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +1 -1
  199. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +7 -0
  200. data/spec/unit/knife/cookbook_show_spec.rb +1 -1
  201. data/spec/unit/knife/core/gem_glob_loader_spec.rb +1 -1
  202. data/spec/unit/knife/core/hashed_command_loader_spec.rb +1 -1
  203. data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -1
  204. data/spec/unit/knife/core/ui_spec.rb +2 -2
  205. data/spec/unit/knife/data_bag_from_file_spec.rb +2 -2
  206. data/spec/unit/knife/environment_from_file_spec.rb +2 -2
  207. data/spec/unit/knife/ssh_spec.rb +27 -17
  208. data/spec/unit/knife/status_spec.rb +1 -1
  209. data/spec/unit/knife/supermarket_install_spec.rb +1 -1
  210. data/spec/unit/mixin/path_sanity_spec.rb +3 -3
  211. data/spec/unit/mixin/shell_out_spec.rb +2 -3
  212. data/spec/unit/mixin/template_spec.rb +4 -4
  213. data/spec/unit/mixin/user_context_spec.rb +3 -3
  214. data/spec/unit/node_map_spec.rb +12 -12
  215. data/spec/unit/platform/query_helpers_spec.rb +9 -9
  216. data/spec/unit/provider/execute_spec.rb +1 -1
  217. data/spec/unit/provider/link_spec.rb +5 -5
  218. data/spec/unit/provider/package/openbsd_spec.rb +1 -1
  219. data/spec/unit/provider/package/smartos_spec.rb +1 -1
  220. data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
  221. data/spec/unit/provider/package/windows_spec.rb +2 -2
  222. data/spec/unit/provider/remote_file/fetcher_spec.rb +2 -2
  223. data/spec/unit/provider/remote_file/local_file_spec.rb +1 -1
  224. data/spec/unit/provider/remote_file/network_file_spec.rb +1 -1
  225. data/spec/unit/provider/script_spec.rb +2 -2
  226. data/spec/unit/provider/service/systemd_service_spec.rb +26 -2
  227. data/spec/unit/provider/subversion_spec.rb +3 -3
  228. data/spec/unit/provider/systemd_unit_spec.rb +53 -4
  229. data/spec/unit/provider/user/dscl_spec.rb +1 -1
  230. data/spec/unit/provider_resolver_spec.rb +41 -61
  231. data/spec/unit/resource/chef_sleep_spec.rb +30 -0
  232. data/spec/unit/resource/cookbook_file_spec.rb +3 -3
  233. data/spec/unit/resource/remote_file_spec.rb +3 -3
  234. data/spec/unit/resource/windows_firewall_rule_spec.rb +69 -12
  235. data/spec/unit/role_spec.rb +2 -2
  236. data/spec/unit/shell_spec.rb +1 -1
  237. data/spec/unit/util/selinux_spec.rb +2 -2
  238. data/spec/unit/win32/error_spec.rb +1 -1
  239. data/spec/unit/win32/link_spec.rb +1 -1
  240. data/spec/unit/win32/security_spec.rb +1 -1
  241. data/spec/unit/windows_service_spec.rb +1 -1
  242. data/tasks/docs.rb +10 -2
  243. data/tasks/rspec.rb +8 -6
  244. metadata +33 -9
  245. data/lib/chef/mixin/train_helpers.rb +0 -60
  246. data/spec/unit/mash_spec.rb +0 -51
@@ -68,11 +68,11 @@ describe Chef::Resource::CookbookFile do
68
68
  let(:path) { File.join(windows_non_temp_dir, make_tmpname(file_base)) }
69
69
 
70
70
  before do
71
- FileUtils.mkdir_p(windows_non_temp_dir) if Chef::Platform.windows?
71
+ FileUtils.mkdir_p(windows_non_temp_dir) if ChefUtils.windows?
72
72
  end
73
73
 
74
74
  after do
75
- FileUtils.rm_r(windows_non_temp_dir) if Chef::Platform.windows? && File.exists?(windows_non_temp_dir)
75
+ FileUtils.rm_r(windows_non_temp_dir) if ChefUtils.windows? && File.exists?(windows_non_temp_dir)
76
76
  end
77
77
 
78
78
  end
@@ -203,7 +203,7 @@ describe Chef::Resource::Template do
203
203
  it "output should contain platform's line endings" do
204
204
  resource.run_action(:create)
205
205
  binread(path).each_line do |line|
206
- expect(line).to end_with(Chef::Platform.windows? ? "\r\n" : "\n")
206
+ expect(line).to end_with(ChefUtils.windows? ? "\r\n" : "\n")
207
207
  end
208
208
  end
209
209
  end
@@ -21,7 +21,7 @@ require "chef/version"
21
21
  require "ohai/version"
22
22
  require "chef/dist"
23
23
 
24
- describe "Chef Versions" do
24
+ describe "Chef Versions", :executables do
25
25
  include Chef::Mixin::ShellOut
26
26
  let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..") }
27
27
 
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
- if Chef::Platform.windows?
20
+ if ChefUtils.windows?
21
21
  require "chef/win32/crypto"
22
22
  end
23
23
 
@@ -19,7 +19,7 @@
19
19
  require "spec_helper"
20
20
  require "mixlib/shellout"
21
21
  require "chef/mixin/user_context"
22
- if Chef::Platform.windows?
22
+ if ChefUtils.windows?
23
23
  require "chef/win32/security"
24
24
  end
25
25
 
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
- if Chef::Platform.windows?
20
+ if ChefUtils.windows?
21
21
  require "chef/application/windows_service_manager"
22
22
  end
23
23
 
@@ -17,12 +17,12 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
- if Chef::Platform.windows?
20
+ if ChefUtils.windows?
21
21
  require "chef/win32/security"
22
22
  end
23
23
 
24
24
  describe "Chef::ReservedNames::Win32::SID", :windows_only do
25
- if Chef::Platform.windows?
25
+ if ChefUtils.windows?
26
26
  SID ||= Chef::ReservedNames::Win32::Security::SID
27
27
  end
28
28
 
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
- if Chef::Platform.windows?
20
+ if ChefUtils.windows?
21
21
  require "chef/win32/file/version_info"
22
22
  end
23
23
 
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
- if Chef::Platform.windows?
20
+ if ChefUtils.windows?
21
21
  require "chef/win32/version"
22
22
  end
23
23
 
@@ -50,7 +50,7 @@ describe "knife config get-profile", :workstation do
50
50
  ENV["KNIFE_HOME"] = old_knife_home
51
51
  ENV["HOME"] = old_home
52
52
  Dir.chdir(old_wd)
53
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
53
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
54
54
  ChefConfig::PathHelper.per_tool_home_environment = nil
55
55
  end
56
56
  end
@@ -60,7 +60,7 @@ describe "knife config get-profile", :workstation do
60
60
  # because it has to run after the before set in the "with a chef repo" shared context.
61
61
  directory("repo")
62
62
  Dir.chdir(path_to("repo"))
63
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
63
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
64
64
  ENV["HOME"] = path_to(".")
65
65
  end
66
66
 
@@ -54,7 +54,7 @@ describe "knife config get", :workstation do
54
54
  ENV["KNIFE_HOME"] = old_knife_home
55
55
  ENV["HOME"] = old_home
56
56
  Dir.chdir(old_wd)
57
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
57
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
58
58
  ChefConfig::PathHelper.per_tool_home_environment = nil
59
59
  end
60
60
  end
@@ -64,7 +64,7 @@ describe "knife config get", :workstation do
64
64
  # because it has to run after the before set in the "with a chef repo" shared context.
65
65
  directory("repo")
66
66
  Dir.chdir(path_to("repo"))
67
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
67
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
68
68
  ENV["HOME"] = path_to(".")
69
69
  end
70
70
 
@@ -110,6 +110,13 @@ describe "knife config get", :workstation do
110
110
  it { is_expected.to match(/^node_name:\s+one$/) }
111
111
  end
112
112
 
113
+ context "with a config dot d files" do
114
+ before { file(".chef/config.d/abc.rb", "node_name 'one'\n") }
115
+
116
+ it { is_expected.to match(%r{^Loading from .d/ configuration file .*/#{File.basename(path_to("."))}/.chef/config.d/abc.rb$}) }
117
+ it { is_expected.to match(/^node_name:\s+one$/) }
118
+ end
119
+
113
120
  context "with a credentials file and CHEF_HOME" do
114
121
  before do
115
122
  file(".chef/credentials", "[default]\nclient_name = \"three\"\n")
@@ -44,7 +44,7 @@ describe "knife config list-profiles", :workstation do
44
44
  ensure
45
45
  ENV["HOME"] = old_home
46
46
  Dir.chdir(old_wd)
47
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
47
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
48
48
  end
49
49
  end
50
50
 
@@ -53,7 +53,7 @@ describe "knife config list-profiles", :workstation do
53
53
  # because it has to run after the before set in the "with a chef repo" shared context.
54
54
  directory("repo")
55
55
  Dir.chdir(path_to("repo"))
56
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
56
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
57
57
  ENV["HOME"] = path_to(".")
58
58
  end
59
59
 
@@ -51,7 +51,7 @@ describe "knife config use-profile", :workstation do
51
51
  ENV["KNIFE_HOME"] = old_knife_home
52
52
  ENV["HOME"] = old_home
53
53
  Dir.chdir(old_wd)
54
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
54
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
55
55
  ChefConfig::PathHelper.per_tool_home_environment = nil
56
56
  end
57
57
  end
@@ -61,7 +61,7 @@ describe "knife config use-profile", :workstation do
61
61
  # because it has to run after the before set in the "with a chef repo" shared context.
62
62
  directory("repo")
63
63
  Dir.chdir(path_to("repo"))
64
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
64
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
65
65
  ENV["HOME"] = path_to(".")
66
66
  end
67
67
 
@@ -466,7 +466,7 @@ describe "knife list", :workstation do
466
466
  end
467
467
  end
468
468
 
469
- when_the_repository "has a cookbooks directory and a symlinked cookbooks directory", skip: (Chef::Platform.windows?) do
469
+ when_the_repository "has a cookbooks directory and a symlinked cookbooks directory", skip: (ChefUtils.windows?) do
470
470
  before do
471
471
  directory "cookbooks"
472
472
  symlink "symlinked", "cookbooks"
@@ -503,7 +503,7 @@ describe "knife list", :workstation do
503
503
  end
504
504
  end
505
505
 
506
- when_the_repository "has a real_cookbooks directory and a cookbooks symlink to it", skip: (Chef::Platform.windows?) do
506
+ when_the_repository "has a real_cookbooks directory and a cookbooks symlink to it", skip: (ChefUtils.windows?) do
507
507
  before do
508
508
  directory "real_cookbooks"
509
509
  symlink "cookbooks", "real_cookbooks"
@@ -4,7 +4,7 @@ require "chef/run_lock"
4
4
  require "chef/config"
5
5
  require "timeout"
6
6
  require "fileutils"
7
- require "chef/win32/security" if Chef::Platform.windows?
7
+ require "chef/win32/security" if ChefUtils.windows?
8
8
  require "chef/dist"
9
9
 
10
10
  describe Chef::Dist::SOLOEXEC do
@@ -60,7 +60,7 @@ module Matchers
60
60
 
61
61
  def profiler
62
62
  @profiler ||= begin
63
- if Chef::Platform.windows?
63
+ if ChefUtils.windows?
64
64
  require File.join(File.dirname(__FILE__), "..", "platforms", "prof", "win32")
65
65
  RSpec::Prof::Win32::Profiler.new
66
66
  else
@@ -6,7 +6,7 @@
6
6
  # testing code that mixes in platform specific modules like +Chef::Mixin::Securable+
7
7
  # or +Chef::FileAccessControl+
8
8
  def platform_mock(platform = :unix)
9
- allow(ChefConfig).to receive(:windows?).and_return(platform == :windows ? true : false)
9
+ allow(ChefUtils).to receive(:windows?).and_return(platform == :windows ? true : false)
10
10
  ENV["SYSTEMDRIVE"] = (platform == :windows ? "C:" : nil)
11
11
 
12
12
  if platform == :windows
@@ -35,6 +35,8 @@ def ruby_32bit?
35
35
  end
36
36
 
37
37
  def windows?
38
+ # NOTE this deliberately does not use ChefUtils.windows? because otherwise it would
39
+ # pick up the node out of tests, while this tests the hosts running the specs.
38
40
  !!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
39
41
  end
40
42
 
@@ -128,7 +128,7 @@ module IntegrationSupport
128
128
  # TODO: "force" actually means "silence all exceptions". this
129
129
  # silences a weird permissions error on Windows that we should track
130
130
  # down, but for now there's no reason for it to blow up our CI.
131
- FileUtils.remove_entry_secure(@repository_dir, force = Chef::Platform.windows?)
131
+ FileUtils.remove_entry_secure(@repository_dir, force = ChefUtils.windows?)
132
132
  ensure
133
133
  @repository_dir = nil
134
134
  end
@@ -181,7 +181,7 @@ module KnifeSupport
181
181
  expect(stderr_actual).to eq(expected[:stderr])
182
182
  end
183
183
  stdout_actual = @stdout
184
- if Chef::Platform.windows?
184
+ if ChefUtils.windows?
185
185
  stderr_actual = stderr_actual.gsub("\r\n", "\n")
186
186
  stdout_actual = stdout_actual.gsub("\r\n", "\n")
187
187
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Lamont Granquist (<lamont@chef.io>)
3
- # Copyright:: Copyright 2013-2016, Chef Software, Inc.
3
+ # Copyright:: Copyright 2013-2018, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -256,7 +256,7 @@ shared_examples_for Chef::Provider::File do
256
256
  context "examining file security metadata on Unix with a file that exists" do
257
257
  before do
258
258
  # fake that we're on unix even if we're on windows
259
- allow(ChefConfig).to receive(:windows?).and_return(false)
259
+ allow(ChefUtils).to receive(:windows?).and_return(false)
260
260
  # mock up the filesystem to behave like unix
261
261
  setup_normal_file
262
262
  stat_struct = double("::File.stat", mode: 0600, uid: 0, gid: 0, mtime: 10000)
@@ -332,7 +332,7 @@ shared_examples_for Chef::Provider::File do
332
332
  context "examining file security metadata on Unix with a file that does not exist" do
333
333
  before do
334
334
  # fake that we're on unix even if we're on windows
335
- allow(ChefConfig).to receive(:windows?).and_return(false)
335
+ allow(ChefUtils).to receive(:windows?).and_return(false)
336
336
  setup_missing_file
337
337
  end
338
338
 
@@ -381,7 +381,7 @@ shared_examples_for Chef::Provider::File do
381
381
 
382
382
  before do
383
383
  # fake that we're on unix even if we're on windows
384
- allow(ChefConfig).to receive(:windows?).and_return(false)
384
+ allow(ChefUtils).to receive(:windows?).and_return(false)
385
385
  # mock up the filesystem to behave like unix
386
386
  setup_normal_file
387
387
  stat_struct = double("::File.stat", mode: 0600, uid: 0, gid: 0, mtime: 10000)
@@ -323,7 +323,7 @@ describe Chef::Application::Client, "reconfigure" do
323
323
 
324
324
  it "should terminate with message when interval is given" do
325
325
  Chef::Config[:interval] = 600
326
- allow(ChefConfig).to receive(:windows?).and_return(false)
326
+ allow(ChefUtils).to receive(:windows?).and_return(false)
327
327
  expect(Chef::Application).to receive(:fatal!).with(
328
328
  /Unforked .* interval runs are disabled by default\.
329
329
  Configuration settings:
@@ -336,7 +336,7 @@ Enable .* interval runs by setting `:client_fork = true` in your config file or
336
336
  context "when interval is given on windows" do
337
337
  before do
338
338
  Chef::Config[:interval] = 600
339
- allow(ChefConfig).to receive(:windows?).and_return(true)
339
+ allow(ChefUtils).to receive(:windows?).and_return(true)
340
340
  end
341
341
 
342
342
  it "should terminate" do
@@ -77,6 +77,23 @@ describe Chef::Application::Knife do
77
77
  expect(Chef::Config[:color]).to be_truthy
78
78
  end
79
79
 
80
+ context "validate --format option" do
81
+ it "should set the default format summary" do
82
+ with_argv(*%w{noop knife command}) do
83
+ expect(@knife).to receive(:exit).with(0)
84
+ @knife.run
85
+ expect(@knife.default_config[:format]).to eq("summary")
86
+ end
87
+ end
88
+
89
+ it "should raise the error for invalid value" do
90
+ with_argv(*%w{noop knife command -F abc}) do
91
+ expect(STDOUT).to receive(:puts).at_least(2).times
92
+ expect { @knife.run }.to raise_error(SystemExit) { |e| expect(e.status).to eq(2) }
93
+ end
94
+ end
95
+ end
96
+
80
97
  context "when given fips flags" do
81
98
  context "when Chef::Config[:fips]=false" do
82
99
  before do
@@ -277,7 +277,7 @@ describe Chef::Application do
277
277
  end
278
278
  end
279
279
 
280
- if Chef::Platform.windows?
280
+ if ChefUtils.windows?
281
281
  it_behaves_like "sets log_location", :win_evt, Chef::Log::WinEvt
282
282
  it_behaves_like "sets log_location", "win_evt", Chef::Log::WinEvt
283
283
  else
@@ -157,7 +157,7 @@ describe Chef::ChefFS::FilePattern do
157
157
  end
158
158
  end
159
159
 
160
- context 'with simple pattern "a\*\b"', skip: (Chef::Platform.windows?) do
160
+ context 'with simple pattern "a\*\b"', skip: (ChefUtils.windows?) do
161
161
  let(:pattern) { Chef::ChefFS::FilePattern.new('a\*\b') }
162
162
  it "match?" do
163
163
  expect(pattern.match?("a*b")).to be_truthy
@@ -264,7 +264,7 @@ describe Chef::ChefFS::FilePattern do
264
264
  end
265
265
  end
266
266
 
267
- context 'with star pattern "/abc/d[a-z][0-9]f/ghi"', skip: (Chef::Platform.windows?) do
267
+ context 'with star pattern "/abc/d[a-z][0-9]f/ghi"', skip: (ChefUtils.windows?) do
268
268
  let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/d[a-z][0-9]f/ghi") }
269
269
  it "match?" do
270
270
  expect(pattern.match?("/abc/de1f/ghi")).to be_truthy
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Kartik Null Cating-Subramanian (<ksubramanian@chef.io>)
3
- # Copyright:: Copyright 2015-2016, Chef Software Inc.
3
+ # Copyright:: Copyright 2015-2018, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -81,7 +81,7 @@ describe Chef::ChefFS::PathUtils do
81
81
  end
82
82
 
83
83
  it "handles root correctly" do
84
- if Chef::Platform.windows?
84
+ if ChefUtils.windows?
85
85
  expect(Chef::ChefFS::PathUtils.realest_path("C:/")).to eq("C:/")
86
86
  else
87
87
  expect(Chef::ChefFS::PathUtils.realest_path("/")).to eq("/")
@@ -91,7 +91,7 @@ describe Chef::ChefFS::PathUtils do
91
91
 
92
92
  context "invoking descendant_path" do
93
93
  it "handles paths with various casing on windows" do
94
- allow(Chef::ChefFS).to receive(:windows?) { true }
94
+ allow(ChefUtils).to receive(:windows?) { true }
95
95
  expect(Chef::ChefFS::PathUtils.descendant_path("C:/ab/b/c", "C:/AB/B")).to eq("c")
96
96
  expect(Chef::ChefFS::PathUtils.descendant_path("C:/ab/b/c", "c:/ab/B")).to eq("c")
97
97
  end
@@ -670,7 +670,7 @@ describe Chef::Client do
670
670
  describe "windows_admin_check" do
671
671
  context "platform is not windows" do
672
672
  before do
673
- allow(ChefConfig).to receive(:windows?).and_return(false)
673
+ allow(ChefUtils).to receive(:windows?).and_return(false)
674
674
  end
675
675
 
676
676
  it "shouldn't be called" do
@@ -681,7 +681,7 @@ describe Chef::Client do
681
681
 
682
682
  context "platform is windows" do
683
683
  before do
684
- allow(ChefConfig).to receive(:windows?).and_return(true)
684
+ allow(ChefUtils).to receive(:windows?).and_return(true)
685
685
  end
686
686
 
687
687
  it "should be called" do
@@ -18,32 +18,52 @@
18
18
  require "spec_helper"
19
19
 
20
20
  describe Chef::Cookbook::Chefignore do
21
- before do
22
- @chefignore = Chef::Cookbook::Chefignore.new(File.join(CHEF_SPEC_DATA, "cookbooks"))
23
- end
21
+ let(:chefignore) { described_class.new(File.join(CHEF_SPEC_DATA, "cookbooks")) }
24
22
 
25
23
  it "loads the globs in the chefignore file" do
26
- expect(@chefignore.ignores).to match_array(%w{recipes/ignoreme.rb ignored})
24
+ expect(chefignore.ignores).to match_array(%w{recipes/ignoreme.rb ignored})
27
25
  end
28
26
 
29
27
  it "removes items from an array that match the ignores" do
30
28
  file_list = %w{ recipes/ignoreme.rb recipes/dontignoreme.rb }
31
- expect(@chefignore.remove_ignores_from(file_list)).to eq(%w{recipes/dontignoreme.rb})
29
+ expect(chefignore.remove_ignores_from(file_list)).to eq(%w{recipes/dontignoreme.rb})
32
30
  end
33
31
 
34
32
  it "determines if a file is ignored" do
35
- expect(@chefignore.ignored?("ignored")).to be_truthy
36
- expect(@chefignore.ignored?("recipes/ignoreme.rb")).to be_truthy
37
- expect(@chefignore.ignored?("recipes/dontignoreme.rb")).to be_falsey
33
+ expect(chefignore.ignored?("ignored")).to be_truthy
34
+ expect(chefignore.ignored?("recipes/ignoreme.rb")).to be_truthy
35
+ expect(chefignore.ignored?("recipes/dontignoreme.rb")).to be_falsey
38
36
  end
39
37
 
40
38
  context "when using the single cookbook pattern" do
41
- before do
42
- @chefignore = Chef::Cookbook::Chefignore.new(File.join(CHEF_SPEC_DATA, "standalone_cookbook"))
39
+ let(:chefignore) { described_class.new(File.join(CHEF_SPEC_DATA, "cookbooks/starter")) }
40
+
41
+ it "loads the globs in the chefignore file" do
42
+ expect(chefignore.ignores).to match_array(%w{recipes/default.rb ignored})
43
+ end
44
+ end
45
+
46
+ context "when cookbook has it's own chefignore" do
47
+ let(:chefignore) { described_class.new(File.join(CHEF_SPEC_DATA, "cookbooks/starter")) }
48
+
49
+ it "loads the globs in the chefignore file" do
50
+ expect(chefignore.ignores).to match_array(%w{recipes/default.rb ignored})
43
51
  end
52
+ end
53
+
54
+ context "when cookbook don't have own chefignore" do
55
+ let(:chefignore) { described_class.new(File.join(CHEF_SPEC_DATA, "cookbooks/apache2")) }
56
+
57
+ it "loads the globs in the chefignore file of cookbooks dir" do
58
+ expect(chefignore.ignores).to match_array(%w{recipes/ignoreme.rb ignored})
59
+ end
60
+ end
61
+
62
+ context "when using the single cookbook pattern" do
63
+ let(:chefignore) { described_class.new(File.join(CHEF_SPEC_DATA, "standalone_cookbook")) }
44
64
 
45
65
  it "loads the globs in the chefignore file" do
46
- expect(@chefignore.ignores).to match_array(%w{recipes/ignoreme.rb ignored vendor/bundle/*})
66
+ expect(chefignore.ignores).to match_array(%w{recipes/ignoreme.rb ignored vendor/bundle/*})
47
67
  end
48
68
  end
49
69
  end