chef 16.2.73-universal-mingw32 → 16.3.38-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/Rakefile +1 -1
  4. data/chef-universal-mingw32.gemspec +2 -2
  5. data/chef.gemspec +2 -1
  6. data/lib/chef/application.rb +12 -0
  7. data/lib/chef/{whitelist.rb → attribute_allowlist.rb} +11 -11
  8. data/lib/chef/{blacklist.rb → attribute_blocklist.rb} +9 -9
  9. data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +1 -2
  10. data/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb +1 -5
  11. data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -0
  12. data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +1 -1
  13. data/lib/chef/client.rb +3 -3
  14. data/lib/chef/cookbook/remote_file_vendor.rb +1 -3
  15. data/lib/chef/cookbook/syntax_check.rb +1 -2
  16. data/lib/chef/cookbook_loader.rb +15 -29
  17. data/lib/chef/data_bag.rb +1 -2
  18. data/lib/chef/deprecated.rb +8 -0
  19. data/lib/chef/dsl/platform_introspection.rb +2 -0
  20. data/lib/chef/environment.rb +1 -2
  21. data/lib/chef/exceptions.rb +3 -0
  22. data/lib/chef/http/authenticator.rb +1 -1
  23. data/lib/chef/knife.rb +4 -4
  24. data/lib/chef/knife/bootstrap.rb +4 -10
  25. data/lib/chef/knife/bootstrap/train_connector.rb +1 -0
  26. data/lib/chef/knife/config_get.rb +1 -0
  27. data/lib/chef/knife/config_list_profiles.rb +4 -1
  28. data/lib/chef/knife/configure.rb +1 -1
  29. data/lib/chef/knife/cookbook_upload.rb +5 -10
  30. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  31. data/lib/chef/knife/core/hashed_command_loader.rb +1 -0
  32. data/lib/chef/knife/core/subcommand_loader.rb +20 -1
  33. data/lib/chef/knife/core/ui.rb +8 -2
  34. data/lib/chef/knife/core/windows_bootstrap_context.rb +1 -2
  35. data/lib/chef/knife/rehash.rb +3 -21
  36. data/lib/chef/knife/ssh.rb +5 -1
  37. data/lib/chef/log.rb +7 -2
  38. data/lib/chef/mixin/chef_utils_wiring.rb +40 -0
  39. data/{spec/unit/log_spec.rb → lib/chef/mixin/default_paths.rb} +13 -5
  40. data/lib/chef/mixin/openssl_helper.rb +27 -5
  41. data/lib/chef/mixin/path_sanity.rb +5 -4
  42. data/lib/chef/mixin/shell_out.rb +4 -188
  43. data/lib/chef/mixin/template.rb +1 -0
  44. data/lib/chef/mixin/which.rb +6 -3
  45. data/lib/chef/mixins.rb +1 -0
  46. data/lib/chef/node.rb +36 -12
  47. data/lib/chef/node_map.rb +21 -18
  48. data/lib/chef/platform/service_helpers.rb +31 -28
  49. data/lib/chef/provider/git.rb +12 -4
  50. data/lib/chef/provider/mount/solaris.rb +0 -1
  51. data/lib/chef/provider/package/snap.rb +2 -3
  52. data/lib/chef/provider/package/windows.rb +9 -4
  53. data/lib/chef/provider/package/zypper.rb +0 -1
  54. data/lib/chef/provider/service.rb +2 -2
  55. data/lib/chef/provider/yum_repository.rb +1 -1
  56. data/lib/chef/provider/zypper_repository.rb +1 -1
  57. data/lib/chef/resource.rb +2 -0
  58. data/lib/chef/resource/build_essential.rb +2 -2
  59. data/lib/chef/resource/chef_client_scheduled_task.rb +1 -1
  60. data/lib/chef/resource/chocolatey_feature.rb +1 -2
  61. data/lib/chef/resource/cron/cron_d.rb +1 -1
  62. data/lib/chef/resource/cron_access.rb +2 -2
  63. data/lib/chef/resource/execute.rb +2 -2
  64. data/lib/chef/resource/lwrp_base.rb +1 -0
  65. data/lib/chef/resource/macos_userdefaults.rb +176 -61
  66. data/lib/chef/resource/openssl_x509_certificate.rb +11 -14
  67. data/lib/chef/resource/openssl_x509_crl.rb +1 -2
  68. data/lib/chef/resource/service.rb +2 -2
  69. data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
  70. data/lib/chef/resource/sudo.rb +1 -1
  71. data/lib/chef/resource/user_ulimit.rb +1 -1
  72. data/lib/chef/resource/windows_dns_record.rb +17 -0
  73. data/lib/chef/resource/windows_firewall_profile.rb +197 -0
  74. data/lib/chef/resource/windows_security_policy.rb +49 -20
  75. data/lib/chef/resource_inspector.rb +7 -1
  76. data/lib/chef/resources.rb +1 -0
  77. data/lib/chef/role.rb +1 -2
  78. data/lib/chef/shell/shell_session.rb +2 -0
  79. data/lib/chef/util/diff.rb +0 -1
  80. data/lib/chef/version.rb +2 -2
  81. data/lib/chef/win32/registry.rb +1 -2
  82. data/spec/functional/knife/ssh_spec.rb +5 -16
  83. data/spec/functional/resource/aix_service_spec.rb +0 -2
  84. data/spec/functional/resource/aixinit_service_spec.rb +0 -1
  85. data/spec/functional/resource/apt_package_spec.rb +0 -1
  86. data/spec/functional/resource/cron_spec.rb +0 -1
  87. data/spec/functional/resource/git_spec.rb +23 -1
  88. data/spec/functional/resource/group_spec.rb +6 -2
  89. data/spec/functional/resource/insserv_spec.rb +0 -1
  90. data/spec/functional/resource/remote_file_spec.rb +1 -7
  91. data/spec/functional/resource/windows_user_privilege_spec.rb +1 -1
  92. data/spec/functional/run_lock_spec.rb +2 -1
  93. data/spec/functional/shell_spec.rb +5 -5
  94. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  95. data/spec/functional/version_spec.rb +1 -1
  96. data/spec/integration/knife/config_list_profiles_spec.rb +30 -2
  97. data/spec/integration/knife/cookbook_upload_spec.rb +27 -0
  98. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  99. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  100. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  101. data/spec/integration/recipes/notifies_spec.rb +1 -1
  102. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  103. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
  104. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +2 -0
  105. data/spec/integration/recipes/resource_load_spec.rb +2 -0
  106. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  107. data/spec/integration/recipes/use_partial_spec.rb +1 -1
  108. data/spec/scripts/ssl-serve.rb +1 -1
  109. data/spec/spec_helper.rb +10 -4
  110. data/spec/support/chef_helpers.rb +1 -20
  111. data/spec/support/platform_helpers.rb +0 -2
  112. data/spec/support/shared/functional/file_resource.rb +0 -1
  113. data/spec/support/shared/integration/knife_support.rb +2 -9
  114. data/spec/support/shared/unit/application_dot_d.rb +0 -1
  115. data/spec/unit/application_spec.rb +4 -2
  116. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +2 -4
  117. data/spec/unit/chef_fs/{parallelizer.rb → parallelizer_spec.rb} +1 -1
  118. data/spec/unit/cookbook/gem_installer_spec.rb +2 -1
  119. data/spec/unit/data_collector_spec.rb +1 -1
  120. data/spec/unit/dsl/platform_introspection_spec.rb +1 -0
  121. data/spec/unit/event_dispatch/dispatcher_spec.rb +3 -0
  122. data/spec/unit/json_compat_spec.rb +1 -1
  123. data/spec/unit/knife/bootstrap_spec.rb +2 -6
  124. data/spec/unit/knife/cookbook_upload_spec.rb +7 -10
  125. data/spec/unit/log/syslog_spec.rb +6 -10
  126. data/spec/unit/log/winevt_spec.rb +21 -13
  127. data/spec/unit/lwrp_spec.rb +4 -4
  128. data/spec/unit/mixin/{path_sanity_spec.rb → default_paths_spec.rb} +14 -14
  129. data/spec/unit/mixin/powershell_exec_spec.rb +1 -1
  130. data/spec/unit/mixin/securable_spec.rb +0 -1
  131. data/spec/unit/mixin/shell_out_spec.rb +25 -26
  132. data/spec/unit/mixin/which.rb +8 -0
  133. data/spec/unit/node_spec.rb +98 -11
  134. data/spec/unit/property_spec.rb +5 -5
  135. data/spec/unit/provider/execute_spec.rb +0 -7
  136. data/spec/unit/provider/ifconfig_spec.rb +0 -1
  137. data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
  138. data/spec/unit/provider/package/rubygems_spec.rb +5 -10
  139. data/spec/unit/provider/package/smartos_spec.rb +1 -1
  140. data/spec/unit/provider/package/windows_spec.rb +30 -53
  141. data/spec/unit/provider/service/redhat_spec.rb +1 -1
  142. data/spec/unit/provider/service/windows_spec.rb +2 -6
  143. data/spec/unit/provider/systemd_unit_spec.rb +28 -24
  144. data/spec/unit/provider_spec.rb +1 -0
  145. data/spec/unit/resource/execute_spec.rb +10 -0
  146. data/spec/unit/resource/macos_user_defaults_spec.rb +103 -2
  147. data/spec/unit/resource/windows_firewall_profile_spec.rb +77 -0
  148. data/spec/unit/resource/windows_package_spec.rb +1 -0
  149. data/spec/unit/resource_reporter_spec.rb +1 -1
  150. data/spec/unit/run_context/cookbook_compiler_spec.rb +1 -1
  151. data/spec/unit/run_lock_spec.rb +1 -1
  152. data/spec/unit/scan_access_control_spec.rb +1 -1
  153. data/spec/unit/util/diff_spec.rb +1 -15
  154. data/spec/unit/win32/security_spec.rb +4 -3
  155. metadata +38 -15
