chef 13.6.4-universal-mingw32 → 13.7.16-universal-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/VERSION +1 -1
- data/acceptance/Gemfile +2 -2
- data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb +1 -6
- data/distro/powershell/chef/chef.psm1 +1 -5
- data/lib/chef/api_client.rb +5 -5
- data/lib/chef/api_client_v1.rb +6 -6
- data/lib/chef/application.rb +3 -2
- data/lib/chef/application/knife.rb +4 -0
- data/lib/chef/chef_class.rb +2 -2
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -4
- data/lib/chef/client.rb +3 -3
- data/lib/chef/cookbook/chefignore.rb +4 -0
- data/lib/chef/cookbook/cookbook_collection.rb +2 -2
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/deprecated.rb +10 -0
- data/lib/chef/event_dispatch/base.rb +2 -2
- data/lib/chef/http.rb +10 -10
- data/lib/chef/knife.rb +16 -15
- data/lib/chef/knife/configure.rb +12 -36
- data/lib/chef/knife/cookbook_upload.rb +4 -4
- data/lib/chef/knife/core/bootstrap_context.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +6 -2
- data/lib/chef/knife/core/ui.rb +1 -1
- data/lib/chef/knife/data_bag_secret_options.rb +1 -1
- data/lib/chef/knife/data_bag_show.rb +1 -1
- data/lib/chef/knife/edit.rb +1 -1
- data/lib/chef/knife/ssh.rb +47 -35
- data/lib/chef/knife/user_create.rb +2 -0
- data/lib/chef/knife/user_delete.rb +2 -0
- data/lib/chef/knife/user_edit.rb +2 -0
- data/lib/chef/knife/user_reregister.rb +2 -0
- data/lib/chef/knife/user_show.rb +2 -0
- data/lib/chef/mixin/powershell_out.rb +1 -1
- data/lib/chef/node/attribute.rb +46 -70
- data/lib/chef/node/attribute_collections.rb +5 -5
- data/lib/chef/node/common_api.rb +1 -1
- data/lib/chef/node/immutable_collections.rb +180 -23
- data/lib/chef/node/mixin/state_tracking.rb +6 -6
- data/lib/chef/node_map.rb +63 -45
- data/lib/chef/property.rb +8 -8
- data/lib/chef/provider.rb +9 -3
- data/lib/chef/provider/apt_preference.rb +1 -1
- data/lib/chef/provider/apt_repository.rb +1 -1
- data/lib/chef/provider/apt_update.rb +1 -1
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/group/dscl.rb +6 -2
- data/lib/chef/provider/ifconfig.rb +96 -34
- data/lib/chef/provider/launchd.rb +0 -1
- data/lib/chef/provider/log.rb +3 -13
- data/lib/chef/provider/package/dnf.rb +1 -1
- data/lib/chef/provider/package/smartos.rb +2 -2
- data/lib/chef/provider/reboot.rb +12 -0
- data/lib/chef/provider/remote_directory.rb +1 -1
- data/lib/chef/provider/remote_file/http.rb +3 -2
- data/lib/chef/provider/service/solaris.rb +6 -2
- data/lib/chef/provider/systemd_unit.rb +34 -33
- data/lib/chef/provider/user/dscl.rb +1 -1
- data/lib/chef/provider/windows_path.rb +6 -7
- data/lib/chef/provider/windows_task.rb +89 -33
- data/lib/chef/provider/yum_repository.rb +24 -9
- data/lib/chef/resource/apt_package.rb +1 -0
- data/lib/chef/resource/apt_preference.rb +4 -0
- data/lib/chef/resource/apt_repository.rb +4 -0
- data/lib/chef/resource/apt_update.rb +3 -0
- data/lib/chef/resource/bash.rb +4 -0
- data/lib/chef/resource/batch.rb +5 -0
- data/lib/chef/resource/bff_package.rb +4 -0
- data/lib/chef/resource/breakpoint.rb +6 -0
- data/lib/chef/resource/cab_package.rb +6 -6
- data/lib/chef/resource/chef_gem.rb +13 -0
- data/lib/chef/resource/chocolatey_package.rb +4 -6
- data/lib/chef/resource/cookbook_file.rb +13 -15
- data/lib/chef/resource/cron.rb +2 -0
- data/lib/chef/resource/csh.rb +4 -0
- data/lib/chef/resource/directory.rb +8 -26
- data/lib/chef/resource/dnf_package.rb +5 -0
- data/lib/chef/resource/dpkg_package.rb +2 -0
- data/lib/chef/resource/dsc_resource.rb +5 -0
- data/lib/chef/resource/dsc_script.rb +6 -0
- data/lib/chef/resource/env.rb +3 -0
- data/lib/chef/resource/erl_call.rb +5 -0
- data/lib/chef/resource/execute.rb +5 -1
- data/lib/chef/resource/file.rb +2 -1
- data/lib/chef/resource/file/verification.rb +10 -0
- data/lib/chef/resource/freebsd_package.rb +10 -2
- data/lib/chef/resource/gem_package.rb +2 -0
- data/lib/chef/resource/git.rb +2 -0
- data/lib/chef/resource/group.rb +1 -0
- data/lib/chef/resource/homebrew_package.rb +3 -0
- data/lib/chef/resource/http_request.rb +2 -0
- data/lib/chef/resource/ifconfig.rb +23 -150
- data/lib/chef/resource/ips_package.rb +1 -0
- data/lib/chef/resource/ksh.rb +6 -0
- data/lib/chef/resource/launchd.rb +5 -4
- data/lib/chef/resource/link.rb +10 -0
- data/lib/chef/resource/log.rb +19 -46
- data/lib/chef/resource/macports_package.rb +1 -0
- data/lib/chef/resource/mdadm.rb +4 -0
- data/lib/chef/resource/mount.rb +1 -0
- data/lib/chef/resource/msu_package.rb +7 -8
- data/lib/chef/resource/ohai.rb +2 -0
- data/lib/chef/resource/openbsd_package.rb +3 -0
- data/lib/chef/resource/osx_profile.rb +10 -40
- data/lib/chef/resource/package.rb +6 -0
- data/lib/chef/resource/pacman_package.rb +1 -0
- data/lib/chef/resource/paludis_package.rb +3 -0
- data/lib/chef/resource/perl.rb +4 -0
- data/lib/chef/resource/portage_package.rb +1 -0
- data/lib/chef/resource/powershell_package.rb +5 -0
- data/lib/chef/resource/powershell_script.rb +8 -0
- data/lib/chef/resource/python.rb +4 -0
- data/lib/chef/resource/reboot.rb +14 -20
- data/lib/chef/resource/registry_key.rb +1 -0
- data/lib/chef/resource/remote_directory.rb +3 -0
- data/lib/chef/resource/remote_file.rb +2 -0
- data/lib/chef/resource/resource_notification.rb +17 -0
- data/lib/chef/resource/route.rb +1 -0
- data/lib/chef/resource/rpm_package.rb +1 -0
- data/lib/chef/resource/ruby.rb +4 -0
- data/lib/chef/resource/ruby_block.rb +3 -0
- data/lib/chef/resource/script.rb +4 -0
- data/lib/chef/resource/service.rb +1 -0
- data/lib/chef/resource/smartos_package.rb +1 -0
- data/lib/chef/resource/solaris_package.rb +1 -0
- data/lib/chef/resource/subversion.rb +1 -0
- data/lib/chef/resource/systemd_unit.rb +6 -0
- data/lib/chef/resource/template.rb +9 -0
- data/lib/chef/resource/user.rb +1 -0
- data/lib/chef/resource/windows_package.rb +2 -0
- data/lib/chef/resource/windows_path.rb +5 -10
- data/lib/chef/resource/windows_service.rb +3 -0
- data/lib/chef/resource/windows_task.rb +66 -87
- data/lib/chef/resource/yum_repository.rb +26 -22
- data/lib/chef/resource/zypper_package.rb +2 -0
- data/lib/chef/resource/zypper_repository.rb +6 -1
- data/lib/chef/run_context.rb +8 -2
- data/lib/chef/server_api.rb +1 -0
- data/lib/chef/util/selinux.rb +5 -4
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version/platform.rb +18 -0
- data/lib/chef/version_constraint/platform.rb +2 -0
- data/spec/data/client.d_00/02-strings.rb +2 -0
- data/spec/functional/assets/chefinittest +6 -4
- data/spec/functional/knife/ssh_spec.rb +54 -7
- data/spec/functional/resource/bff_spec.rb +3 -3
- data/spec/functional/resource/ifconfig_spec.rb +1 -1
- data/spec/functional/resource/mount_spec.rb +7 -3
- data/spec/functional/resource/user/useradd_spec.rb +4 -4
- data/spec/functional/resource/windows_task_spec.rb +6 -6
- data/spec/functional/win32/security_spec.rb +7 -33
- data/spec/integration/knife/data_bag_show_spec.rb +1 -1
- data/spec/integration/recipes/noop_resource_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +30 -30
- data/spec/integration/recipes/resource_action_spec.rb +2 -2
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +71 -15
- data/spec/spec_helper.rb +19 -0
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/unit/application_dot_d.rb +2 -0
- data/spec/support/shared/unit/execute_resource.rb +8 -1
- data/spec/support/shared/unit/provider/file.rb +9 -1
- data/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb +10 -7
- data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +2 -2
- data/spec/unit/client_spec.rb +1 -1
- data/spec/unit/deprecated_spec.rb +4 -4
- data/spec/unit/http_spec.rb +9 -0
- data/spec/unit/knife/bootstrap_spec.rb +5 -0
- data/spec/unit/knife/configure_spec.rb +10 -60
- data/spec/unit/knife/data_bag_create_spec.rb +40 -2
- data/spec/unit/knife/data_bag_show_spec.rb +16 -2
- data/spec/unit/knife/ssh_spec.rb +85 -39
- data/spec/unit/knife_spec.rb +2 -0
- data/spec/unit/lwrp_spec.rb +5 -3
- data/spec/unit/mixin/powershell_type_coercions_spec.rb +7 -6
- data/spec/unit/node/attribute_spec.rb +55 -24
- data/spec/unit/node/immutable_collections_spec.rb +28 -14
- data/spec/unit/node/vivid_mash_spec.rb +27 -10
- data/spec/unit/node_map_spec.rb +34 -0
- data/spec/unit/property_spec.rb +13 -13
- data/spec/unit/provider/group/dscl_spec.rb +14 -5
- data/spec/unit/provider/ifconfig_spec.rb +10 -3
- data/spec/unit/provider/remote_file/http_spec.rb +23 -19
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +6 -5
- data/spec/unit/provider/user/dscl_spec.rb +26 -0
- data/spec/unit/provider/windows_task_spec.rb +148 -4
- data/spec/unit/provider_spec.rb +1 -1
- data/spec/unit/resource/apt_package_spec.rb +1 -1
- data/spec/unit/resource/bash_spec.rb +8 -10
- data/spec/unit/resource/batch_spec.rb +1 -1
- data/spec/unit/resource/cab_package_spec.rb +19 -1
- data/spec/unit/resource/chef_gem_spec.rb +3 -3
- data/spec/unit/resource/chocolatey_package_spec.rb +10 -10
- data/spec/unit/resource/conditional_spec.rb +2 -2
- data/spec/unit/resource/cookbook_file_spec.rb +24 -30
- data/spec/unit/resource/cron_spec.rb +79 -82
- data/spec/unit/resource/csh_spec.rb +8 -10
- data/spec/unit/resource/deploy_spec.rb +1 -1
- data/spec/unit/resource/directory_spec.rb +28 -31
- data/spec/unit/resource/dnf_package_spec.rb +9 -9
- data/spec/unit/resource/env_spec.rb +7 -7
- data/spec/unit/resource/erl_call_spec.rb +9 -9
- data/spec/unit/resource/execute_spec.rb +6 -6
- data/spec/unit/resource/file/verification_spec.rb +18 -4
- data/spec/unit/resource/file_spec.rb +53 -56
- data/spec/unit/resource/freebsd_package_spec.rb +7 -7
- data/spec/unit/resource/gem_package_spec.rb +1 -1
- data/spec/unit/resource/git_spec.rb +7 -9
- data/spec/unit/resource/group_spec.rb +60 -70
- data/spec/unit/resource/http_request_spec.rb +16 -19
- data/spec/unit/resource/ifconfig_spec.rb +3 -3
- data/spec/unit/resource/ips_package_spec.rb +3 -5
- data/spec/unit/resource/ksh_spec.rb +8 -10
- data/spec/unit/resource/launchd_spec.rb +17 -10
- data/spec/unit/resource/link_spec.rb +53 -53
- data/spec/unit/resource/log_spec.rb +24 -28
- data/spec/unit/resource/mdadm_spec.rb +42 -44
- data/spec/unit/resource/mount_spec.rb +97 -99
- data/spec/unit/resource/msu_package_spec.rb +14 -8
- data/spec/unit/resource/ohai_spec.rb +15 -17
- data/spec/unit/resource/openbsd_package_spec.rb +3 -3
- data/spec/unit/resource/osx_profile_spec.rb +7 -7
- data/spec/unit/resource/package_spec.rb +36 -40
- data/spec/unit/resource/perl_spec.rb +8 -11
- data/spec/unit/resource/portage_package_spec.rb +8 -10
- data/spec/unit/resource/powershell_package_spec.rb +9 -9
- data/spec/unit/resource/python_spec.rb +8 -11
- data/spec/unit/resource/reboot_spec.rb +50 -0
- data/spec/unit/resource/registry_key_spec.rb +84 -98
- data/spec/unit/resource/remote_directory_spec.rb +40 -42
- data/spec/unit/resource/remote_file_spec.rb +78 -80
- data/spec/unit/resource/route_spec.rb +42 -44
- data/spec/unit/resource/rpm_package_spec.rb +5 -7
- data/spec/unit/resource/ruby_block_spec.rb +14 -16
- data/spec/unit/resource/ruby_spec.rb +8 -12
- data/spec/unit/resource/scm_spec.rb +66 -69
- data/spec/unit/resource/script_spec.rb +1 -1
- data/spec/unit/resource/service_spec.rb +80 -83
- data/spec/unit/resource/smartos_package_spec.rb +5 -0
- data/spec/unit/resource/solaris_package_spec.rb +3 -5
- data/spec/unit/resource/subversion_spec.rb +18 -16
- data/spec/unit/resource/systemd_unit_spec.rb +50 -54
- data/spec/unit/resource/template_spec.rb +56 -61
- data/spec/unit/resource/user_spec.rb +47 -53
- data/spec/unit/resource/windows_package_spec.rb +1 -1
- data/spec/unit/resource/windows_path_spec.rb +11 -8
- data/spec/unit/resource/windows_task_spec.rb +129 -33
- data/spec/unit/resource/yum_package_spec.rb +1 -1
- data/spec/unit/resource/yum_repository_spec.rb +61 -8
- data/spec/unit/resource/zypper_repository_spec.rb +17 -18
- data/spec/unit/util/selinux_spec.rb +3 -6
- data/tasks/dependencies.rb +0 -5
- data/tasks/rspec.rb +1 -1
- metadata +7 -19
- data/acceptance/.DS_Store +0 -0
- data/acceptance/.bundle/config +0 -2
- data/acceptance/top-cookbooks/.kitchen.docker.yml +0 -13
- data/acceptance/top-cookbooks/.kitchen.git.yml +0 -11
- data/distro/.DS_Store +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/chef/.DS_Store +0 -0
- data/lib/chef/knife/.DS_Store +0 -0
- data/lib/chef/mixin/.DS_Store +0 -0
- data/spec/.DS_Store +0 -0
- data/spec/functional/.DS_Store +0 -0
- data/spec/support/.DS_Store +0 -0
- data/spec/unit/.DS_Store +0 -0
- data/tasks/.DS_Store +0 -0
@@ -46,8 +46,8 @@ describe Chef::Knife::DataBagCreate do
|
|
46
46
|
allow(knife).to receive(:config).and_return(config)
|
47
47
|
end
|
48
48
|
|
49
|
-
context "when data_bag already
|
50
|
-
it "doesn't
|
49
|
+
context "when data_bag already exists" do
|
50
|
+
it "doesn't create a data bag" do
|
51
51
|
expect(knife).to receive(:create_object).and_yield(raw_hash)
|
52
52
|
expect(rest).to receive(:get).with("data/#{bag_name}")
|
53
53
|
expect(rest).to_not receive(:post).with("data", { "name" => bag_name })
|
@@ -80,6 +80,27 @@ describe Chef::Knife::DataBagCreate do
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
+
context "when part of the name is a reserved name" do
|
84
|
+
before do
|
85
|
+
exception = double("404 error", :code => "404")
|
86
|
+
%w{node role client environment}.each do |name|
|
87
|
+
allow(rest).to receive(:get)
|
88
|
+
.with("data/sudoing_#{name}_admins")
|
89
|
+
.and_raise(Net::HTTPServerException.new("404", exception))
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it "will create a data bag containing a reserved word" do
|
94
|
+
%w{node role client environment}.each do |name|
|
95
|
+
knife.name_args = ["sudoing_#{name}_admins"]
|
96
|
+
expect(rest).to receive(:post).with("data", { "name" => knife.name_args[0] })
|
97
|
+
expect(knife.ui).to receive(:info).with("Created data_bag[#{knife.name_args[0]}]")
|
98
|
+
|
99
|
+
knife.run
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
83
104
|
context "when given one argument" do
|
84
105
|
before do
|
85
106
|
knife.name_args = [bag_name]
|
@@ -93,6 +114,23 @@ describe Chef::Knife::DataBagCreate do
|
|
93
114
|
end
|
94
115
|
end
|
95
116
|
|
117
|
+
context "when given a data bag name partially matching a reserved name for search" do
|
118
|
+
%w{xnode rolex xenvironmentx xclientx}.each do |name|
|
119
|
+
let(:bag_name) { name }
|
120
|
+
|
121
|
+
before do
|
122
|
+
knife.name_args = [bag_name]
|
123
|
+
end
|
124
|
+
|
125
|
+
it "creates a data bag named '#{name}'" do
|
126
|
+
expect(rest).to receive(:post).with("data", { "name" => bag_name })
|
127
|
+
expect(knife.ui).to receive(:info).with("Created data_bag[#{bag_name}]")
|
128
|
+
|
129
|
+
knife.run
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
96
134
|
context "no secret is specified for encryption" do
|
97
135
|
let(:item) do
|
98
136
|
item = Chef::DataBagItem.from_hash(raw_hash)
|
@@ -91,12 +91,11 @@ qux: http://localhost:4000/data/bag_o_data/qux}
|
|
91
91
|
context "Data bag to show is not encrypted" do
|
92
92
|
before do
|
93
93
|
allow(knife).to receive(:encrypted?).and_return(false)
|
94
|
-
expect(knife).to receive(:read_secret).exactly(0).times
|
95
94
|
end
|
96
95
|
|
97
96
|
it "displays the data bag" do
|
97
|
+
expect(knife).to receive(:read_secret).exactly(0).times
|
98
98
|
expect(Chef::DataBagItem).to receive(:load).with(bag_name, item_name).and_return(data_bag)
|
99
|
-
expect(knife.ui).to receive(:warn).with("Unencrypted data bag detected, ignoring any provided secret options.")
|
100
99
|
|
101
100
|
expected = %q{baz: http://localhost:4000/data/bag_o_data/baz
|
102
101
|
id: id
|
@@ -104,6 +103,21 @@ qux: http://localhost:4000/data/bag_o_data/qux}
|
|
104
103
|
knife.run
|
105
104
|
expect(stdout.string.strip).to eq(expected)
|
106
105
|
end
|
106
|
+
|
107
|
+
context "when a secret is given" do
|
108
|
+
it "displays the data bag" do
|
109
|
+
expect(knife).to receive(:encryption_secret_provided_ignore_encrypt_flag?).and_return(true)
|
110
|
+
expect(knife).to receive(:read_secret).and_return(secret)
|
111
|
+
expect(Chef::DataBagItem).to receive(:load).with(bag_name, item_name).and_return(data_bag)
|
112
|
+
expect(knife.ui).to receive(:warn).with("Unencrypted data bag detected, ignoring any provided secret options.")
|
113
|
+
|
114
|
+
expected = %q{baz: http://localhost:4000/data/bag_o_data/baz
|
115
|
+
id: id
|
116
|
+
qux: http://localhost:4000/data/bag_o_data/qux}
|
117
|
+
knife.run
|
118
|
+
expect(stdout.string.strip).to eq(expected)
|
119
|
+
end
|
120
|
+
end
|
107
121
|
end
|
108
122
|
|
109
123
|
it "displays the list of items in the data bag when only one @name_arg is provided" do
|
data/spec/unit/knife/ssh_spec.rb
CHANGED
@@ -49,28 +49,36 @@ describe Chef::Knife::Ssh do
|
|
49
49
|
|
50
50
|
def self.should_return_specified_attributes
|
51
51
|
it "returns an array of the attributes specified on the command line OR config file, if only one is set" do
|
52
|
-
@node_bar["
|
53
|
-
@node_foo["
|
54
|
-
@
|
52
|
+
@node_bar["target"] = "10.0.0.2"
|
53
|
+
@node_foo["target"] = "10.0.0.1"
|
54
|
+
@node_bar["prefix"] = "bar"
|
55
|
+
@node_foo["prefix"] = "foo"
|
56
|
+
@knife.config[:ssh_attribute] = "ipaddress"
|
57
|
+
@knife.config[:prefix_attribute] = "name"
|
55
58
|
Chef::Config[:knife][:ssh_attribute] = "ipaddress" # this value will be in the config file
|
56
|
-
|
59
|
+
Chef::Config[:knife][:prefix_attribute] = "name" # this value will be in the config file
|
60
|
+
expect(@knife).to receive(:session_from_list).with([["10.0.0.1", nil, "foo"], ["10.0.0.2", nil, "bar"]])
|
57
61
|
@knife.configure_session
|
58
62
|
end
|
59
63
|
|
60
64
|
it "returns an array of the attributes specified on the command line even when a config value is set" do
|
61
|
-
@node_bar["
|
62
|
-
@node_foo["
|
65
|
+
@node_bar["target"] = "10.0.0.2"
|
66
|
+
@node_foo["target"] = "10.0.0.1"
|
67
|
+
@node_bar["prefix"] = "bar"
|
68
|
+
@node_foo["prefix"] = "foo"
|
63
69
|
Chef::Config[:knife][:ssh_attribute] = "config_file" # this value will be in the config file
|
64
|
-
|
65
|
-
|
70
|
+
Chef::Config[:knife][:prefix_attribute] = "config_file" # this value will be in the config file
|
71
|
+
@knife.config[:ssh_attribute] = "ipaddress" # this is the value of the command line via #configure_attribute
|
72
|
+
@knife.config[:prefix_attribute] = "name" # this is the value of the command line via #configure_attribute
|
73
|
+
expect(@knife).to receive(:session_from_list).with([["10.0.0.1", nil, "foo"], ["10.0.0.2", nil, "bar"]])
|
66
74
|
@knife.configure_session
|
67
75
|
end
|
68
76
|
end
|
69
77
|
|
70
|
-
it "
|
78
|
+
it "searches for and returns an array of fqdns" do
|
71
79
|
expect(@knife).to receive(:session_from_list).with([
|
72
|
-
["foo.example.org", nil],
|
73
|
-
["bar.example.org", nil],
|
80
|
+
["foo.example.org", nil, nil],
|
81
|
+
["bar.example.org", nil, nil],
|
74
82
|
])
|
75
83
|
@knife.configure_session
|
76
84
|
end
|
@@ -84,8 +92,8 @@ describe Chef::Knife::Ssh do
|
|
84
92
|
end
|
85
93
|
it "returns an array of cloud public hostnames" do
|
86
94
|
expect(@knife).to receive(:session_from_list).with([
|
87
|
-
["ec2-10-0-0-1.compute-1.amazonaws.com", nil],
|
88
|
-
["ec2-10-0-0-2.compute-1.amazonaws.com", nil],
|
95
|
+
["ec2-10-0-0-1.compute-1.amazonaws.com", nil, nil],
|
96
|
+
["ec2-10-0-0-2.compute-1.amazonaws.com", nil, nil],
|
89
97
|
])
|
90
98
|
@knife.configure_session
|
91
99
|
end
|
@@ -101,8 +109,8 @@ describe Chef::Knife::Ssh do
|
|
101
109
|
|
102
110
|
it "returns an array of fqdns" do
|
103
111
|
expect(@knife).to receive(:session_from_list).with([
|
104
|
-
["foo.example.org", nil],
|
105
|
-
["bar.example.org", nil],
|
112
|
+
["foo.example.org", nil, nil],
|
113
|
+
["bar.example.org", nil, nil],
|
106
114
|
])
|
107
115
|
@knife.configure_session
|
108
116
|
end
|
@@ -144,15 +152,35 @@ describe Chef::Knife::Ssh do
|
|
144
152
|
end
|
145
153
|
end
|
146
154
|
|
155
|
+
describe "#get_prefix_attribute" do
|
156
|
+
# Order of precedence for prefix
|
157
|
+
# 1) config value (cli or knife config)
|
158
|
+
# 2) nil
|
159
|
+
before do
|
160
|
+
Chef::Config[:knife][:prefix_attribute] = nil
|
161
|
+
@knife.config[:prefix_attribute] = nil
|
162
|
+
@node_foo["cloud"]["public_hostname"] = "ec2-10-0-0-1.compute-1.amazonaws.com"
|
163
|
+
@node_bar["cloud"]["public_hostname"] = ""
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should return nil by default" do
|
167
|
+
expect(@knife.get_prefix_attribute({})).to eq(nil)
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should favor config over nil" do
|
171
|
+
@node_foo["prefix"] = "config"
|
172
|
+
expect( @knife.get_prefix_attribute(@node_foo)).to eq("config")
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
147
176
|
describe "#get_ssh_attribute" do
|
148
177
|
# Order of precedence for ssh target
|
149
|
-
# 1)
|
150
|
-
# 2)
|
151
|
-
# 3)
|
152
|
-
# 4) fqdn
|
178
|
+
# 1) config value (cli or knife config)
|
179
|
+
# 2) cloud attribute
|
180
|
+
# 3) fqdn
|
153
181
|
before do
|
154
182
|
Chef::Config[:knife][:ssh_attribute] = nil
|
155
|
-
@knife.config[:
|
183
|
+
@knife.config[:ssh_attribute] = nil
|
156
184
|
@node_foo["cloud"]["public_hostname"] = "ec2-10-0-0-1.compute-1.amazonaws.com"
|
157
185
|
@node_bar["cloud"]["public_hostname"] = ""
|
158
186
|
end
|
@@ -165,18 +193,9 @@ describe Chef::Knife::Ssh do
|
|
165
193
|
expect(@knife.get_ssh_attribute(@node_foo)).to eq("ec2-10-0-0-1.compute-1.amazonaws.com")
|
166
194
|
end
|
167
195
|
|
168
|
-
it "should favor
|
169
|
-
@
|
170
|
-
|
171
|
-
@node_foo["config"] = "command_line"
|
172
|
-
@node_foo["knife_config"] = "config_file"
|
173
|
-
expect( @knife.get_ssh_attribute(@node_foo)).to eq("command_line")
|
174
|
-
end
|
175
|
-
|
176
|
-
it "should favor config file over cloud and default" do
|
177
|
-
Chef::Config[:knife][:ssh_attribute] = "config_file"
|
178
|
-
@node_foo["knife_config"] = "config_file"
|
179
|
-
expect( @knife.get_ssh_attribute(@node_foo)).to eq("config_file")
|
196
|
+
it "should favor config over cloud and default" do
|
197
|
+
@node_foo["target"] = "config"
|
198
|
+
expect( @knife.get_ssh_attribute(@node_foo)).to eq("config")
|
180
199
|
end
|
181
200
|
|
182
201
|
it "should return fqdn if cloud.hostname is empty" do
|
@@ -192,40 +211,50 @@ describe Chef::Knife::Ssh do
|
|
192
211
|
end
|
193
212
|
|
194
213
|
it "uses the port from an ssh config file" do
|
195
|
-
@knife.session_from_list([["the.b.org", nil]])
|
214
|
+
@knife.session_from_list([["the.b.org", nil, nil]])
|
196
215
|
expect(@knife.session.servers[0].port).to eq(23)
|
197
216
|
end
|
198
217
|
|
199
218
|
it "uses the port from a cloud attr" do
|
200
|
-
@knife.session_from_list([["the.b.org", 123]])
|
219
|
+
@knife.session_from_list([["the.b.org", 123, nil]])
|
201
220
|
expect(@knife.session.servers[0].port).to eq(123)
|
202
221
|
end
|
203
222
|
|
223
|
+
it "uses the prefix from list" do
|
224
|
+
@knife.session_from_list([["the.b.org", nil, "b-team"]])
|
225
|
+
expect(@knife.session.servers[0][:prefix]).to eq("b-team")
|
226
|
+
end
|
227
|
+
|
228
|
+
it "defaults to a prefix of host" do
|
229
|
+
@knife.session_from_list([["the.b.org", nil, nil]])
|
230
|
+
expect(@knife.session.servers[0][:prefix]).to eq("the.b.org")
|
231
|
+
end
|
232
|
+
|
204
233
|
it "defaults to a timeout of 120 seconds" do
|
205
|
-
@knife.session_from_list([["the.b.org", nil]])
|
234
|
+
@knife.session_from_list([["the.b.org", nil, nil]])
|
206
235
|
expect(@knife.session.servers[0].options[:timeout]).to eq(120)
|
207
236
|
end
|
208
237
|
|
209
238
|
it "uses the timeout from Chef Config" do
|
210
239
|
Chef::Config[:knife][:ssh_timeout] = 5
|
211
240
|
@knife.config[:ssh_timeout] = nil
|
212
|
-
@knife.session_from_list([["the.b.org", nil]])
|
241
|
+
@knife.session_from_list([["the.b.org", nil, nil]])
|
213
242
|
expect(@knife.session.servers[0].options[:timeout]).to eq(5)
|
214
243
|
end
|
215
244
|
|
216
245
|
it "uses the timeout from knife config" do
|
217
246
|
@knife.config[:ssh_timeout] = 6
|
218
|
-
@knife.session_from_list([["the.b.org", nil]])
|
247
|
+
@knife.session_from_list([["the.b.org", nil, nil]])
|
219
248
|
expect(@knife.session.servers[0].options[:timeout]).to eq(6)
|
220
249
|
end
|
221
250
|
|
222
251
|
it "uses the user from an ssh config file" do
|
223
|
-
@knife.session_from_list([["the.b.org", 123]])
|
252
|
+
@knife.session_from_list([["the.b.org", 123, nil]])
|
224
253
|
expect(@knife.session.servers[0].user).to eq("locutus")
|
225
254
|
end
|
226
255
|
|
227
256
|
it "uses keepalive settings from an ssh config file" do
|
228
|
-
@knife.session_from_list([["the.b.org", 123]])
|
257
|
+
@knife.session_from_list([["the.b.org", 123, nil]])
|
229
258
|
expect(@knife.session.servers[0].options[:keepalive]).to be true
|
230
259
|
expect(@knife.session.servers[0].options[:keepalive_interval]).to eq 60
|
231
260
|
end
|
@@ -295,6 +324,23 @@ describe Chef::Knife::Ssh do
|
|
295
324
|
end
|
296
325
|
end
|
297
326
|
|
327
|
+
describe "#tmux" do
|
328
|
+
before do
|
329
|
+
ssh_config = { :timeout => 50, :user => "locutus", :port => 23, :keepalive => true, :keepalive_interval => 60 }
|
330
|
+
allow(Net::SSH).to receive(:configuration_for).with("foo.example.org", true).and_return(ssh_config)
|
331
|
+
@query = Chef::Search::Query.new
|
332
|
+
expect(@query).to receive(:search).and_yield(@node_foo)
|
333
|
+
allow(Chef::Search::Query).to receive(:new).and_return(@query)
|
334
|
+
allow(@knife).to receive(:exec).and_return(0)
|
335
|
+
end
|
336
|
+
|
337
|
+
it "filters out invalid characters from tmux session name" do
|
338
|
+
@knife.name_args = ["name:foo.example.org", "tmux"]
|
339
|
+
expect(@knife).to receive(:shell_out!).with("tmux new-session -d -s 'knife ssh name=foo-example-org' -n 'foo.example.org' 'ssh locutus@foo.example.org' ")
|
340
|
+
@knife.run
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
298
344
|
describe "#run" do
|
299
345
|
before do
|
300
346
|
@query = Chef::Search::Query.new
|
data/spec/unit/knife_spec.rb
CHANGED
@@ -47,6 +47,7 @@ describe Chef::Knife do
|
|
47
47
|
|
48
48
|
allow(Chef::WorkstationConfigLoader).to receive(:new).and_return(config_loader)
|
49
49
|
allow(config_loader).to receive(:explicit_config_file=)
|
50
|
+
allow(config_loader).to receive(:profile=)
|
50
51
|
|
51
52
|
# Prevent gratuitous code reloading:
|
52
53
|
allow(Chef::Knife).to receive(:load_commands)
|
@@ -331,6 +332,7 @@ describe Chef::Knife do
|
|
331
332
|
knife.config[:config_file] = fake_config
|
332
333
|
config_loader = double("Chef::WorkstationConfigLoader", :load => true, :no_config_found? => false, :chef_config_dir => "/etc/chef", :config_location => fake_config)
|
333
334
|
allow(config_loader).to receive(:explicit_config_file=).with(fake_config).and_return(fake_config)
|
335
|
+
allow(config_loader).to receive(:profile=)
|
334
336
|
allow(Chef::WorkstationConfigLoader).to receive(:new).and_return(config_loader)
|
335
337
|
end
|
336
338
|
|
data/spec/unit/lwrp_spec.rb
CHANGED
@@ -571,14 +571,16 @@ describe "LWRP" do
|
|
571
571
|
|
572
572
|
context "resource class created" do
|
573
573
|
let(:test_lwrp_class) { @test_lwrp_class }
|
574
|
-
before(:
|
575
|
-
@
|
574
|
+
before(:each) do
|
575
|
+
@tmpparent = Dir.mktmpdir("lwrp_test")
|
576
|
+
@tmpdir = File.join(@tmpparent, "lwrp")
|
577
|
+
Dir.mkdir(@tmpdir)
|
576
578
|
resource_path = File.join(@tmpdir, "once.rb")
|
577
579
|
IO.write(resource_path, "default_action :create")
|
578
580
|
@test_lwrp_class = Chef::Resource::LWRPBase.build_from_file("lwrp", resource_path, nil)
|
579
581
|
end
|
580
582
|
|
581
|
-
after(:
|
583
|
+
after(:each) do
|
582
584
|
FileUtils.remove_entry @tmpdir
|
583
585
|
end
|
584
586
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Jay Mundrawala (<jdm@chef.io>)
|
3
|
-
# Copyright:: Copyright 2015-
|
3
|
+
# Copyright:: Copyright 2015-2017, 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");
|
@@ -64,14 +64,15 @@ describe Chef::Mixin::PowershellTypeCoercions do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
it "translates a Chef::Node::ImmutableMash like a hash" do
|
67
|
-
|
68
|
-
|
69
|
-
expect(test_class.translate_type(
|
67
|
+
node = Chef::Node.new
|
68
|
+
node.default[:test] = { "a" => 1, "b" => 1.2, "c" => false, "d" => true }
|
69
|
+
expect(test_class.translate_type(node[:test])).to eq("@{a=1;b=1.2;c=$false;d=$true}")
|
70
70
|
end
|
71
71
|
|
72
72
|
it "translates a Chef::Node::ImmutableArray like an array" do
|
73
|
-
|
74
|
-
|
73
|
+
node = Chef::Node.new
|
74
|
+
node.default[:test] = [ true, false ]
|
75
|
+
expect(test_class.translate_type(node[:test])).to eq("@($true,$false)")
|
75
76
|
end
|
76
77
|
|
77
78
|
it "falls back :to_psobject if we have not defined at explicit rule" do
|
@@ -171,6 +171,7 @@ describe Chef::Node::Attribute do
|
|
171
171
|
}
|
172
172
|
@automatic_hash = { "week" => "friday" }
|
173
173
|
@attributes = Chef::Node::Attribute.new(@attribute_hash, @default_hash, @override_hash, @automatic_hash, node)
|
174
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
174
175
|
end
|
175
176
|
|
176
177
|
describe "initialize" do
|
@@ -179,13 +180,14 @@ describe Chef::Node::Attribute do
|
|
179
180
|
end
|
180
181
|
|
181
182
|
it "should take an Automatioc, Normal, Default and Override hash" do
|
182
|
-
expect { Chef::Node::Attribute.new({}, {}, {}, {}) }.not_to raise_error
|
183
|
+
expect { Chef::Node::Attribute.new({}, {}, {}, {}, node) }.not_to raise_error
|
183
184
|
end
|
184
185
|
|
185
186
|
[ :normal, :default, :override, :automatic ].each do |accessor|
|
186
187
|
it "should set #{accessor}" do
|
187
|
-
|
188
|
-
|
188
|
+
@attributes = Chef::Node::Attribute.new({ :normal => true }, { :default => true }, { :override => true }, { :automatic => true }, node)
|
189
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
190
|
+
expect(@attributes.send(accessor)).to eq({ accessor.to_s => true })
|
189
191
|
end
|
190
192
|
end
|
191
193
|
|
@@ -330,7 +332,8 @@ describe Chef::Node::Attribute do
|
|
330
332
|
end
|
331
333
|
|
332
334
|
it "merges nested hashes between precedence levels" do
|
333
|
-
@attributes = Chef::Node::Attribute.new({}, {}, {}, {})
|
335
|
+
@attributes = Chef::Node::Attribute.new({}, {}, {}, {}, node)
|
336
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
334
337
|
@attributes.env_default = { "a" => { "b" => { "default" => "default" } } }
|
335
338
|
@attributes.normal = { "a" => { "b" => { "normal" => "normal" } } }
|
336
339
|
@attributes.override = { "a" => { "override" => "role" } }
|
@@ -584,8 +587,10 @@ describe Chef::Node::Attribute do
|
|
584
587
|
"one" => { "six" => "seven" },
|
585
588
|
"snack" => "cookies",
|
586
589
|
},
|
587
|
-
{}
|
590
|
+
{},
|
591
|
+
node
|
588
592
|
)
|
593
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
589
594
|
end
|
590
595
|
|
591
596
|
it "should yield each top level key" do
|
@@ -632,8 +637,10 @@ describe Chef::Node::Attribute do
|
|
632
637
|
"one" => "six",
|
633
638
|
"snack" => "cookies",
|
634
639
|
},
|
635
|
-
{}
|
640
|
+
{},
|
641
|
+
node
|
636
642
|
)
|
643
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
637
644
|
end
|
638
645
|
|
639
646
|
it "should yield each top level key and value, post merge rules" do
|
@@ -670,8 +677,10 @@ describe Chef::Node::Attribute do
|
|
670
677
|
"one" => "six",
|
671
678
|
"snack" => "cookies",
|
672
679
|
},
|
673
|
-
{}
|
680
|
+
{},
|
681
|
+
node
|
674
682
|
)
|
683
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
675
684
|
end
|
676
685
|
|
677
686
|
it "should respond to each_key" do
|
@@ -706,8 +715,10 @@ describe Chef::Node::Attribute do
|
|
706
715
|
"one" => "six",
|
707
716
|
"snack" => "cookies",
|
708
717
|
},
|
709
|
-
{}
|
718
|
+
{},
|
719
|
+
node
|
710
720
|
)
|
721
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
711
722
|
end
|
712
723
|
|
713
724
|
it "should respond to each_pair" do
|
@@ -742,8 +753,10 @@ describe Chef::Node::Attribute do
|
|
742
753
|
"one" => "six",
|
743
754
|
"snack" => "cookies",
|
744
755
|
},
|
745
|
-
{}
|
756
|
+
{},
|
757
|
+
node
|
746
758
|
)
|
759
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
747
760
|
end
|
748
761
|
|
749
762
|
it "should respond to each_value" do
|
@@ -786,9 +799,10 @@ describe Chef::Node::Attribute do
|
|
786
799
|
"one" => "six",
|
787
800
|
"snack" => "cookies",
|
788
801
|
},
|
789
|
-
{}
|
802
|
+
{},
|
803
|
+
node
|
790
804
|
)
|
791
|
-
|
805
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
792
806
|
end
|
793
807
|
|
794
808
|
it "should respond to empty?" do
|
@@ -796,7 +810,9 @@ describe Chef::Node::Attribute do
|
|
796
810
|
end
|
797
811
|
|
798
812
|
it "should return true when there are no keys" do
|
799
|
-
|
813
|
+
@attributes = Chef::Node::Attribute.new({}, {}, {}, {}, node)
|
814
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
815
|
+
expect(@attributes.empty?).to eq(true)
|
800
816
|
end
|
801
817
|
|
802
818
|
it "should return false when there are keys" do
|
@@ -820,8 +836,10 @@ describe Chef::Node::Attribute do
|
|
820
836
|
"one" => "six",
|
821
837
|
"snack" => "cookies",
|
822
838
|
},
|
823
|
-
{}
|
839
|
+
{},
|
840
|
+
node
|
824
841
|
)
|
842
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
825
843
|
end
|
826
844
|
|
827
845
|
it "should respond to fetch" do
|
@@ -877,8 +895,10 @@ describe Chef::Node::Attribute do
|
|
877
895
|
"one" => "six",
|
878
896
|
"snack" => "cookies",
|
879
897
|
},
|
880
|
-
{}
|
898
|
+
{},
|
899
|
+
node
|
881
900
|
)
|
901
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
882
902
|
end
|
883
903
|
|
884
904
|
it "should respond to has_value?" do
|
@@ -922,8 +942,10 @@ describe Chef::Node::Attribute do
|
|
922
942
|
"one" => "six",
|
923
943
|
"snack" => "cookies",
|
924
944
|
},
|
925
|
-
{}
|
945
|
+
{},
|
946
|
+
node
|
926
947
|
)
|
948
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
927
949
|
end
|
928
950
|
|
929
951
|
it "should respond to index" do
|
@@ -963,8 +985,10 @@ describe Chef::Node::Attribute do
|
|
963
985
|
"one" => "six",
|
964
986
|
"snack" => "cookies",
|
965
987
|
},
|
966
|
-
{}
|
988
|
+
{},
|
989
|
+
node
|
967
990
|
)
|
991
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
968
992
|
end
|
969
993
|
|
970
994
|
it "should respond to values" do
|
@@ -999,8 +1023,10 @@ describe Chef::Node::Attribute do
|
|
999
1023
|
"one" => "six",
|
1000
1024
|
"snack" => "cookies",
|
1001
1025
|
},
|
1002
|
-
{}
|
1026
|
+
{},
|
1027
|
+
node
|
1003
1028
|
)
|
1029
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
1004
1030
|
end
|
1005
1031
|
|
1006
1032
|
it "should respond to select" do
|
@@ -1049,10 +1075,11 @@ describe Chef::Node::Attribute do
|
|
1049
1075
|
"one" => "six",
|
1050
1076
|
"snack" => "cookies",
|
1051
1077
|
},
|
1052
|
-
{}
|
1078
|
+
{},
|
1079
|
+
node
|
1053
1080
|
)
|
1081
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
1054
1082
|
|
1055
|
-
@empty = Chef::Node::Attribute.new({}, {}, {}, {})
|
1056
1083
|
end
|
1057
1084
|
|
1058
1085
|
it "should respond to size" do
|
@@ -1064,7 +1091,9 @@ describe Chef::Node::Attribute do
|
|
1064
1091
|
end
|
1065
1092
|
|
1066
1093
|
it "should return 0 for an empty attribute" do
|
1067
|
-
|
1094
|
+
@attributes = Chef::Node::Attribute.new({}, {}, {}, {}, node)
|
1095
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
1096
|
+
expect(@attributes.size).to eq(0)
|
1068
1097
|
end
|
1069
1098
|
|
1070
1099
|
it "should return the number of pairs" do
|
@@ -1092,8 +1121,9 @@ describe Chef::Node::Attribute do
|
|
1092
1121
|
|
1093
1122
|
describe "to_s" do
|
1094
1123
|
it "should output simple attributes" do
|
1095
|
-
attributes = Chef::Node::Attribute.new(nil, nil, nil, nil)
|
1096
|
-
|
1124
|
+
@attributes = Chef::Node::Attribute.new(nil, nil, nil, nil, node)
|
1125
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
1126
|
+
expect(@attributes.to_s).to eq("{}")
|
1097
1127
|
end
|
1098
1128
|
|
1099
1129
|
it "should output merged attributes" do
|
@@ -1105,8 +1135,9 @@ describe Chef::Node::Attribute do
|
|
1105
1135
|
"b" => 3,
|
1106
1136
|
"c" => 4,
|
1107
1137
|
}
|
1108
|
-
attributes = Chef::Node::Attribute.new(nil, default_hash, override_hash, nil)
|
1109
|
-
|
1138
|
+
@attributes = Chef::Node::Attribute.new(nil, default_hash, override_hash, nil, node)
|
1139
|
+
allow(node).to receive(:attributes).and_return(@attributes)
|
1140
|
+
expect(@attributes.to_s).to eq('{"b"=>3, "c"=>4, "a"=>1}')
|
1110
1141
|
end
|
1111
1142
|
end
|
1112
1143
|
|