chef 12.11.18 → 12.12.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -4
- data/Rakefile +3 -2
- data/VERSION +1 -1
- data/acceptance/Gemfile.lock +22 -23
- data/acceptance/data-collector/test/integration/default/serverspec/default_spec.rb +2 -41
- data/lib/chef/application/solo.rb +7 -0
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +1 -1
- data/lib/chef/data_collector.rb +79 -43
- data/lib/chef/data_collector/messages.rb +4 -33
- data/lib/chef/data_collector/messages/helpers.rb +2 -2
- data/lib/chef/data_collector/resource_report.rb +21 -11
- data/lib/chef/decorator/unchain.rb +43 -0
- data/lib/chef/exceptions.rb +5 -0
- data/lib/chef/http.rb +5 -5
- data/lib/chef/knife/cookbook_create.rb +4 -0
- data/lib/chef/knife/cookbook_site_download.rb +8 -1
- data/lib/chef/knife/cookbook_site_install.rb +8 -0
- data/lib/chef/knife/cookbook_site_list.rb +8 -1
- data/lib/chef/knife/cookbook_site_search.rb +8 -1
- data/lib/chef/knife/cookbook_site_share.rb +8 -1
- data/lib/chef/knife/cookbook_site_show.rb +14 -3
- data/lib/chef/knife/cookbook_site_unshare.rb +8 -1
- data/lib/chef/knife/core/bootstrap_context.rb +1 -1
- data/lib/chef/knife/supermarket_download.rb +33 -0
- data/lib/chef/knife/supermarket_install.rb +33 -0
- data/lib/chef/knife/supermarket_list.rb +33 -0
- data/lib/chef/knife/supermarket_search.rb +33 -0
- data/lib/chef/knife/supermarket_share.rb +33 -0
- data/lib/chef/knife/supermarket_show.rb +33 -0
- data/lib/chef/knife/supermarket_unshare.rb +33 -0
- data/lib/chef/node.rb +13 -32
- data/lib/chef/node/attribute.rb +123 -70
- data/lib/chef/node/attribute_collections.rb +9 -130
- data/lib/chef/node/common_api.rb +124 -0
- data/lib/chef/node/immutable_collections.rb +27 -2
- data/lib/chef/property.rb +6 -2
- data/lib/chef/provider.rb +4 -5
- data/lib/chef/provider/batch.rb +1 -1
- data/lib/chef/provider/directory.rb +3 -1
- data/lib/chef/provider/package/openbsd.rb +1 -1
- data/lib/chef/provider/package/rubygems.rb +9 -3
- data/lib/chef/provider/package/windows/exe.rb +2 -5
- data/lib/chef/provider/powershell_script.rb +1 -1
- data/lib/chef/provider/remote_directory.rb +2 -0
- data/lib/chef/resource.rb +22 -17
- data/lib/chef/resource_builder.rb +9 -4
- data/lib/chef/shell.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/spec/data/run_context/cookbooks/circular-dep1/attributes/default.rb +2 -4
- data/spec/data/run_context/cookbooks/circular-dep2/attributes/default.rb +2 -3
- data/spec/data/run_context/cookbooks/dependency1/attributes/aa_first.rb +2 -2
- data/spec/data/run_context/cookbooks/dependency1/attributes/default.rb +2 -2
- data/spec/data/run_context/cookbooks/dependency1/attributes/zz_last.rb +2 -3
- data/spec/data/run_context/cookbooks/dependency2/attributes/default.rb +2 -3
- data/spec/data/run_context/cookbooks/no-default-attr/attributes/server.rb +2 -3
- data/spec/data/run_context/cookbooks/test-with-circular-deps/attributes/default.rb +2 -3
- data/spec/data/run_context/cookbooks/test-with-deps/attributes/default.rb +2 -3
- data/spec/functional/assets/chocolatey_feed/test-A.1.0.nupkg +0 -0
- data/spec/functional/assets/chocolatey_feed/test-A.1.5.nupkg +0 -0
- data/spec/functional/assets/chocolatey_feed/test-A.2.0.nupkg +0 -0
- data/spec/functional/assets/chocolatey_feed/test-B.1.0.nupkg +0 -0
- data/spec/functional/resource/dsc_script_spec.rb +1 -0
- data/spec/functional/resource/package_spec.rb +1 -1
- data/spec/functional/resource/template_spec.rb +3 -3
- data/spec/functional/shell_spec.rb +1 -1
- data/spec/integration/knife/client_bulk_delete_spec.rb +130 -0
- data/spec/integration/knife/client_create_spec.rb +69 -0
- data/spec/integration/knife/client_delete_spec.rb +63 -0
- data/spec/integration/knife/client_key_create_spec.rb +65 -0
- data/spec/integration/knife/client_key_delete_spec.rb +42 -0
- data/spec/integration/knife/client_key_list_spec.rb +60 -0
- data/spec/integration/knife/client_key_show_spec.rb +44 -0
- data/spec/integration/knife/client_list_spec.rb +48 -0
- data/spec/integration/knife/client_show_spec.rb +36 -0
- data/spec/integration/knife/cookbook_bulk_delete_spec.rb +64 -0
- data/spec/integration/knife/cookbook_download_spec.rb +95 -0
- data/spec/integration/knife/cookbook_list_spec.rb +54 -0
- data/spec/integration/knife/cookbook_show_spec.rb +159 -0
- data/spec/integration/knife/cookbook_upload_spec.rb +90 -0
- data/spec/integration/knife/data_bag_create_spec.rb +58 -0
- data/spec/integration/knife/data_bag_delete_spec.rb +58 -0
- data/spec/integration/knife/data_bag_from_file_spec.rb +115 -0
- data/spec/integration/knife/data_bag_list_spec.rb +43 -0
- data/spec/integration/knife/data_bag_show_spec.rb +53 -0
- data/spec/integration/knife/environment_compare_spec.rb +74 -0
- data/spec/integration/knife/environment_create_spec.rb +40 -0
- data/spec/integration/knife/environment_delete_spec.rb +36 -0
- data/spec/integration/knife/environment_from_file_spec.rb +115 -0
- data/spec/integration/knife/environment_list_spec.rb +41 -0
- data/spec/integration/knife/environment_show_spec.rb +56 -0
- data/spec/integration/knife/node_bulk_delete_spec.rb +51 -0
- data/spec/integration/knife/node_create_spec.rb +46 -0
- data/spec/integration/knife/node_delete_spec.rb +47 -0
- data/spec/integration/knife/node_environment_set_spec.rb +42 -0
- data/spec/integration/knife/node_from_file_spec.rb +58 -0
- data/spec/integration/knife/node_list_spec.rb +44 -0
- data/spec/integration/knife/node_run_list_add_spec.rb +53 -0
- data/spec/integration/knife/node_run_list_remove_spec.rb +35 -0
- data/spec/integration/knife/node_run_list_set_spec.rb +40 -0
- data/spec/integration/knife/node_show_spec.rb +35 -0
- data/spec/integration/knife/role_bulk_delete_spec.rb +51 -0
- data/spec/integration/knife/role_create_spec.rb +40 -0
- data/spec/integration/knife/role_delete_spec.rb +47 -0
- data/spec/integration/knife/role_from_file_spec.rb +95 -0
- data/spec/integration/knife/role_list_spec.rb +44 -0
- data/spec/integration/knife/role_show_spec.rb +50 -0
- data/spec/support/shared/integration/knife_support.rb +10 -3
- data/spec/unit/application/solo_spec.rb +7 -0
- data/spec/unit/cookbook_version_spec.rb +4 -4
- data/spec/unit/data_collector/messages/helpers_spec.rb +3 -7
- data/spec/unit/data_collector/messages_spec.rb +28 -45
- data/spec/unit/data_collector_spec.rb +40 -47
- data/spec/unit/knife/cookbook_create_spec.rb +1 -0
- data/spec/unit/knife/cookbook_site_download_spec.rb +1 -0
- data/spec/unit/knife/node_environment_set_spec.rb +0 -24
- data/spec/unit/knife/node_run_list_set_spec.rb +0 -25
- data/spec/unit/node/attribute_spec.rb +7 -9
- data/spec/unit/node/immutable_collections_spec.rb +4 -0
- data/spec/unit/node/vivid_mash_spec.rb +344 -0
- data/spec/unit/node_spec.rb +115 -26
- data/spec/unit/provider/directory_spec.rb +11 -1
- data/spec/unit/provider/package/windows/exe_spec.rb +14 -9
- data/spec/unit/provider/powershell_script_spec.rb +4 -4
- data/spec/unit/provider/remote_directory_spec.rb +15 -0
- data/spec/unit/recipe_spec.rb +31 -6
- data/spec/unit/run_context_spec.rb +2 -2
- data/spec/unit/shell/shell_session_spec.rb +1 -1
- data/tasks/dependencies.rb +0 -2
- metadata +55 -786
- data/acceptance/.bundle/config +0 -2
- data/acceptance/basics/.kitchen/logs/chef-current-install-ubuntu-1404.log +0 -2
- data/acceptance/basics/.kitchen/logs/kitchen.log +0 -3
- data/acceptance/fips/.kitchen/logs/fips-integration-centos-6.log +0 -3
- data/acceptance/fips/.kitchen/logs/fips-integration-windows-2012r2.log +0 -3
- data/acceptance/fips/.kitchen/logs/fips-unit-functional-centos-6.log +0 -3
- data/acceptance/fips/.kitchen/logs/fips-unit-functional-windows-2012r2.log +0 -3
- data/acceptance/fips/.kitchen/logs/kitchen.log +0 -6
- data/acceptance/trivial/.kitchen/logs/chef-current-install-windows-2012r2.log +0 -2
- data/acceptance/trivial/.kitchen/logs/kitchen.log +0 -3
- data/acceptance/windows-service/.kitchen/logs/chef-windows-service-windows-2012r2.log +0 -2
- data/acceptance/windows-service/.kitchen/logs/kitchen.log +0 -3
@@ -0,0 +1,63 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2013-2016, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require "support/shared/integration/integration_helper"
|
18
|
+
require "support/shared/context/config"
|
19
|
+
|
20
|
+
describe "knife client delete", :workstation do
|
21
|
+
include IntegrationSupport
|
22
|
+
include KnifeSupport
|
23
|
+
|
24
|
+
include_context "default config options"
|
25
|
+
|
26
|
+
when_the_chef_server "has some clients" do
|
27
|
+
before do
|
28
|
+
client "cons", {}
|
29
|
+
client "car", {}
|
30
|
+
client "car-validator", { validator: true }
|
31
|
+
client "cdr", {}
|
32
|
+
client "cat", {}
|
33
|
+
end
|
34
|
+
|
35
|
+
it "deletes a client" do
|
36
|
+
knife("client delete car", input: "Y").should_succeed <<EOM
|
37
|
+
Do you really want to delete car? (Y/N) Deleted client[car]
|
38
|
+
EOM
|
39
|
+
|
40
|
+
knife("client list").should_succeed <<EOM
|
41
|
+
car-validator
|
42
|
+
cat
|
43
|
+
cdr
|
44
|
+
chef-validator
|
45
|
+
chef-webui
|
46
|
+
cons
|
47
|
+
EOM
|
48
|
+
end
|
49
|
+
|
50
|
+
it "refuses to delete a validator normally" do
|
51
|
+
knife("client delete car-validator", input: "Y").should_fail exit_code: 2, stdout: "Do you really want to delete car-validator? (Y/N) ", stderr: <<EOM
|
52
|
+
FATAL: You must specify --delete-validators to delete the validator client car-validator
|
53
|
+
EOM
|
54
|
+
end
|
55
|
+
|
56
|
+
it "deletes a validator correctly" do
|
57
|
+
knife("client delete car-validator -D", input: "Y").should_succeed <<EOM
|
58
|
+
Do you really want to delete car-validator? (Y/N) Deleted client[car-validator]
|
59
|
+
EOM
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2013-2016, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require "support/shared/integration/integration_helper"
|
18
|
+
require "support/shared/context/config"
|
19
|
+
require "openssl"
|
20
|
+
|
21
|
+
describe "knife client key create", :workstation do
|
22
|
+
include IntegrationSupport
|
23
|
+
include KnifeSupport
|
24
|
+
|
25
|
+
include_context "default config options"
|
26
|
+
|
27
|
+
let(:out) { "Created key: new" }
|
28
|
+
|
29
|
+
when_the_chef_server "has a client" do
|
30
|
+
before do
|
31
|
+
client "bah", {}
|
32
|
+
end
|
33
|
+
|
34
|
+
it "creates a new client key" do
|
35
|
+
knife("client key create -k new bah").should_succeed stderr: /^#{out}/, stdout: /.*BEGIN RSA PRIVATE KEY/
|
36
|
+
end
|
37
|
+
|
38
|
+
it "creates a new client key with an expiration date" do
|
39
|
+
date = "2017-12-31T23:59:59Z"
|
40
|
+
knife("client key create -k new -e #{date} bah").should_succeed stderr: /^#{out}/, stdout: /.*BEGIN RSA PRIVATE KEY/
|
41
|
+
knife("client key show bah new").should_succeed /expiration_date:.*#{date}/
|
42
|
+
end
|
43
|
+
|
44
|
+
it "refuses to add an already existing key" do
|
45
|
+
knife("client key create -k new bah")
|
46
|
+
expect { knife("client key create -k new bah") }.to raise_error(Net::HTTPServerException)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "saves the private key to a file" do
|
50
|
+
Dir.mktmpdir do |tgt|
|
51
|
+
knife("client key create -f #{tgt}/bah.pem -k new bah").should_succeed stderr: /^#{out}/
|
52
|
+
expect(File).to exist("#{tgt}/bah.pem")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it "reads the public key from a file" do
|
57
|
+
Dir.mktmpdir do |tgt|
|
58
|
+
key = OpenSSL::PKey::RSA.generate(1024)
|
59
|
+
File.open("#{tgt}/public.pem", "w") { |pub| pub.write(key.public_key.to_pem) }
|
60
|
+
knife("client key create -p #{tgt}/public.pem -k new bah").should_succeed stderr: /^#{out}/
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2013-2016, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require "support/shared/integration/integration_helper"
|
18
|
+
require "support/shared/context/config"
|
19
|
+
|
20
|
+
describe "knife client key delete", :workstation do
|
21
|
+
include IntegrationSupport
|
22
|
+
include KnifeSupport
|
23
|
+
|
24
|
+
include_context "default config options"
|
25
|
+
|
26
|
+
when_the_chef_server "has a client" do
|
27
|
+
before do
|
28
|
+
client "car", {}
|
29
|
+
end
|
30
|
+
|
31
|
+
it "deletes a client" do
|
32
|
+
out = "Do you really want to delete the key named new for the client named car? (Y/N) "
|
33
|
+
knife("client key create -k new car")
|
34
|
+
knife("client key delete car new", input: "Y").should_succeed stdout: out, stderr: <<EOM
|
35
|
+
Deleted key named new for the client named car
|
36
|
+
EOM
|
37
|
+
|
38
|
+
knife("client key list car").should_succeed ""
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2013-2016, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require "support/shared/integration/integration_helper"
|
18
|
+
require "support/shared/context/config"
|
19
|
+
require "date"
|
20
|
+
|
21
|
+
describe "knife client key list", :workstation do
|
22
|
+
include IntegrationSupport
|
23
|
+
include KnifeSupport
|
24
|
+
|
25
|
+
include_context "default config options"
|
26
|
+
|
27
|
+
let(:now) { DateTime.now }
|
28
|
+
let(:last_month) { (now << 1).strftime("%FT%TZ") }
|
29
|
+
let(:next_month) { (now >> 1).strftime("%FT%TZ") }
|
30
|
+
|
31
|
+
when_the_chef_server "has a client" do
|
32
|
+
before do
|
33
|
+
client "cons", {}
|
34
|
+
knife("client key create cons -k new")
|
35
|
+
knife("client key create cons -k next_month -e #{next_month}")
|
36
|
+
knife("client key create cons -k expired -e #{last_month}")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "lists the keys for a client" do
|
40
|
+
knife("client key list cons").should_succeed "expired\nnew\nnext_month\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "shows detailed output" do
|
44
|
+
knife("client key list -w cons").should_succeed <<EOM
|
45
|
+
expired: http://127.0.0.1:8900/clients/cons/keys/expired (expired)
|
46
|
+
new: http://127.0.0.1:8900/clients/cons/keys/new
|
47
|
+
next_month: http://127.0.0.1:8900/clients/cons/keys/next_month
|
48
|
+
EOM
|
49
|
+
end
|
50
|
+
|
51
|
+
it "lists the expired keys for a client" do
|
52
|
+
knife("client key list -e cons").should_succeed "expired\n"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "lists the unexpired keys for a client" do
|
56
|
+
knife("client key list -n cons").should_succeed "new\nnext_month\n"
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2013-2016, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require "support/shared/integration/integration_helper"
|
18
|
+
require "support/shared/context/config"
|
19
|
+
require "date"
|
20
|
+
|
21
|
+
describe "knife client key show", :workstation do
|
22
|
+
include IntegrationSupport
|
23
|
+
include KnifeSupport
|
24
|
+
|
25
|
+
include_context "default config options"
|
26
|
+
|
27
|
+
let(:now) { DateTime.now }
|
28
|
+
let(:last_month) { (now << 1).strftime("%FT%TZ") }
|
29
|
+
let(:next_month) { (now >> 1).strftime("%FT%TZ") }
|
30
|
+
|
31
|
+
when_the_chef_server "has a client" do
|
32
|
+
before do
|
33
|
+
client "cons", {}
|
34
|
+
knife("client key create cons -k new")
|
35
|
+
knife("client key create cons -k next_month -e #{next_month}")
|
36
|
+
knife("client key create cons -k expired -e #{last_month}")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "shows a key for a client" do
|
40
|
+
knife("client key show cons new").should_succeed stdout: /.*name:.*new/
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2013-2016, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require "support/shared/integration/integration_helper"
|
18
|
+
require "support/shared/context/config"
|
19
|
+
|
20
|
+
describe "knife client list", :workstation do
|
21
|
+
include IntegrationSupport
|
22
|
+
include KnifeSupport
|
23
|
+
|
24
|
+
include_context "default config options"
|
25
|
+
|
26
|
+
when_the_chef_server "has some clients" do
|
27
|
+
before do
|
28
|
+
client "cons", {}
|
29
|
+
client "car", {}
|
30
|
+
client "car-validator", { validator: true }
|
31
|
+
client "cdr", {}
|
32
|
+
client "cat", {}
|
33
|
+
end
|
34
|
+
|
35
|
+
it "lists the clients" do
|
36
|
+
knife("client list").should_succeed <<EOM
|
37
|
+
car
|
38
|
+
car-validator
|
39
|
+
cat
|
40
|
+
cdr
|
41
|
+
chef-validator
|
42
|
+
chef-webui
|
43
|
+
cons
|
44
|
+
EOM
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2013-2016, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require "support/shared/integration/integration_helper"
|
18
|
+
require "support/shared/context/config"
|
19
|
+
|
20
|
+
describe "knife client show", :workstation do
|
21
|
+
include IntegrationSupport
|
22
|
+
include KnifeSupport
|
23
|
+
|
24
|
+
include_context "default config options"
|
25
|
+
|
26
|
+
when_the_chef_server "has a client" do
|
27
|
+
before do
|
28
|
+
client "cons", {}
|
29
|
+
end
|
30
|
+
|
31
|
+
it "shows a client" do
|
32
|
+
knife("client show cons").should_succeed stdout: /.*name:.*cons/
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2013-2016, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require "support/shared/integration/integration_helper"
|
18
|
+
require "support/shared/context/config"
|
19
|
+
require "chef/knife/cookbook_bulk_delete"
|
20
|
+
|
21
|
+
describe "knife cookbook bulk delete", :workstation do
|
22
|
+
include IntegrationSupport
|
23
|
+
include KnifeSupport
|
24
|
+
|
25
|
+
include_context "default config options"
|
26
|
+
|
27
|
+
when_the_chef_server "has a cookbook" do
|
28
|
+
before do
|
29
|
+
cookbook "foo", "1.0.0"
|
30
|
+
cookbook "foo", "0.6.5"
|
31
|
+
cookbook "fox", "0.6.0"
|
32
|
+
cookbook "fox", "0.6.5"
|
33
|
+
cookbook "fax", "0.6.0"
|
34
|
+
cookbook "zfa", "0.6.5"
|
35
|
+
end
|
36
|
+
|
37
|
+
# rubocop:disable Style/TrailingWhitespace
|
38
|
+
it "knife cookbook bulk delete deletes all matching cookbooks" do
|
39
|
+
stdout = <<EOM
|
40
|
+
All versions of the following cookbooks will be deleted:
|
41
|
+
|
42
|
+
foo fox
|
43
|
+
|
44
|
+
Do you really want to delete these cookbooks? (Y/N)
|
45
|
+
EOM
|
46
|
+
|
47
|
+
stderr = <<EOM
|
48
|
+
Deleted cookbook foo [1.0.0]
|
49
|
+
Deleted cookbook foo [0.6.5]
|
50
|
+
Deleted cookbook fox [0.6.5]
|
51
|
+
Deleted cookbook fox [0.6.0]
|
52
|
+
EOM
|
53
|
+
|
54
|
+
knife("cookbook bulk delete ^fo.*", input: "Y").should_succeed(stderr: stderr, stdout: stdout)
|
55
|
+
|
56
|
+
knife("cookbook list -a").should_succeed <<EOM
|
57
|
+
fax 0.6.0
|
58
|
+
zfa 0.6.5
|
59
|
+
EOM
|
60
|
+
end
|
61
|
+
# rubocop:enable Style/TrailingWhitespace
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2013-2016, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require "support/shared/integration/integration_helper"
|
18
|
+
require "support/shared/context/config"
|
19
|
+
require "chef/knife/cookbook_download"
|
20
|
+
require "tmpdir"
|
21
|
+
|
22
|
+
describe "knife cookbook download", :workstation do
|
23
|
+
include IntegrationSupport
|
24
|
+
include KnifeSupport
|
25
|
+
|
26
|
+
include_context "default config options"
|
27
|
+
|
28
|
+
let(:tmpdir) { Dir.mktmpdir }
|
29
|
+
|
30
|
+
when_the_chef_server "has only one cookbook" do
|
31
|
+
before do
|
32
|
+
cookbook "x", "1.0.1"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "knife cookbook download downloads the latest version" do
|
36
|
+
knife("cookbook download -d #{tmpdir} x").should_succeed stderr: <<EOM
|
37
|
+
Downloading x cookbook version 1.0.1
|
38
|
+
Downloading resources
|
39
|
+
Downloading providers
|
40
|
+
Downloading recipes
|
41
|
+
Downloading definitions
|
42
|
+
Downloading libraries
|
43
|
+
Downloading attributes
|
44
|
+
Downloading files
|
45
|
+
Downloading templates
|
46
|
+
Downloading root_files
|
47
|
+
Cookbook downloaded to #{tmpdir}/x-1.0.1
|
48
|
+
EOM
|
49
|
+
end
|
50
|
+
|
51
|
+
it "knife cookbook download with a version downloads the specified version" do
|
52
|
+
knife("cookbook download -d #{tmpdir} x 1.0.1").should_succeed stderr: <<EOM
|
53
|
+
Downloading x cookbook version 1.0.1
|
54
|
+
Downloading resources
|
55
|
+
Downloading providers
|
56
|
+
Downloading recipes
|
57
|
+
Downloading definitions
|
58
|
+
Downloading libraries
|
59
|
+
Downloading attributes
|
60
|
+
Downloading files
|
61
|
+
Downloading templates
|
62
|
+
Downloading root_files
|
63
|
+
Cookbook downloaded to #{tmpdir}/x-1.0.1
|
64
|
+
EOM
|
65
|
+
end
|
66
|
+
|
67
|
+
it "knife cookbook download with an unknown version raises an error" do
|
68
|
+
expect { knife("cookbook download -d #{tmpdir} x 1.0.0") }.to raise_error(Net::HTTPServerException)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
when_the_chef_server "has multiple cookbook versions" do
|
73
|
+
before do
|
74
|
+
cookbook "x", "1.0.1"
|
75
|
+
cookbook "x", "1.0.0"
|
76
|
+
end
|
77
|
+
|
78
|
+
it "knife cookbook download with no version prompts" do
|
79
|
+
knife("cookbook download -d #{tmpdir} x", input: "2\n").should_succeed(stderr: <<EOM, stdout: "Which version do you want to download?\n1. x 1.0.0\n2. x 1.0.1\n\n"
|
80
|
+
Downloading x cookbook version 1.0.1
|
81
|
+
Downloading resources
|
82
|
+
Downloading providers
|
83
|
+
Downloading recipes
|
84
|
+
Downloading definitions
|
85
|
+
Downloading libraries
|
86
|
+
Downloading attributes
|
87
|
+
Downloading files
|
88
|
+
Downloading templates
|
89
|
+
Downloading root_files
|
90
|
+
Cookbook downloaded to #{tmpdir}/x-1.0.1
|
91
|
+
EOM
|
92
|
+
)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|