@@ -133,7 +133,7 @@ class Chef
133
133
  def to_h
134
134
  env_run_lists_without_default = @env_run_lists.dup
135
135
  env_run_lists_without_default.delete("_default")
136
- result = {
136
+ {
137
137
  "name" => @name,
138
138
  "description" => @description,
139
139
  "json_class" => self.class.name,
@@ -149,7 +149,6 @@ class Chef
149
149
  accumulator
150
150
  end,
151
151
  }
152
- result
153
152
  end
154
153
 
155
154
  alias_method :to_hash, :to_h
@@ -41,6 +41,7 @@ module Shell
41
41
 
42
42
  attr_accessor :node, :compile, :recipe, :json_configuration
43
43
  attr_reader :node_attributes, :client
44
+
44
45
  def initialize
45
46
  @node_built = false
46
47
  formatter = Chef::Formatters.new(Chef::Config.formatter, STDOUT, STDERR)
@@ -75,6 +76,7 @@ module Shell
75
76
  end
76
77
 
77
78
  attr_writer :run_context
79
+
78
80
  def run_context
79
81
  @run_context ||= rebuild_context
80
82
  end
@@ -48,7 +48,6 @@ class Chef
48
48
  class Diff
49
49
  # @todo: to_a, to_s, to_json, inspect defs, accessors for @diff and @error
50
50
  # @todo: move coercion to UTF-8 into to_json
51
- # @todo: replace shellout to diff -u with diff-lcs gem
52
51
 
53
52
  def for_output
54
53
  # formatted output to a terminal uses arrays of strings and returns error strings
@@ -22,8 +22,8 @@
22
22
  require_relative "version_string"
23
23
 
24
24
  class Chef
25
- CHEF_ROOT = File.expand_path("../..", __FILE__)
26
- VERSION = Chef::VersionString.new("16.2.73")
25
+ CHEF_ROOT = File.expand_path("..", __dir__)
26
+ VERSION = Chef::VersionString.new("16.3.38")
27
27
  end
28
28
 
29
29
  #
@@ -341,7 +341,7 @@ class Chef
341
341
  end
342
342
 
343
343
  def get_type_from_num(val_type)
344
- value = {
344
+ {
345
345
  3 => ::Win32::Registry::REG_BINARY,
346
346
  1 => ::Win32::Registry::REG_SZ,
347
347
  7 => ::Win32::Registry::REG_MULTI_SZ,
@@ -350,7 +350,6 @@ class Chef
350
350
  5 => ::Win32::Registry::REG_DWORD_BIG_ENDIAN,
351
351
  11 => ::Win32::Registry::REG_QWORD,
352
352
  }[val_type]
353
- value
354
353
  end
355
354
 
356
355
  def create_missing(key_path)
@@ -36,17 +36,6 @@ describe Chef::Knife::Ssh do
36
36
  allow(Net::SSH).to receive(:configuration_for).and_return(ssh_config)
37
37
  end
38
38
 
39
- # Force log level to info.
40
- around do |ex|
41
- old_level = Chef::Log.level
42
- begin
43
- Chef::Log.level = :info
44
- ex.run
45
- ensure
46
- Chef::Log.level = old_level
47
- end
48
- end
49
-
50
39
  describe "identity file" do
51
40
  context "when knife[:ssh_identity_file] is set" do
52
41
  before do
@@ -278,7 +267,7 @@ describe Chef::Knife::Ssh do
278
267
  end
279
268
 
280
269
  it "uses the ssh_gateway" do
281
- expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", {})
270
+ expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { append_all_supported_algorithms: true })
282
271
  @knife.run
283
272
  expect(@knife.config[:ssh_gateway]).to eq("user@ec2.public_hostname")
284
273
  end
@@ -291,7 +280,7 @@ describe Chef::Knife::Ssh do
291
280
  end
292
281
 
293
282
  it "uses the ssh_gateway" do
294
- expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", {})
283
+ expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { append_all_supported_algorithms: true })
295
284
  @knife.run
