chef 15.4.45 → 15.5.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -3
- data/Rakefile +5 -3
- data/chef.gemspec +2 -1
- data/lib/chef/application.rb +2 -2
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/knife.rb +1 -0
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/chef_class.rb +1 -6
- data/lib/chef/chef_fs.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +7 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +4 -3
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +3 -3
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -3
- data/lib/chef/chef_fs/knife.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +2 -2
- data/lib/chef/client.rb +4 -5
- data/lib/chef/config.rb +3 -2
- data/lib/chef/cookbook/chefignore.rb +16 -11
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/syntax_check.rb +5 -3
- data/lib/chef/cookbook_loader.rb +3 -3
- data/lib/chef/cookbook_uploader.rb +1 -1
- data/lib/chef/data_collector.rb +2 -2
- data/lib/chef/data_collector/run_end_message.rb +1 -0
- data/lib/chef/deprecated.rb +4 -0
- data/lib/chef/dsl/core.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +9 -18
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/file_content_management/deploy.rb +3 -3
- data/lib/chef/file_content_management/deploy/mv_windows.rb +2 -2
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +2 -2
- data/lib/chef/http.rb +1 -1
- data/lib/chef/http/socketless_chef_zero_client.rb +1 -1
- data/lib/chef/knife.rb +4 -3
- data/lib/chef/knife/config_get.rb +2 -1
- data/lib/chef/knife/configure.rb +1 -1
- data/lib/chef/knife/cookbook_metadata_from_file.rb +6 -0
- data/lib/chef/knife/core/generic_presenter.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/ssh.rb +6 -0
- data/lib/chef/local_mode.rb +1 -1
- data/lib/chef/mash.rb +21 -232
- data/lib/chef/mixin/file_class.rb +2 -2
- data/lib/chef/mixin/lazy_module_include.rb +1 -1
- data/lib/chef/mixin/path_sanity.rb +3 -39
- data/lib/chef/mixin/securable.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +4 -5
- data/lib/chef/mixin/template.rb +1 -1
- data/lib/chef/mixin/user_context.rb +3 -3
- data/lib/chef/mixin/which.rb +10 -38
- data/lib/chef/mixin/windows_architecture_helper.rb +6 -6
- data/lib/chef/mixin/windows_env_helper.rb +5 -5
- data/lib/chef/node/attribute.rb +2 -2
- data/lib/chef/node_map.rb +17 -4
- data/lib/chef/platform/query_helpers.rb +4 -2
- data/lib/chef/platform/rebooter.rb +1 -1
- data/lib/chef/platform/service_helpers.rb +14 -85
- data/lib/chef/provider.rb +2 -0
- data/lib/chef/provider/file.rb +2 -2
- data/lib/chef/provider/ifconfig/redhat.rb +1 -1
- data/lib/chef/provider/link.rb +3 -3
- data/lib/chef/provider/mount/solaris.rb +1 -1
- data/lib/chef/provider/package/yum.rb +1 -1
- data/lib/chef/provider/registry_key.rb +1 -1
- data/lib/chef/provider/remote_directory.rb +3 -3
- data/lib/chef/provider/remote_file/fetcher.rb +2 -2
- data/lib/chef/provider/remote_file/local_file.rb +1 -1
- data/lib/chef/provider/script.rb +3 -3
- data/lib/chef/provider/service.rb +5 -2
- data/lib/chef/provider/service/arch.rb +1 -1
- data/lib/chef/provider/service/debian.rb +4 -4
- data/lib/chef/provider/service/init.rb +1 -1
- data/lib/chef/provider/service/insserv.rb +4 -4
- data/lib/chef/provider/service/invokercd.rb +4 -4
- data/lib/chef/provider/service/redhat.rb +4 -4
- data/lib/chef/provider/service/systemd.rb +19 -3
- data/lib/chef/provider/service/upstart.rb +3 -3
- data/lib/chef/provider/subversion.rb +1 -1
- data/lib/chef/provider/systemd_unit.rb +26 -2
- data/lib/chef/provider/windows_path.rb +3 -3
- data/lib/chef/provider/windows_task.rb +4 -4
- data/lib/chef/resource.rb +1 -0
- data/lib/chef/resource/bash.rb +2 -0
- data/lib/chef/resource/batch.rb +2 -0
- data/lib/chef/resource/breakpoint.rb +3 -1
- data/lib/chef/resource/build_essential.rb +3 -3
- data/lib/chef/resource/chef_sleep.rb +70 -0
- data/lib/chef/resource/cookbook_file.rb +2 -1
- data/lib/chef/resource/csh.rb +2 -0
- data/lib/chef/resource/directory.rb +2 -0
- data/lib/chef/resource/dmg_package.rb +1 -1
- data/lib/chef/resource/dnf_package.rb +1 -1
- data/lib/chef/resource/execute.rb +2 -0
- data/lib/chef/resource/file.rb +2 -1
- data/lib/chef/resource/git.rb +2 -0
- data/lib/chef/resource/group.rb +1 -1
- data/lib/chef/resource/homebrew_package.rb +1 -1
- data/lib/chef/resource/http_request.rb +2 -0
- data/lib/chef/resource/ifconfig.rb +3 -1
- data/lib/chef/resource/ksh.rb +2 -0
- data/lib/chef/resource/link.rb +4 -2
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/log.rb +2 -0
- data/lib/chef/resource/ohai.rb +2 -0
- data/lib/chef/resource/perl.rb +2 -0
- data/lib/chef/resource/python.rb +2 -0
- data/lib/chef/resource/reboot.rb +2 -0
- data/lib/chef/resource/registry_key.rb +2 -0
- data/lib/chef/resource/remote_directory.rb +3 -2
- data/lib/chef/resource/remote_file.rb +1 -0
- data/lib/chef/resource/ruby.rb +2 -0
- data/lib/chef/resource/ruby_block.rb +2 -0
- data/lib/chef/resource/scm.rb +2 -0
- data/lib/chef/resource/script.rb +2 -0
- data/lib/chef/resource/service.rb +9 -1
- data/lib/chef/resource/solaris_package.rb +1 -1
- data/lib/chef/resource/subversion.rb +2 -0
- data/lib/chef/resource/sudo.rb +1 -1
- data/lib/chef/resource/systemd_unit.rb +1 -0
- data/lib/chef/resource/template.rb +2 -0
- data/lib/chef/resource/user.rb +2 -0
- data/lib/chef/resource/user/aix_user.rb +2 -0
- data/lib/chef/resource/user/linux_user.rb +2 -0
- data/lib/chef/resource/user/pw_user.rb +2 -0
- data/lib/chef/resource/user/solaris_user.rb +2 -0
- data/lib/chef/resource/user/windows_user.rb +2 -0
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
- data/lib/chef/resource/windows_ad_join.rb +1 -1
- data/lib/chef/resource/windows_env.rb +1 -1
- data/lib/chef/resource/windows_feature.rb +2 -2
- data/lib/chef/resource/windows_feature_powershell.rb +1 -1
- data/lib/chef/resource/windows_firewall_rule.rb +11 -6
- data/lib/chef/resource/windows_script.rb +3 -1
- data/lib/chef/resource/yum_package.rb +1 -1
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/run_context.rb +1 -1
- data/lib/chef/run_lock.rb +5 -5
- data/lib/chef/search/query.rb +0 -3
- data/lib/chef/train_transport.rb +3 -1
- data/lib/chef/util/powershell/ps_credential.rb +2 -2
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/util/windows/logon_session.rb +2 -2
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/eventlog.rb +2 -2
- data/spec/data/cookbooks/starter/chefignore +8 -0
- data/spec/data/cookbooks/starter/files/sample.txt +1 -0
- data/spec/data/cookbooks/starter/metadata.rb +2 -0
- data/spec/data/cookbooks/starter/recipes/default.rb +4 -0
- data/spec/functional/event_loggers/windows_eventlog_spec.rb +1 -1
- data/spec/functional/mixin/user_context_spec.rb +2 -2
- data/spec/functional/rebooter_spec.rb +1 -1
- data/spec/functional/resource/cookbook_file_spec.rb +2 -2
- data/spec/functional/resource/template_spec.rb +1 -1
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/crypto_spec.rb +1 -1
- data/spec/functional/win32/security_spec.rb +1 -1
- data/spec/functional/win32/service_manager_spec.rb +1 -1
- data/spec/functional/win32/sid_spec.rb +2 -2
- data/spec/functional/win32/version_info_spec.rb +1 -1
- data/spec/functional/win32/versions_spec.rb +1 -1
- data/spec/integration/knife/config_get_profile_spec.rb +2 -2
- data/spec/integration/knife/config_get_spec.rb +9 -2
- data/spec/integration/knife/config_list_profiles_spec.rb +2 -2
- data/spec/integration/knife/config_use_profile_spec.rb +2 -2
- data/spec/integration/knife/list_spec.rb +2 -2
- data/spec/integration/solo/solo_spec.rb +1 -1
- data/spec/support/matchers/leak.rb +1 -1
- data/spec/support/mock/platform.rb +1 -1
- data/spec/support/platform_helpers.rb +2 -0
- data/spec/support/shared/integration/integration_helper.rb +1 -1
- data/spec/support/shared/integration/knife_support.rb +1 -1
- data/spec/support/shared/unit/provider/file.rb +4 -4
- data/spec/unit/application/client_spec.rb +2 -2
- data/spec/unit/application/knife_spec.rb +17 -0
- data/spec/unit/application_spec.rb +1 -1
- data/spec/unit/chef_fs/file_pattern_spec.rb +2 -2
- data/spec/unit/chef_fs/path_util_spec.rb +3 -3
- data/spec/unit/client_spec.rb +2 -2
- data/spec/unit/cookbook/chefignore_spec.rb +31 -11
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +1 -1
- data/spec/unit/cookbook/syntax_check_spec.rb +2 -2
- data/spec/unit/cookbook_loader_spec.rb +2 -2
- data/spec/unit/cookbook_uploader_spec.rb +6 -1
- data/spec/unit/data_bag_spec.rb +2 -2
- data/spec/unit/data_collector_spec.rb +7 -0
- data/spec/unit/dsl/platform_introspection_spec.rb +31 -1
- data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +1 -1
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +1 -1
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +7 -0
- data/spec/unit/knife/cookbook_show_spec.rb +1 -1
- data/spec/unit/knife/core/gem_glob_loader_spec.rb +1 -1
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +1 -1
- data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -1
- data/spec/unit/knife/core/ui_spec.rb +2 -2
- data/spec/unit/knife/data_bag_from_file_spec.rb +2 -2
- data/spec/unit/knife/environment_from_file_spec.rb +2 -2
- data/spec/unit/knife/ssh_spec.rb +27 -17
- data/spec/unit/knife/status_spec.rb +1 -1
- data/spec/unit/knife/supermarket_install_spec.rb +1 -1
- data/spec/unit/mixin/path_sanity_spec.rb +3 -3
- data/spec/unit/mixin/shell_out_spec.rb +2 -3
- data/spec/unit/mixin/template_spec.rb +4 -4
- data/spec/unit/mixin/user_context_spec.rb +3 -3
- data/spec/unit/node_map_spec.rb +12 -12
- data/spec/unit/platform/query_helpers_spec.rb +9 -9
- data/spec/unit/provider/execute_spec.rb +1 -1
- data/spec/unit/provider/link_spec.rb +5 -5
- data/spec/unit/provider/package/openbsd_spec.rb +1 -1
- data/spec/unit/provider/package/smartos_spec.rb +1 -1
- data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +2 -2
- data/spec/unit/provider/remote_file/fetcher_spec.rb +2 -2
- data/spec/unit/provider/remote_file/local_file_spec.rb +1 -1
- data/spec/unit/provider/remote_file/network_file_spec.rb +1 -1
- data/spec/unit/provider/script_spec.rb +2 -2
- data/spec/unit/provider/service/systemd_service_spec.rb +26 -2
- data/spec/unit/provider/subversion_spec.rb +3 -3
- data/spec/unit/provider/systemd_unit_spec.rb +53 -4
- data/spec/unit/provider/user/dscl_spec.rb +1 -1
- data/spec/unit/provider_resolver_spec.rb +41 -61
- data/spec/unit/resource/chef_sleep_spec.rb +30 -0
- data/spec/unit/resource/cookbook_file_spec.rb +3 -3
- data/spec/unit/resource/remote_file_spec.rb +3 -3
- data/spec/unit/resource/windows_firewall_rule_spec.rb +69 -12
- data/spec/unit/role_spec.rb +2 -2
- data/spec/unit/shell_spec.rb +1 -1
- data/spec/unit/util/selinux_spec.rb +2 -2
- data/spec/unit/win32/error_spec.rb +1 -1
- data/spec/unit/win32/link_spec.rb +1 -1
- data/spec/unit/win32/security_spec.rb +1 -1
- data/spec/unit/windows_service_spec.rb +1 -1
- data/tasks/docs.rb +10 -2
- data/tasks/rspec.rb +8 -6
- metadata +32 -8
- data/lib/chef/mixin/train_helpers.rb +0 -60
- data/spec/unit/mash_spec.rb +0 -51
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Kartik Null Cating-Subramanian (<ksubramanian@chef.io>)
|
3
|
-
# Copyright:: Copyright 2015-
|
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
|
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(
|
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
|
data/spec/unit/client_spec.rb
CHANGED
@@ -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(
|
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(
|
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
|
-
|
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(
|
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(
|
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(
|
36
|
-
expect(
|
37
|
-
expect(
|
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
|
-
|
42
|
-
|
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(
|
66
|
+
expect(chefignore.ignores).to match_array(%w{recipes/ignoreme.rb ignored vendor/bundle/*})
|
47
67
|
end
|
48
68
|
end
|
49
69
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Daniel DeLeo (<dan@chef.io>)
|
3
|
-
# Copyright:: Copyright 2010-
|
3
|
+
# Copyright:: Copyright 2010-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");
|
@@ -21,7 +21,7 @@ require "chef/cookbook/syntax_check"
|
|
21
21
|
|
22
22
|
describe Chef::Cookbook::SyntaxCheck do
|
23
23
|
before do
|
24
|
-
allow(
|
24
|
+
allow(ChefUtils).to receive(:windows?) { false }
|
25
25
|
end
|
26
26
|
|
27
27
|
let(:cookbook_path) { File.join(CHEF_SPEC_DATA, "cookbooks", "openldap") }
|
@@ -20,7 +20,7 @@ require "spec_helper"
|
|
20
20
|
|
21
21
|
describe Chef::CookbookLoader do
|
22
22
|
before do
|
23
|
-
allow(
|
23
|
+
allow(ChefUtils).to receive(:windows?) { false }
|
24
24
|
end
|
25
25
|
let(:repo_paths) do
|
26
26
|
[
|
@@ -101,7 +101,7 @@ describe Chef::CookbookLoader do
|
|
101
101
|
cookbook_loader.each_key do |cookbook_name|
|
102
102
|
seen << cookbook_name
|
103
103
|
end
|
104
|
-
expect(seen).to eq %w{angrybash apache2 borken ignorken irssi java name-mismatch openldap preseed supports-platform-constraints wget}
|
104
|
+
expect(seen).to eq %w{angrybash apache2 borken ignorken irssi java name-mismatch openldap preseed starter supports-platform-constraints wget}
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -21,9 +21,10 @@ require "spec_helper"
|
|
21
21
|
describe Chef::CookbookUploader do
|
22
22
|
|
23
23
|
let(:http_client) { double("Chef::ServerAPI") }
|
24
|
+
let(:cookbook_path) { File.join(CHEF_SPEC_DATA, "cookbooks") }
|
24
25
|
|
25
26
|
let(:cookbook_loader) do
|
26
|
-
loader = Chef::CookbookLoader.new(
|
27
|
+
loader = Chef::CookbookLoader.new(cookbook_path)
|
27
28
|
loader.load_cookbooks
|
28
29
|
loader.cookbooks_by_name["apache2"].identifier = apache2_identifier
|
29
30
|
loader.cookbooks_by_name["java"].identifier = java_identifier
|
@@ -55,6 +56,10 @@ describe Chef::CookbookUploader do
|
|
55
56
|
|
56
57
|
let(:uploader) { described_class.new(cookbooks_to_upload, rest: http_client, policy_mode: policy_mode) }
|
57
58
|
|
59
|
+
before do
|
60
|
+
allow(Chef::Config).to receive(:cookbook_path) { cookbook_path }
|
61
|
+
end
|
62
|
+
|
58
63
|
it "defaults to not enabling policy mode" do
|
59
64
|
expect(described_class.new(cookbooks_to_upload, rest: http_client).policy_mode?).to be(false)
|
60
65
|
end
|
data/spec/unit/data_bag_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright 2008-
|
3
|
+
# Copyright:: Copyright 2008-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");
|
@@ -22,7 +22,7 @@ require "chef/data_bag"
|
|
22
22
|
describe Chef::DataBag do
|
23
23
|
before(:each) do
|
24
24
|
@data_bag = Chef::DataBag.new
|
25
|
-
allow(
|
25
|
+
allow(ChefUtils).to receive(:windows?) { false }
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "initialize" do
|
@@ -46,6 +46,8 @@ describe Chef::DataCollector do
|
|
46
46
|
|
47
47
|
let(:run_list) { node.run_list }
|
48
48
|
|
49
|
+
let(:cookbooks) { node.fetch("cookbooks", {}) }
|
50
|
+
|
49
51
|
let(:run_id) { run_status.run_id }
|
50
52
|
|
51
53
|
let(:expansion) { Chef::RunList::RunListExpansion.new("_default", run_list.run_list_items) }
|
@@ -211,6 +213,11 @@ describe Chef::DataCollector do
|
|
211
213
|
send_run_failed_or_completed_event
|
212
214
|
end
|
213
215
|
|
216
|
+
it "has a cookbooks" do
|
217
|
+
expect_converge_message("cookbooks" => cookbooks)
|
218
|
+
send_run_failed_or_completed_event
|
219
|
+
end
|
220
|
+
|
214
221
|
it "has a source" do
|
215
222
|
expect_converge_message("source" => "chef_client")
|
216
223
|
send_run_failed_or_completed_event
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Seth Falcon (<seth@chef.io>)
|
3
|
-
# Copyright:: Copyright 2010-
|
3
|
+
# Copyright:: Copyright 2010-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");
|
@@ -127,3 +127,33 @@ describe Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue do
|
|
127
127
|
end
|
128
128
|
|
129
129
|
end
|
130
|
+
|
131
|
+
describe "ChefHelper functions mixed into classes" do
|
132
|
+
METHODS = %i{windows? fedora_derived? bsd_based? rhel? aix? gentoo?}.freeze
|
133
|
+
|
134
|
+
METHODS.each do |method|
|
135
|
+
it "mixes #{method} into Chef::Resource instances" do
|
136
|
+
expect(Chef::Resource.instance_methods.include?(method)).to be true
|
137
|
+
end
|
138
|
+
|
139
|
+
it "mixes #{method} into Chef::Resource classes (provides lines, etc)" do
|
140
|
+
expect(Chef::Resource.respond_to?(method)).to be true
|
141
|
+
end
|
142
|
+
|
143
|
+
it "mixes #{method} into Chef::Provider instances (actions)" do
|
144
|
+
expect(Chef::Provider.instance_methods.include?(method)).to be true
|
145
|
+
end
|
146
|
+
|
147
|
+
it "mixes #{method} into Chef::Provider classes (provides lines, etc)" do
|
148
|
+
expect(Chef::Provider.respond_to?(method)).to be true
|
149
|
+
end
|
150
|
+
|
151
|
+
it "mixes #{method} into Chef::Recipe instances (recipe files)" do
|
152
|
+
expect(Chef::Recipe.instance_methods.include?(method)).to be true
|
153
|
+
end
|
154
|
+
|
155
|
+
it "mixes #{method} into Chef::Node instances (attribute files)" do
|
156
|
+
expect(Chef::Recipe.instance_methods.include?(method)).to be true
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Daniel DeLeo (<dan@chef.io>)
|
3
|
-
# Copyright:: Copyright 2012-
|
3
|
+
# Copyright:: Copyright 2012-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");
|
@@ -40,6 +40,13 @@ describe Chef::Knife::CookbookMetadataFromFile do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "run" do
|
43
|
+
it "should print usage and exit when a FILE is not provided" do
|
44
|
+
@knife.name_args = []
|
45
|
+
expect(@knife).to receive(:show_usage)
|
46
|
+
expect(@knife.ui).to receive(:fatal).with(/You must specify the FILE./)
|
47
|
+
expect { @knife.run }.to raise_error(SystemExit)
|
48
|
+
end
|
49
|
+
|
43
50
|
it "should determine cookbook name from path" do
|
44
51
|
expect(@md).to receive(:name).with(no_args)
|
45
52
|
expect(@md).to receive(:name).with("quick_start")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
3
|
# Copyright:: Copyright 2008-2017, Chef Software Inc.
|
4
|
-
# License:: Apache License,
|
4
|
+
# License:: Apache License, version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -23,7 +23,7 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do
|
|
23
23
|
let(:plugin_dir) { File.join(home, ".chef", "plugins", "knife") }
|
24
24
|
|
25
25
|
before do
|
26
|
-
allow(
|
26
|
+
allow(ChefUtils).to receive(:windows?) { false }
|
27
27
|
Chef::Util::PathHelper.class_variable_set(:@@home_dir, home)
|
28
28
|
end
|
29
29
|
|
@@ -23,7 +23,7 @@ describe Chef::Knife::SubcommandLoader do
|
|
23
23
|
let(:plugin_dir) { File.join(home, ".chef", "plugins", "knife") }
|
24
24
|
|
25
25
|
before do
|
26
|
-
allow(
|
26
|
+
allow(ChefUtils).to receive(:windows?) { false }
|
27
27
|
Chef::Util::PathHelper.class_variable_set(:@@home_dir, home)
|
28
28
|
end
|
29
29
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Author:: Tim Hinderliter (<tim@chef.io>)
|
4
4
|
# Author:: Daniel DeLeo (<dan@chef.io>)
|
5
5
|
# Author:: John Keiser (<jkeiser@chef.io>)
|
6
|
-
# Copyright:: Copyright 2008-
|
6
|
+
# Copyright:: Copyright 2008-2018, Chef Software Inc.
|
7
7
|
# License:: Apache License, Version 2.0
|
8
8
|
#
|
9
9
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -482,7 +482,7 @@ describe Chef::Knife::UI do
|
|
482
482
|
before(:each) do
|
483
483
|
stdout = double("StringIO", tty?: true)
|
484
484
|
allow(@ui).to receive(:stdout).and_return(stdout)
|
485
|
-
allow(
|
485
|
+
allow(ChefUtils).to receive(:windows?) { true }
|
486
486
|
Chef::Config.reset
|
487
487
|
end
|
488
488
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Seth Falcon (<seth@chef.io>)
|
3
|
-
# Copyright:: Copyright 2010-
|
3
|
+
# Copyright:: Copyright 2010-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");
|
@@ -26,7 +26,7 @@ Chef::Knife::DataBagFromFile.load_deps
|
|
26
26
|
|
27
27
|
describe Chef::Knife::DataBagFromFile do
|
28
28
|
before :each do
|
29
|
-
allow(
|
29
|
+
allow(ChefUtils).to receive(:windows?) { false }
|
30
30
|
Chef::Config[:node_name] = "webmonkey.example.com"
|
31
31
|
FileUtils.mkdir_p([db_folder, db_folder2])
|
32
32
|
db_file.write(Chef::JSONCompat.to_json(plain_data))
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Stephen Delano (<stephen@ospcode.com>)
|
3
3
|
# Author:: Seth Falcon (<seth@ospcode.com>)
|
4
|
-
# Copyright:: Copyright 2010-
|
4
|
+
# Copyright:: Copyright 2010-2018, Chef Software Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -23,7 +23,7 @@ Chef::Knife::EnvironmentFromFile.load_deps
|
|
23
23
|
|
24
24
|
describe Chef::Knife::EnvironmentFromFile do
|
25
25
|
before(:each) do
|
26
|
-
allow(
|
26
|
+
allow(ChefUtils).to receive(:windows?) { false }
|
27
27
|
@knife = Chef::Knife::EnvironmentFromFile.new
|
28
28
|
@stdout = StringIO.new
|
29
29
|
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
|
data/spec/unit/knife/ssh_spec.rb
CHANGED
@@ -360,29 +360,39 @@ describe Chef::Knife::Ssh do
|
|
360
360
|
end
|
361
361
|
|
362
362
|
describe "#run" do
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
@knife.
|
363
|
+
|
364
|
+
it "should print usage and exit when a SEARCH QUERY is not provided" do
|
365
|
+
@knife.name_args = []
|
366
|
+
expect(@knife).to receive(:show_usage)
|
367
|
+
expect(@knife.ui).to receive(:fatal).with(/You must specify the SEARCH QUERY./)
|
368
|
+
expect { @knife.run }.to raise_error(SystemExit)
|
369
369
|
end
|
370
370
|
|
371
|
-
context "
|
372
|
-
|
371
|
+
context "exit" do
|
372
|
+
before do
|
373
|
+
@query = Chef::Search::Query.new
|
374
|
+
expect(@query).to receive(:search).and_yield(@node_foo)
|
375
|
+
allow(Chef::Search::Query).to receive(:new).and_return(@query)
|
376
|
+
allow(@knife).to receive(:ssh_command).and_return(exit_code)
|
377
|
+
@knife.name_args = ["*:*", "false"]
|
378
|
+
end
|
379
|
+
|
380
|
+
context "with an error" do
|
381
|
+
let(:exit_code) { 1 }
|
373
382
|
|
374
|
-
|
375
|
-
|
376
|
-
|
383
|
+
it "should exit with a non-zero exit code" do
|
384
|
+
expect(@knife).to receive(:exit).with(exit_code)
|
385
|
+
@knife.run
|
386
|
+
end
|
377
387
|
end
|
378
|
-
end
|
379
388
|
|
380
|
-
|
381
|
-
|
389
|
+
context "with no error" do
|
390
|
+
let(:exit_code) { 0 }
|
382
391
|
|
383
|
-
|
384
|
-
|
385
|
-
|
392
|
+
it "should not exit" do
|
393
|
+
expect(@knife).not_to receive(:exit)
|
394
|
+
@knife.run
|
395
|
+
end
|
386
396
|
end
|
387
397
|
end
|
388
398
|
end
|
@@ -30,7 +30,7 @@ describe Chef::Knife::Status do
|
|
30
30
|
@query = double("Chef::Search::Query")
|
31
31
|
allow(@query).to receive(:search).and_yield(node)
|
32
32
|
allow(Chef::Search::Query).to receive(:new).and_return(@query)
|
33
|
-
@knife
|
33
|
+
@knife = Chef::Knife::Status.new
|
34
34
|
@stdout = StringIO.new
|
35
35
|
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
|
36
36
|
end
|