chef 11.12.8-x86-mingw32 → 11.14.0.alpha.2-x86-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 +4 -4
- data/Rakefile +4 -2
- data/distro/common/html/_sources/index.txt +6 -0
- data/distro/common/html/_sources/knife_ssl_check.txt +41 -0
- data/distro/common/html/_sources/knife_ssl_fetch.txt +41 -0
- data/distro/common/html/_static/basic.css +2 -5
- data/distro/common/html/_static/doctools.js +5 -14
- data/distro/common/html/_static/jquery.js +2 -154
- data/distro/common/html/_static/pygments.css +2 -2
- data/distro/common/html/_static/searchtools.js +212 -150
- data/distro/common/html/_static/underscore.js +29 -21
- data/distro/common/html/_static/websupport.js +1 -1
- data/distro/common/html/ctl_chef_client.html +15 -18
- data/distro/common/html/ctl_chef_server.html +7 -7
- data/distro/common/html/ctl_chef_shell.html +6 -6
- data/distro/common/html/ctl_chef_solo.html +7 -8
- data/distro/common/html/index.html +34 -24
- data/distro/common/html/knife.html +23 -24
- data/distro/common/html/knife_bootstrap.html +13 -9
- data/distro/common/html/knife_client.html +10 -11
- data/distro/common/html/knife_common_options.html +6 -7
- data/distro/common/html/knife_configure.html +3 -4
- data/distro/common/html/knife_cookbook.html +18 -11
- data/distro/common/html/knife_cookbook_site.html +14 -14
- data/distro/common/html/knife_data_bag.html +24 -23
- data/distro/common/html/knife_delete.html +4 -5
- data/distro/common/html/knife_deps.html +4 -5
- data/distro/common/html/knife_diff.html +6 -7
- data/distro/common/html/knife_download.html +12 -13
- data/distro/common/html/knife_edit.html +4 -5
- data/distro/common/html/knife_environment.html +8 -9
- data/distro/common/html/knife_exec.html +9 -10
- data/distro/common/html/knife_index_rebuild.html +4 -5
- data/distro/common/html/knife_list.html +8 -9
- data/distro/common/html/knife_node.html +34 -33
- data/distro/common/html/knife_raw.html +2 -3
- data/distro/common/html/knife_recipe_list.html +3 -4
- data/distro/common/html/knife_role.html +30 -29
- data/distro/common/html/knife_search.html +7 -7
- data/distro/common/html/knife_show.html +4 -5
- data/distro/common/html/knife_ssh.html +2 -3
- data/distro/common/html/knife_ssl_check.html +148 -0
- data/distro/common/html/knife_ssl_fetch.html +152 -0
- data/distro/common/html/knife_status.html +4 -5
- data/distro/common/html/knife_tag.html +2 -3
- data/distro/common/html/knife_upload.html +5 -6
- data/distro/common/html/knife_user.html +9 -10
- data/distro/common/html/knife_using.html +12 -12
- data/distro/common/html/knife_xargs.html +11 -12
- data/distro/common/html/search.html +1 -2
- data/distro/common/html/searchindex.js +1 -1
- data/distro/common/man/man1/chef-shell.1 +19 -11
- data/distro/common/man/man1/knife-bootstrap.1 +35 -19
- data/distro/common/man/man1/knife-client.1 +111 -28
- data/distro/common/man/man1/knife-configure.1 +30 -14
- data/distro/common/man/man1/knife-cookbook-site.1 +105 -22
- data/distro/common/man/man1/knife-cookbook.1 +164 -23
- data/distro/common/man/man1/knife-data-bag.1 +157 -33
- data/distro/common/man/man1/knife-delete.1 +21 -17
- data/distro/common/man/man1/knife-deps.1 +60 -16
- data/distro/common/man/man1/knife-diff.1 +37 -17
- data/distro/common/man/man1/knife-download.1 +68 -24
- data/distro/common/man/man1/knife-edit.1 +19 -15
- data/distro/common/man/man1/knife-environment.1 +105 -17
- data/distro/common/man/man1/knife-exec.1 +78 -18
- data/distro/common/man/man1/knife-index-rebuild.1 +16 -8
- data/distro/common/man/man1/knife-list.1 +39 -23
- data/distro/common/man/man1/knife-node.1 +170 -22
- data/distro/common/man/man1/knife-raw.1 +33 -13
- data/distro/common/man/man1/knife-recipe-list.1 +17 -5
- data/distro/common/man/man1/knife-role.1 +86 -18
- data/distro/common/man/man1/knife-search.1 +80 -16
- data/distro/common/man/man1/knife-show.1 +30 -14
- data/distro/common/man/man1/knife-ssh.1 +54 -14
- data/distro/common/man/man1/knife-ssl-check.1 +207 -0
- data/distro/common/man/man1/knife-ssl-fetch.1 +207 -0
- data/distro/common/man/man1/knife-status.1 +48 -12
- data/distro/common/man/man1/knife-tag.1 +30 -10
- data/distro/common/man/man1/knife-upload.1 +72 -20
- data/distro/common/man/man1/knife-user.1 +79 -23
- data/distro/common/man/man1/knife-xargs.1 +61 -53
- data/distro/common/man/man8/chef-client.8 +87 -29
- data/distro/common/man/man8/chef-solo.8 +36 -15
- data/lib/chef/application.rb +19 -14
- data/lib/chef/application/client.rb +5 -0
- data/lib/chef/application/solo.rb +5 -0
- data/lib/chef/application/windows_service_manager.rb +3 -0
- data/lib/chef/chef_fs/chef_fs_data_store.rb +72 -24
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +20 -4
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +20 -1
- data/lib/chef/chef_fs/file_system/file_system_entry.rb +10 -2
- data/lib/chef/client.rb +2 -3
- data/lib/chef/config.rb +34 -8
- data/lib/chef/cookbook/cookbook_version_loader.rb +45 -4
- data/lib/chef/cookbook_version.rb +38 -30
- data/lib/chef/dsl/recipe.rb +4 -1
- data/lib/chef/event_dispatch/base.rb +14 -0
- data/lib/chef/event_dispatch/events_output_stream.rb +29 -0
- data/lib/chef/exceptions.rb +8 -0
- data/lib/chef/formatters/base.rb +16 -45
- data/lib/chef/formatters/doc.rb +51 -26
- data/lib/chef/formatters/indentable_output_stream.rb +165 -0
- data/lib/chef/knife/node_environment_set.rb +54 -0
- data/lib/chef/knife/user_create.rb +1 -1
- data/lib/chef/monkey_patches/pathname.rb +32 -0
- data/lib/chef/node.rb +1 -1
- data/lib/chef/platform/provider_mapping.rb +345 -338
- data/lib/chef/policy_builder/expand_node_object.rb +1 -1
- data/lib/chef/policy_builder/policyfile.rb +1 -1
- data/lib/chef/provider.rb +1 -0
- data/lib/chef/provider/git.rb +1 -1
- data/lib/chef/provider/link.rb +2 -2
- data/lib/chef/provider/remote_file/content.rb +1 -1
- data/lib/chef/provider/remote_file/local_file.rb +8 -2
- data/lib/chef/provider/service/arch.rb +0 -1
- data/lib/chef/provider/service/debian.rb +0 -2
- data/lib/chef/provider/service/freebsd.rb +2 -1
- data/lib/chef/provider/service/gentoo.rb +1 -1
- data/lib/chef/provider/service/init.rb +0 -1
- data/lib/chef/provider/service/insserv.rb +0 -2
- data/lib/chef/provider/service/invokercd.rb +0 -2
- data/lib/chef/provider/service/macosx.rb +2 -1
- data/lib/chef/provider/service/redhat.rb +0 -1
- data/lib/chef/provider/service/simple.rb +1 -0
- data/lib/chef/provider/service/solaris.rb +1 -0
- data/lib/chef/provider/service/systemd.rb +1 -1
- data/lib/chef/provider/service/upstart.rb +1 -1
- data/lib/chef/provider/user.rb +9 -9
- data/lib/chef/provider/user/solaris.rb +2 -0
- data/lib/chef/resource.rb +1 -0
- data/lib/chef/resource/remote_file.rb +32 -6
- data/lib/chef/run_context.rb +22 -0
- data/lib/chef/run_lock.rb +43 -4
- data/lib/chef/version.rb +2 -2
- data/spec/functional/http/simple_spec.rb +84 -0
- data/spec/functional/resource/remote_file_spec.rb +107 -43
- data/spec/functional/rest_spec.rb +94 -0
- data/spec/functional/run_lock_spec.rb +1 -1
- data/spec/functional/win32/service_manager_spec.rb +6 -0
- data/spec/integration/knife/chef_fs_data_store_spec.rb +2 -0
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +76 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/mock/platform.rb +7 -0
- data/spec/support/pedant/pedant_config.rb +121 -0
- data/spec/support/pedant/run_pedant.rb +63 -0
- data/spec/support/pedant/stickywicket.pem +27 -0
- data/spec/support/shared/functional/http.rb +242 -0
- data/spec/support/shared/unit/api_error_inspector.rb +2 -2
- data/spec/unit/api_client_spec.rb +2 -2
- data/spec/unit/application/client_spec.rb +6 -1
- data/spec/unit/application/knife_spec.rb +4 -0
- data/spec/unit/application/solo_spec.rb +2 -0
- data/spec/unit/application_spec.rb +7 -0
- data/spec/unit/client_spec.rb +16 -0
- data/spec/unit/config_spec.rb +3 -20
- data/spec/unit/cookbook_version_spec.rb +224 -122
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +2 -2
- data/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb +2 -2
- data/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb +2 -2
- data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +2 -2
- data/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb +2 -2
- data/spec/unit/handler_spec.rb +0 -1
- data/spec/unit/knife/client_bulk_delete_spec.rb +3 -0
- data/spec/unit/knife/cookbook_bulk_delete_spec.rb +2 -0
- data/spec/unit/knife/cookbook_metadata_spec.rb +2 -2
- data/spec/unit/knife/cookbook_site_install_spec.rb +3 -1
- data/spec/unit/knife/cookbook_upload_spec.rb +10 -10
- data/spec/unit/knife/node_environment_set_spec.rb +80 -0
- data/spec/unit/knife/user_create_spec.rb +6 -4
- data/spec/unit/knife/user_edit_spec.rb +5 -0
- data/spec/unit/knife_spec.rb +3 -0
- data/spec/unit/mixin/securable_spec.rb +18 -20
- data/spec/unit/node/attribute_spec.rb +15 -2
- data/spec/unit/node/immutable_collections_spec.rb +4 -4
- data/spec/unit/provider/cron_spec.rb +14 -14
- data/spec/unit/provider/git_spec.rb +4 -4
- data/spec/unit/provider/group_spec.rb +1 -1
- data/spec/unit/provider/ohai_spec.rb +2 -2
- data/spec/unit/provider/remote_file/content_spec.rb +58 -35
- data/spec/unit/provider/remote_file/local_file_spec.rb +23 -0
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +13 -13
- data/spec/unit/resource/mount_spec.rb +0 -1
- data/spec/unit/resource/remote_file_spec.rb +29 -0
- data/spec/unit/resource_spec.rb +1 -1
- data/spec/unit/run_context_spec.rb +7 -0
- data/spec/unit/run_lock_spec.rb +98 -0
- data/spec/unit/version_constraint_spec.rb +1 -1
- metadata +166 -153
- data/distro/common/html/_static/chef.css +0 -507
- data/distro/common/html/_static/chef_logo.png +0 -0
- data/lib/chef/checksum/storage.rb +0 -18
- data/lib/chef/checksum/storage/filesystem.rb +0 -56
- data/spec/unit/checksum/storage/filesystem_spec.rb +0 -70
data/lib/chef/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
|
2
2
|
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
3
3
|
# Copyright:: Copyright (c) 2010-2011 Opscode, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
@@ -17,7 +17,7 @@
|
|
17
17
|
|
18
18
|
class Chef
|
19
19
|
CHEF_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__)))
|
20
|
-
VERSION = '11.
|
20
|
+
VERSION = '11.14.0.alpha.2'
|
21
21
|
end
|
22
22
|
|
23
23
|
# NOTE: the Chef::Version class is defined in version_class.rb
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Lamont Granquist (<lamont@getchef.com>)
|
3
|
+
# Copyright:: Copyright (c) 2014 Chef Software, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'spec_helper'
|
20
|
+
require 'tiny_server'
|
21
|
+
require 'support/shared/functional/http'
|
22
|
+
|
23
|
+
describe Chef::HTTP::Simple do
|
24
|
+
include ChefHTTPShared
|
25
|
+
|
26
|
+
let(:http_client) { described_class.new(source) }
|
27
|
+
let(:http_client_disable_gzip) { described_class.new(source, { :disable_gzip => true } ) }
|
28
|
+
|
29
|
+
before(:all) do
|
30
|
+
start_tiny_server
|
31
|
+
end
|
32
|
+
|
33
|
+
after(:all) do
|
34
|
+
stop_tiny_server
|
35
|
+
end
|
36
|
+
|
37
|
+
shared_examples_for "downloads requests correctly" do
|
38
|
+
it "successfully downloads a streaming request" do
|
39
|
+
tempfile = http_client.streaming_request(source, {})
|
40
|
+
tempfile.close
|
41
|
+
expect(Digest::MD5.hexdigest(binread(tempfile.path))).to eq(Digest::MD5.hexdigest(expected_content))
|
42
|
+
end
|
43
|
+
it "successfully does a non-streaming GET request" do
|
44
|
+
expect(Digest::MD5.hexdigest(http_client.get(source))).to eq(Digest::MD5.hexdigest(expected_content))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
shared_examples_for "validates content length and throws an exception" do
|
49
|
+
it "successfully downloads a streaming request" do
|
50
|
+
expect { http_client.streaming_request(source) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
|
51
|
+
end
|
52
|
+
it "successfully does a non-streaming GET request" do
|
53
|
+
expect { http_client.get(source) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
shared_examples_for "an endpoint that 403s" do
|
58
|
+
it "fails with a Net::HTTPServerException for a streaming request" do
|
59
|
+
expect { http_client.streaming_request(source) }.to raise_error(Net::HTTPServerException)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "fails with a Net::HTTPServerException for a GET request" do
|
63
|
+
expect { http_client.get(source) }.to raise_error(Net::HTTPServerException)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# see CHEF-5100
|
68
|
+
shared_examples_for "a 403 after a successful request when reusing the request object" do
|
69
|
+
it "fails with a Net::HTTPServerException for a streaming request" do
|
70
|
+
tempfile = http_client.streaming_request(source)
|
71
|
+
tempfile.close
|
72
|
+
expect(Digest::MD5.hexdigest(binread(tempfile.path))).to eq(Digest::MD5.hexdigest(expected_content))
|
73
|
+
expect { http_client.streaming_request(source2) }.to raise_error(Net::HTTPServerException)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "fails with a Net::HTTPServerException for a GET request" do
|
77
|
+
expect(Digest::MD5.hexdigest(http_client.get(source))).to eq(Digest::MD5.hexdigest(expected_content))
|
78
|
+
expect { http_client.get(source2) }.to raise_error(Net::HTTPServerException)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
it_behaves_like "downloading all the things"
|
83
|
+
end
|
84
|
+
|
@@ -18,8 +18,10 @@
|
|
18
18
|
|
19
19
|
require 'spec_helper'
|
20
20
|
require 'tiny_server'
|
21
|
+
require 'support/shared/functional/http'
|
21
22
|
|
22
23
|
describe Chef::Resource::RemoteFile do
|
24
|
+
include ChefHTTPShared
|
23
25
|
|
24
26
|
let(:file_cache_path) { Dir.mktmpdir }
|
25
27
|
|
@@ -52,28 +54,6 @@ describe Chef::Resource::RemoteFile do
|
|
52
54
|
|
53
55
|
let(:default_mode) { ((0100666 - File.umask) & 07777).to_s(8) }
|
54
56
|
|
55
|
-
def start_tiny_server(server_opts={})
|
56
|
-
@server = TinyServer::Manager.new(server_opts)
|
57
|
-
@server.start
|
58
|
-
@api = TinyServer::API.instance
|
59
|
-
@api.clear
|
60
|
-
@api.get("/nyan_cat.png", 200) {
|
61
|
-
File.open(File.join(CHEF_SPEC_DATA, 'remote_file', 'nyan_cat.png'), "rb") do |f|
|
62
|
-
f.read
|
63
|
-
end
|
64
|
-
}
|
65
|
-
@api.get("/nyan_cat.png.gz", 200, nil, { 'Content-Type' => 'application/gzip', 'Content-Encoding' => 'gzip' } ) {
|
66
|
-
File.open(File.join(CHEF_SPEC_DATA, 'remote_file', 'nyan_cat.png.gz'), "rb") do |f|
|
67
|
-
f.read
|
68
|
-
end
|
69
|
-
}
|
70
|
-
end
|
71
|
-
|
72
|
-
def stop_tiny_server
|
73
|
-
@server.stop
|
74
|
-
@server = @api = nil
|
75
|
-
end
|
76
|
-
|
77
57
|
context "when fetching files over HTTP" do
|
78
58
|
before(:all) do
|
79
59
|
start_tiny_server
|
@@ -98,13 +78,7 @@ describe Chef::Resource::RemoteFile do
|
|
98
78
|
|
99
79
|
context "when using normal encoding" do
|
100
80
|
let(:source) { 'http://localhost:9000/nyan_cat.png' }
|
101
|
-
let(:expected_content)
|
102
|
-
content = File.open(File.join(CHEF_SPEC_DATA, 'remote_file', 'nyan_cat.png'), "rb") do |f|
|
103
|
-
f.read
|
104
|
-
end
|
105
|
-
content.force_encoding(Encoding::BINARY) if content.respond_to?(:force_encoding)
|
106
|
-
content
|
107
|
-
end
|
81
|
+
let(:expected_content) { binread(nyan_uncompressed_filename) }
|
108
82
|
|
109
83
|
it_behaves_like "a file resource"
|
110
84
|
|
@@ -113,13 +87,7 @@ describe Chef::Resource::RemoteFile do
|
|
113
87
|
|
114
88
|
context "when using gzip encoding" do
|
115
89
|
let(:source) { 'http://localhost:9000/nyan_cat.png.gz' }
|
116
|
-
let(:expected_content)
|
117
|
-
content = File.open(File.join(CHEF_SPEC_DATA, 'remote_file', 'nyan_cat.png.gz'), "rb") do |f|
|
118
|
-
f.read
|
119
|
-
end
|
120
|
-
content.force_encoding(Encoding::BINARY) if content.respond_to?(:force_encoding)
|
121
|
-
content
|
122
|
-
end
|
90
|
+
let(:expected_content) { binread(nyan_compressed_filename) }
|
123
91
|
|
124
92
|
it_behaves_like "a file resource"
|
125
93
|
|
@@ -150,16 +118,112 @@ describe Chef::Resource::RemoteFile do
|
|
150
118
|
|
151
119
|
let(:source) { 'https://localhost:9000/nyan_cat.png' }
|
152
120
|
|
153
|
-
let(:expected_content)
|
154
|
-
content = File.open(File.join(CHEF_SPEC_DATA, 'remote_file', 'nyan_cat.png'), "rb") do |f|
|
155
|
-
f.read
|
156
|
-
end
|
157
|
-
content.force_encoding(Encoding::BINARY) if content.respond_to?(:force_encoding)
|
158
|
-
content
|
159
|
-
end
|
121
|
+
let(:expected_content) { binread(nyan_uncompressed_filename) }
|
160
122
|
|
161
123
|
it_behaves_like "a file resource"
|
162
124
|
|
163
125
|
end
|
164
126
|
|
127
|
+
context "when dealing with content length checking" do
|
128
|
+
before(:all) do
|
129
|
+
start_tiny_server
|
130
|
+
end
|
131
|
+
|
132
|
+
after(:all) do
|
133
|
+
stop_tiny_server
|
134
|
+
end
|
135
|
+
|
136
|
+
context "when downloading compressed data" do
|
137
|
+
let(:expected_content) { binread(nyan_uncompressed_filename) }
|
138
|
+
let(:source) { 'http://localhost:9000/nyan_cat_content_length_compressed.png' }
|
139
|
+
|
140
|
+
before do
|
141
|
+
File.should_not exist(path)
|
142
|
+
resource.run_action(:create)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should create the file" do
|
146
|
+
File.should exist(path)
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should mark the resource as updated" do
|
150
|
+
resource.should be_updated_by_last_action
|
151
|
+
end
|
152
|
+
|
153
|
+
it "has the correct content" do
|
154
|
+
binread(path).should == expected_content
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context "when downloding uncompressed data" do
|
159
|
+
let(:expected_content) { binread(nyan_uncompressed_filename) }
|
160
|
+
let(:source) { 'http://localhost:9000/nyan_cat_content_length.png' }
|
161
|
+
|
162
|
+
before do
|
163
|
+
File.should_not exist(path)
|
164
|
+
resource.run_action(:create)
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should create the file" do
|
168
|
+
File.should exist(path)
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should mark the resource as updated" do
|
172
|
+
resource.should be_updated_by_last_action
|
173
|
+
end
|
174
|
+
|
175
|
+
it "has the correct content" do
|
176
|
+
binread(path).should == expected_content
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
context "when downloading truncated compressed data" do
|
181
|
+
let(:source) { 'http://localhost:9000/nyan_cat_truncated_compressed.png' }
|
182
|
+
|
183
|
+
before do
|
184
|
+
File.should_not exist(path)
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should raise ContentLengthMismatch" do
|
188
|
+
lambda { resource.run_action(:create) }.should raise_error(Chef::Exceptions::ContentLengthMismatch)
|
189
|
+
#File.should_not exist(path) # XXX: CHEF-5081
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
context "when downloding truncated uncompressed data" do
|
194
|
+
let(:source) { 'http://localhost:9000/nyan_cat_truncated.png' }
|
195
|
+
|
196
|
+
before do
|
197
|
+
File.should_not exist(path)
|
198
|
+
end
|
199
|
+
|
200
|
+
it "should raise ContentLengthMismatch" do
|
201
|
+
lambda { resource.run_action(:create) }.should raise_error(Chef::Exceptions::ContentLengthMismatch)
|
202
|
+
#File.should_not exist(path) # XXX: CHEF-5081
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
context "when downloding data with transfer-encoding set" do
|
207
|
+
let(:expected_content) { binread(nyan_uncompressed_filename) }
|
208
|
+
let(:source) { 'http://localhost:9000/nyan_cat_transfer_encoding.png' }
|
209
|
+
|
210
|
+
before do
|
211
|
+
File.should_not exist(path)
|
212
|
+
resource.run_action(:create)
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should create the file" do
|
216
|
+
File.should exist(path)
|
217
|
+
end
|
218
|
+
|
219
|
+
it "should mark the resource as updated" do
|
220
|
+
resource.should be_updated_by_last_action
|
221
|
+
end
|
222
|
+
|
223
|
+
it "has the correct content" do
|
224
|
+
binread(path).should == expected_content
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
end
|
165
229
|
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Lamont Granquist (<lamont@getchef.com>)
|
3
|
+
# Copyright:: Copyright (c) 2014 Chef Software, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'spec_helper'
|
20
|
+
require 'tiny_server'
|
21
|
+
require 'support/shared/functional/http'
|
22
|
+
|
23
|
+
describe Chef::REST do
|
24
|
+
include ChefHTTPShared
|
25
|
+
|
26
|
+
let(:http_client) { described_class.new(source) }
|
27
|
+
let(:http_client_disable_gzip) { described_class.new(source, Chef::Config[:node_name], Chef::Config[:client_key], { :disable_gzip => true } ) }
|
28
|
+
|
29
|
+
shared_examples_for "downloads requests correctly" do
|
30
|
+
it "successfully downloads a streaming request" do
|
31
|
+
tempfile = http_client.streaming_request(source, {})
|
32
|
+
tempfile.close
|
33
|
+
expect(Digest::MD5.hexdigest(binread(tempfile.path))).to eq(Digest::MD5.hexdigest(expected_content))
|
34
|
+
end
|
35
|
+
|
36
|
+
it "successfully downloads a GET request" do
|
37
|
+
tempfile = http_client.get(source, {})
|
38
|
+
tempfile.close
|
39
|
+
expect(Digest::MD5.hexdigest(binread(tempfile.path))).to eq(Digest::MD5.hexdigest(expected_content))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
shared_examples_for "validates content length and throws an exception" do
|
44
|
+
it "fails validation on a streaming download" do
|
45
|
+
expect { http_client.streaming_request(source, {}) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "fails validation on a GET request" do
|
49
|
+
expect { http_client.get(source, {}) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
shared_examples_for "an endpoint that 403s" do
|
54
|
+
it "fails with a Net::HTTPServerException on a streaming download" do
|
55
|
+
expect { http_client.streaming_request(source, {}) }.to raise_error(Net::HTTPServerException)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "fails with a Net::HTTPServerException on a GET request" do
|
59
|
+
expect { http_client.get(source, {}) }.to raise_error(Net::HTTPServerException)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# see CHEF-5100
|
64
|
+
shared_examples_for "a 403 after a successful request when reusing the request object" do
|
65
|
+
it "fails with a Net::HTTPServerException on a streaming download" do
|
66
|
+
tempfile = http_client.streaming_request(source, {})
|
67
|
+
tempfile.close
|
68
|
+
expect(Digest::MD5.hexdigest(binread(tempfile.path))).to eq(Digest::MD5.hexdigest(expected_content))
|
69
|
+
expect { http_client.streaming_request(source2, {}) }.to raise_error(Net::HTTPServerException)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "fails with a Net::HTTPServerException on a GET request" do
|
73
|
+
tempfile = http_client.get(source, {})
|
74
|
+
tempfile.close
|
75
|
+
expect(Digest::MD5.hexdigest(binread(tempfile.path))).to eq(Digest::MD5.hexdigest(expected_content))
|
76
|
+
expect { http_client.get(source2, {}) }.to raise_error(Net::HTTPServerException)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
before do
|
81
|
+
Chef::Config[:node_name] = "webmonkey.example.com"
|
82
|
+
Chef::Config[:client_key] = CHEF_SPEC_DATA + "/ssl/private_key.pem"
|
83
|
+
end
|
84
|
+
|
85
|
+
before(:all) do
|
86
|
+
start_tiny_server
|
87
|
+
end
|
88
|
+
|
89
|
+
after(:all) do
|
90
|
+
stop_tiny_server
|
91
|
+
end
|
92
|
+
|
93
|
+
it_behaves_like "downloading all the things"
|
94
|
+
end
|
@@ -148,6 +148,12 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
|
|
148
148
|
service_manager.run(["-a", "install"])
|
149
149
|
end
|
150
150
|
|
151
|
+
it "should have an own-process, non-interactive type" do
|
152
|
+
status = ::Win32::Service.status("spec-service")
|
153
|
+
status[:service_type].should == "own process"
|
154
|
+
status[:interactive].should be_false
|
155
|
+
end
|
156
|
+
|
151
157
|
it "install => should say service already exists" do
|
152
158
|
service_manager.run(["-a", "install"])
|
153
159
|
@service_manager_output.grep(/already exists/).length.should > 0
|
@@ -188,6 +188,7 @@ EOM
|
|
188
188
|
when_the_repository 'is empty' do
|
189
189
|
context 'POST /TYPE/NAME' do
|
190
190
|
file 'empty.json', { 'name' => 'z' }
|
191
|
+
file 'empty_x.json', { 'name' => 'x' }
|
191
192
|
file 'empty_id.json', { 'id' => 'z' }
|
192
193
|
file 'rolestuff.json', '{"description":"hi there","name":"x"}'
|
193
194
|
file 'cookbooks_to_upload/z/metadata.rb', "version '1.0.0'"
|
@@ -211,6 +212,7 @@ EOM
|
|
211
212
|
end
|
212
213
|
|
213
214
|
it 'knife raw -z -i empty.json -m POST /data/x' do
|
215
|
+
knife("raw -z -i #{path_to('empty_x.json')} -m POST /data").should_succeed /uri/
|
214
216
|
knife("raw -z -i #{path_to('empty_id.json')} -m POST /data/x").should_succeed /"z"/
|
215
217
|
knife('list --local -Rfp /data_bags').should_succeed "/data_bags/x/\n/data_bags/x/z.json\n"
|
216
218
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'support/shared/integration/integration_helper'
|
2
|
+
require 'chef/mixin/shell_out'
|
3
|
+
|
4
|
+
describe "LWRPs with inline resources" do
|
5
|
+
extend IntegrationSupport
|
6
|
+
include Chef::Mixin::ShellOut
|
7
|
+
|
8
|
+
let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") }
|
9
|
+
|
10
|
+
# Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
|
11
|
+
# following constraints are satisfied:
|
12
|
+
# * Windows: windows can only run batch scripts as bare executables. Rubygems
|
13
|
+
# creates batch wrappers for installed gems, but we don't have batch wrappers
|
14
|
+
# in the source tree.
|
15
|
+
# * Other `chef-client` in PATH: A common case is running the tests on a
|
16
|
+
# machine that has omnibus chef installed. In that case we need to ensure
|
17
|
+
# we're running `chef-client` from the source tree and not the external one.
|
18
|
+
# cf. CHEF-4914
|
19
|
+
let(:chef_client) { "ruby #{chef_dir}/chef-client" }
|
20
|
+
|
21
|
+
when_the_repository "has a cookbook with a nested LWRP" do
|
22
|
+
directory 'cookbooks/x' do
|
23
|
+
|
24
|
+
file 'resources/do_nothing.rb', <<EOM
|
25
|
+
actions :create, :nothing
|
26
|
+
default_action :create
|
27
|
+
EOM
|
28
|
+
file 'providers/do_nothing.rb', <<EOM
|
29
|
+
action :create do
|
30
|
+
end
|
31
|
+
EOM
|
32
|
+
|
33
|
+
file 'resources/my_machine.rb', <<EOM
|
34
|
+
actions :create, :nothing
|
35
|
+
default_action :create
|
36
|
+
EOM
|
37
|
+
file 'providers/my_machine.rb', <<EOM
|
38
|
+
use_inline_resources
|
39
|
+
action :create do
|
40
|
+
x_do_nothing 'a'
|
41
|
+
x_do_nothing 'b'
|
42
|
+
end
|
43
|
+
EOM
|
44
|
+
|
45
|
+
file 'recipes/default.rb', <<EOM
|
46
|
+
x_my_machine "me"
|
47
|
+
x_my_machine "you"
|
48
|
+
EOM
|
49
|
+
|
50
|
+
end # directory 'cookbooks/x'
|
51
|
+
|
52
|
+
it "should complete with success" do
|
53
|
+
file 'config/client.rb', <<EOM
|
54
|
+
local_mode true
|
55
|
+
cookbook_path "#{path_to('cookbooks')}"
|
56
|
+
log_level :warn
|
57
|
+
EOM
|
58
|
+
|
59
|
+
result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir)
|
60
|
+
actual = result.stdout.lines.map { |l| l.chomp }.join("\n")
|
61
|
+
expected = <<EOM
|
62
|
+
* x_my_machine[me] action create
|
63
|
+
* x_do_nothing[a] action create (up to date)
|
64
|
+
* x_do_nothing[b] action create (up to date)
|
65
|
+
(up to date)
|
66
|
+
* x_my_machine[you] action create
|
67
|
+
* x_do_nothing[a] action create (up to date)
|
68
|
+
* x_do_nothing[b] action create (up to date)
|
69
|
+
(up to date)
|
70
|
+
EOM
|
71
|
+
expected = expected.lines.map { |l| l.chomp }.join("\n")
|
72
|
+
actual.should include(expected)
|
73
|
+
result.error!
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|