296
285
  expect(@knife.config[:ssh_gateway]).to eq("user@ec2.public_hostname")
297
286
  end
@@ -305,7 +294,7 @@ describe Chef::Knife::Ssh do
305
294
  end
306
295
 
307
296
  it "uses the ssh_gateway_identity file" do
308
- expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV["HOME"]}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true })
297
+ expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { append_all_supported_algorithms: true, keys: File.expand_path("#{ENV["HOME"]}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true })
309
298
  @knife.run
310
299
  expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa")
311
300
  end
@@ -319,7 +308,7 @@ describe Chef::Knife::Ssh do
319
308
  end
320
309
 
321
310
  it "uses the ssh_gateway_identity file" do
322
- expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { keys: File.expand_path("#{ENV["HOME"]}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true })
311
+ expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", { append_all_supported_algorithms: true, keys: File.expand_path("#{ENV["HOME"]}/.ssh/aws-gateway.rsa").squeeze("/"), keys_only: true })
323
312
  @knife.run
324
313
  expect(@knife.config[:ssh_gateway_identity]).to eq("~/.ssh/aws-gateway.rsa")
325
314
  end
@@ -335,7 +324,7 @@ describe Chef::Knife::Ssh do
335
324
  end
336
325
 
337
326
  it "should prompt the user for a password" do
338
- expect(@knife.ui).to receive(:ask).with("Enter the password for user@ec2.public_hostname: ").and_return("password")
327
+ expect(@knife.ui).to receive(:ask).with("Enter the password for user@ec2.public_hostname: ", echo: false).and_return("password")
339
328
  @knife.run
340
329
  end
341
330
  end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  #
3
2
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
4
3
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -88,7 +87,6 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
88
87
  Chef::RunContext.new(node, {}, events)
89
88
  end
90
89
 
91
-
92
90
  describe "When service is a subsystem" do
93
91
  before(:all) do
94
92
  script_dir = File.join(File.dirname(__FILE__), "/../assets/")
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  #
3
2
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
4
3
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  #
3
2
  # Author:: Daniel DeLeo (<dan@chef.io>)
4
3
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  #
3
2
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
4
3
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -20,7 +20,7 @@ require "spec_helper"
20
20
  require "tmpdir"
21
21
 
22
22
  # Deploy relies heavily on symlinks, so it doesn't work on windows.
23
- describe Chef::Resource::Git, requires_git: true do
23
+ describe Chef::Resource::Git do
24
24
  include RecipeDSLHelper
25
25
 
26
26
  # Some versions of git complains when the deploy directory is
@@ -239,6 +239,28 @@ describe Chef::Resource::Git, requires_git: true do
239
239
  end
240
240
  end
241
241
 
242
+ context "when updating a branch that's already checked out out" do
243
+ it "checks out master, commits to the repo, and checks out the latest changes" do
244
+ git deploy_directory do
245
+ repository origin_repo
246
+ revision "master"
247
+ action :sync
248
+ end.should_be_updated
249
+
250
+ # We don't have a way to test a commit in the git bundle
251
+ # Revert to a previous commit in the same branch and make sure we can still sync.
252
+ shell_out!("git", "reset", "--hard", rev_foo, cwd: deploy_directory)
253
+
254
+ git deploy_directory do
255
+ repository origin_repo
256
+ revision "master"
257
+ action :sync
258
+ end.should_be_updated
259
+ expect_revision_to_be("HEAD", rev_head)
260
+ expect_branch_to_be("master")
261
+ end
262
+ end
263
+
242
264
  context "when dealing with a repo with a degenerate tag named 'HEAD'" do
243
265
  before do
244
266
  shell_out!("git", "tag", "-m\"degenerate tag\"", "HEAD", "ed181b3419b6f489bedab282348162a110d6d3a1", cwd: origin_repo)
@@ -159,8 +159,10 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
159
159
  # excluded_members can only be used when append is set. It is ignored otherwise.
160
160
  let(:excluded_members) { [] }
161
161
 
162
+ let(:expected_error_class) { windows? ? ArgumentError : Mixlib::ShellOut::ShellCommandFailed }
163
+
162
164
  it "should raise an error" do
163
- expect { group_resource.run_action(tested_action) }.to raise_error
165
+ expect { group_resource.run_action(tested_action) }.to raise_error(expected_error_class)
164
166
  end
165
167
  end
166
168
 
@@ -169,8 +171,10 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
169
171
  group_resource.append(true)
170
172
  end
171
173
 
174
+ let(:expected_error_class) { windows? ? Chef::Exceptions::Win32APIError : Mixlib::ShellOut::ShellCommandFailed }
175
+
172
176
  it "should raise an error" do
173
- expect { group_resource.run_action(tested_action) }.to raise_error
177
+ expect { group_resource.run_action(tested_action) }.to raise_error(expected_error_class)
174
178
  end
175
179
  end
176
180
  end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  #
3
2
  # Author:: Dheeraj Dubey (<dheeraj.dubey@msystechnologies.com>)
4
3
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -409,13 +409,7 @@ describe Chef::Resource::RemoteFile do
409
409
  it "should not create the file" do
410
410
  # This can legitimately raise either Errno::EADDRNOTAVAIL or Errno::ECONNREFUSED
411
411
  # in different Ruby versions.
412
- old_value = RSpec::Expectations.configuration.on_potential_false_positives
413
- RSpec::Expectations.configuration.on_potential_false_positives = :nothing
414
- begin
415
- expect { resource.run_action(:create) }.to raise_error
416
- ensure
417
- RSpec::Expectations.configuration.on_potential_false_positives = old_value
418
- end
412
+ expect { resource.run_action(:create) }.to raise_error(SystemCallError)
419
413
 
420
414
  expect(File).not_to exist(path)
421
415
  end
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require_relative "../../spec_helper"
18
+ require "spec_helper"
19
19
 
20
20
  describe Chef::Resource::WindowsUserPrivilege, :windows_only do
21
21
  let(:principal) { nil }
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require_relative "../spec_helper"
18
+ require "spec_helper"
19
19
  require "chef/client"
20
20
 
21
21
  describe Chef::RunLock do
@@ -435,6 +435,7 @@ describe Chef::RunLock do
435
435
 
436
436
  class TestRunLock < Chef::RunLock
437
437
  attr_accessor :client_process
438
+
438
439
  def create_lock
439
440
  super
440
441
  client_process.fire_event("created lock")
@@ -97,13 +97,13 @@ describe Shell do
97
97
  [output, e.status]
98
98
  end
99
99
 
100
- it "boots correctly with -lauto" do
100
+ it "boots correctly with -lauto", :executables do
101
101
  output, exitstatus = run_chef_shell_with("-lauto")
102
102
  expect(output).to include("done")
103
103
  expect(exitstatus).to eq(0)
104
104
  end
105
105
 
106
- it "sets the log_level from the command line" do
106
+ it "sets the log_level from the command line", :executables do
107
107
  output, exitstatus = run_chef_shell_with("-lfatal") do |out, keyboard|
108
108
  show_log_level_code = %q[puts "===#{Chef::Log.level}==="]
109
109
  keyboard.puts(show_log_level_code)
@@ -114,13 +114,13 @@ describe Shell do
114
114
  end
115
115
 
116
116
  context "on solo mode" do
117
- it "starts correctly" do
117
+ it "starts correctly", :executables do
118
118
  output, exitstatus = run_chef_shell_with("--solo")
119
119
  expect(output).to include("done")
120
120
  expect(exitstatus).to eq(0)
121
121
  end
122
122
 
123
- it "should be able to use the API" do
123
+ it "should be able to use the API", :executables do
124
124
  output, exitstatus = run_chef_shell_with("-s") do |out, keyboard|
125
125
  simple_api_get = "api.get('data')"
126
126
  keyboard.puts(simple_api_get)
@@ -131,7 +131,7 @@ describe Shell do
131
131
  end
132
132
  end
133
133
 
134
- it "sets the override_runlist from the command line" do
134
+ it "sets the override_runlist from the command line", :executables do
135
135
  output, exitstatus = run_chef_shell_with("-o 'override::foo,override::bar'") do |out, keyboard|
136
136
  show_recipes_code = %q[puts "#{node["recipes"].inspect}"]
137
137
  keyboard.puts(show_recipes_code)
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require "chef/json_compat"
20
- require_relative "../../../spec_helper"
20
+ require "spec_helper"
21
21
 
22
22
  describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
23
23
  before(:all) do
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require_relative "../spec_helper"
18
+ require "spec_helper"
19
19
  require "chef/mixin/shell_out"
20
20
  require "chef/version"
21
21
  require "ohai/version"
@@ -26,8 +26,9 @@ describe "knife config list-profiles", :workstation do
26
26
 
27
27
  let(:cmd_args) { [] }
28
28
  let(:knife_list_profiles) do
29
- knife("config", "list-profiles", *cmd_args, instance_filter: proc {
30
- # Clear the stub set up in KnifeSupport.
29
+ knife("config", "list-profiles", *cmd_args, instance_filter: lambda { |instance|
30
+ # Fake the failsafe check because this command doesn't actually process knife.rb.
31
+ $__KNIFE_INTEGRATION_FAILSAFE_CHECK << " ole"
31
32
  allow(File).to receive(:file?).and_call_original
32
33
  })
33
34
  end
@@ -140,6 +141,33 @@ describe "knife config list-profiles", :workstation do
140
141
  EOH
141
142
  end
142
143
 
144
+ context "with a bad profile as an active profile" do
145
+ let(:cmd_args) { %w{--profile production} }
146
+ before { file(".chef/credentials", <<~EOH) }
147
+ [default]
148
+ client_name = "testuser"
149
+ client_key = "testkey.pem"
150
+ chef_server_url = "https://example.com/organizations/testorg"
151
+
152
+ [prod]
153
+ client_name = "testuser"
154
+ client_key = "testkey.pem"
155
+ chef_server_url = "https://example.com/organizations/prod"
156
+
157
+ [qa]
158
+ client_name = "qauser"
159
+ client_key = "~/src/qauser.pem"
160
+ chef_server_url = "https://example.com/organizations/testorg"
161
+ EOH
162
+ it { is_expected.to eq <<~EOH.delete("#") }
163
+ Profile Client Key Server #
164
+ ---------------------------------------------------------------------------------#
165
+ default testuser ~/.chef/testkey.pem https://example.com/organizations/testorg#
166
+ prod testuser ~/.chef/testkey.pem https://example.com/organizations/prod #
167
+ qa qauser ~/src/qauser.pem https://example.com/organizations/testorg#
168
+ EOH
169
+ end
170
+
143
171
  context "with a minimal profile" do
144
172
  before { file(".chef/credentials", <<~EOH) }
145
173
  [default]
@@ -97,5 +97,32 @@ describe "knife cookbook upload", :workstation do
97
97
  expect { knife("cookbook upload x -o #{cb_dir}") }.to raise_error(Chef::Exceptions::MetadataNotValid)
98
98
  end
99
99
  end
100
+
101
+ when_the_repository "has cookbooks at multiple paths" do
102
+
103
+ let(:cb_dir_first) do
104
+ File.join(@repository_dir, "cookbooks")
105
+ .gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)
106
+ end
107
+
108
+ let(:cb_dir_second) do
109
+ File.join(@repository_dir, "test_cookbooks")
110
+ .gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)
111
+ end
112
+
113
+ before(:each) do
114
+ file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0")
115
+ file "test_cookbooks/y/metadata.rb", cb_metadata("y", "1.0.0")
116
+ end
117
+
118
+ it "knife cookbook upload with -o or --cookbook-path" do
119
+ knife("cookbook upload x y -o #{cb_dir_first}#{File::PATH_SEPARATOR}#{cb_dir_second}").should_succeed stderr: <<~EOM
120
+ Uploading x [1.0.0]
121
+ Uploading y [1.0.0]
122
+ Uploaded 2 cookbooks.
123
+ EOM
124
+ end
125
+
126
+ end
100
127
  end
101
128
  end
@@ -6,7 +6,7 @@ describe "Accumulators" do
6
6
  include IntegrationSupport
7
7
  include Chef::Mixin::ShellOut
8
8
 
9
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
9
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
10
10
 
11
11
  # Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
12
12
  # following constraints are satisfied:
@@ -6,7 +6,7 @@ describe "LWRPs with inline resources" do
6
6
  include IntegrationSupport
7
7
  include Chef::Mixin::ShellOut
8
8
 
9
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
9
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
10
10
 
11
11
  # Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
12
12
  # following constraints are satisfied:
@@ -6,7 +6,7 @@ describe "LWRPs" do
6
6
  include IntegrationSupport
7
7
  include Chef::Mixin::ShellOut
8
8
 
9
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
9
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
10
10
 
11
11
  # Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
12
12
  # following constraints are satisfied:
@@ -22,7 +22,7 @@ describe "notifications" do
22
22
  include IntegrationSupport
23
23
  include Chef::Mixin::ShellOut
24
24
 
25
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
25
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
26
26
  let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
27
27
 
28
28
  when_the_repository "notifies a nameless resource" do