chef 11.12.8 → 11.14.0.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- 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 +164 -151
- 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/spec/spec_helper.rb
CHANGED
@@ -82,6 +82,7 @@ require 'spec/support/platform_helpers'
|
|
82
82
|
# Do not change the gsub.
|
83
83
|
Dir["spec/support/**/*.rb"].
|
84
84
|
reject { |f| f =~ %r{^spec/support/platforms} }.
|
85
|
+
reject { |f| f =~ %r{^spec/support/pedant} }.
|
85
86
|
map { |f| f.gsub(%r{.rb$}, '') }.
|
86
87
|
map { |f| f.gsub(%r[spec/], '')}.
|
87
88
|
each { |f| require f }
|
@@ -98,6 +99,7 @@ RSpec.configure do |config|
|
|
98
99
|
|
99
100
|
# Tests that randomly fail, but may have value.
|
100
101
|
config.filter_run_excluding :volatile => true
|
102
|
+
config.filter_run_excluding :volatile_on_solaris => true if solaris?
|
101
103
|
|
102
104
|
# Add jruby filters here
|
103
105
|
config.filter_run_excluding :windows_only => true unless windows?
|
@@ -8,6 +8,13 @@
|
|
8
8
|
def platform_mock(platform = :unix, &block)
|
9
9
|
Chef::Platform.stub(:windows?).and_return(platform == :windows ? true : false)
|
10
10
|
ENV['SYSTEMDRIVE'] = (platform == :windows ? 'C:' : nil)
|
11
|
+
|
12
|
+
if platform == :windows
|
13
|
+
Chef::Config.set_defaults_for_windows
|
14
|
+
else
|
15
|
+
Chef::Config.set_defaults_for_nix
|
16
|
+
end
|
17
|
+
|
11
18
|
if block_given?
|
12
19
|
mock_constants({"RUBY_PLATFORM" => (platform == :windows ? 'i386-mingw32' : 'x86_64-darwin11.2.0'),
|
13
20
|
"File::PATH_SEPARATOR" => (platform == :windows ? ";" : ":"),
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# Copyright: Copyright (c) 2012 Opscode, Inc.
|
2
|
+
# License: Apache License, Version 2.0
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
# This annotated Pedant configuration file details the various
|
17
|
+
# configuration settings available to you. It is separate from the
|
18
|
+
# actual Pedant::Config class because not all settings have sane
|
19
|
+
# defaults, and not all settings are appropriate in all settings.
|
20
|
+
|
21
|
+
################################################################################
|
22
|
+
# You MUST specify the address of the server the API requests will be
|
23
|
+
# sent to. Only specify protocol, hostname, and port.
|
24
|
+
chef_server 'http://127.0.0.1:8889'
|
25
|
+
|
26
|
+
# If you are doing development testing, you can specify the address of
|
27
|
+
# the Solr server. The presence of this parameter will enable tests
|
28
|
+
# to force commits to Solr, greatly decreasing the amout of time
|
29
|
+
# needed for testing the search endpoint. This is only an
|
30
|
+
# optimization for development! If you are testing a "live" Chef
|
31
|
+
# Server, or otherwise do not have access to the Solr server from your
|
32
|
+
# testing location, you should not specify a value for this parameter.
|
33
|
+
# The tests will still run, albeit slower, as they will now need to
|
34
|
+
# poll for a period to ensure they are querying committed results.
|
35
|
+
#search_server "http://localhost:8983"
|
36
|
+
|
37
|
+
# Related to the 'search_server' parameter, this specifies the maximum
|
38
|
+
# amout of time (in seconds) that search endpoint requests should be
|
39
|
+
# retried before giving up. If not explicitly set, it will default to
|
40
|
+
# 65 seconds; only set it if you know that your Solr commit interval
|
41
|
+
# differs significantly from this.
|
42
|
+
maximum_search_time 0
|
43
|
+
|
44
|
+
# OSC sends erchef a host header with a port, so this option needs
|
45
|
+
# # to be enabled for Pedant tests to work correctly
|
46
|
+
explicit_port_url true
|
47
|
+
|
48
|
+
# We're starting to break tests up into groups based on different
|
49
|
+
# criteria. The proper API tests (the results of which are viewable
|
50
|
+
# to OPC customers) should be the only ones run by Pedant embedded in
|
51
|
+
# OPC installs. There are other specs that help us keep track of API
|
52
|
+
# cruft that we want to come back and fix later; these shouldn't be
|
53
|
+
# viewable to customers, but we should be able to run them in
|
54
|
+
# development and CI environments. If this parameter is missing or
|
55
|
+
# explicitly `false` only the customer-friendly tests will be run.
|
56
|
+
#
|
57
|
+
# This is mainly here for documentation purposes, since the
|
58
|
+
# command-line `opscode-pedant` utility ultimately determines this
|
59
|
+
# value.
|
60
|
+
include_internal false
|
61
|
+
|
62
|
+
# Test users. The five users specified below are required; their
|
63
|
+
# names (:user, :non_org_user, etc.) are indicative of their role
|
64
|
+
# within the tests. All users must have a ':name' key. If they have
|
65
|
+
# a ':create_me' key, Pedant will create these users for you. If you
|
66
|
+
# are using pre-existing users, you must supply a ':key_file' key,
|
67
|
+
# which should be the fully-qualified path /on the machine Pedant is
|
68
|
+
# running on/ to a private key for that user.
|
69
|
+
key = 'spec/support/pedant/stickywicket.pem'
|
70
|
+
superuser_name 'admin'
|
71
|
+
superuser_key key
|
72
|
+
webui_key key
|
73
|
+
|
74
|
+
# Set the platform_class
|
75
|
+
platform_class Pedant::OpenSourcePlatform
|
76
|
+
|
77
|
+
requestors({
|
78
|
+
:clients => {
|
79
|
+
# The the admin user, for the purposes of getting things rolling
|
80
|
+
:admin => {
|
81
|
+
:name => "pedant_admin_client",
|
82
|
+
:create_me => true,
|
83
|
+
:create_knife => true,
|
84
|
+
:admin => true
|
85
|
+
},
|
86
|
+
:non_admin => {
|
87
|
+
:name => 'pedant_client',
|
88
|
+
:create_me => true,
|
89
|
+
:create_knife => true
|
90
|
+
},
|
91
|
+
:bad => {
|
92
|
+
:name => 'bad_client',
|
93
|
+
:bogus => true
|
94
|
+
}
|
95
|
+
},
|
96
|
+
:users => {
|
97
|
+
:admin => {
|
98
|
+
:name => "admin",
|
99
|
+
:key_file => key,
|
100
|
+
:create_me => false,
|
101
|
+
:create_knife => false,
|
102
|
+
:admin => true
|
103
|
+
},
|
104
|
+
:non_admin => {
|
105
|
+
:name => "pedant_non_admin_user",
|
106
|
+
:create_me => true,
|
107
|
+
:create_knife => true,
|
108
|
+
:admin => false
|
109
|
+
},
|
110
|
+
# A user for Knife tests. A knife.rb and key files will be set up
|
111
|
+
# for this user
|
112
|
+
:knife_user => {
|
113
|
+
:name => "knifey",
|
114
|
+
:create_me => true,
|
115
|
+
:create_knife => true
|
116
|
+
}
|
117
|
+
}
|
118
|
+
})
|
119
|
+
|
120
|
+
self[:tags] = [:validation, :authentication, :authorization]
|
121
|
+
verify_error_messages false
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'bundler'
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'chef_zero/server'
|
5
|
+
require 'rspec/core'
|
6
|
+
require 'chef/chef_fs/chef_fs_data_store'
|
7
|
+
require 'chef/chef_fs/config'
|
8
|
+
require 'tmpdir'
|
9
|
+
require 'fileutils'
|
10
|
+
require 'chef/version'
|
11
|
+
|
12
|
+
def start_server(chef_repo_path)
|
13
|
+
Dir.mkdir(chef_repo_path) if !File.exists?(chef_repo_path)
|
14
|
+
|
15
|
+
# 11.6 and below had a bug where it couldn't create the repo children automatically
|
16
|
+
if Chef::VERSION.to_f < 11.8
|
17
|
+
%w(clients cookbooks data_bags environments nodes roles users).each do |child|
|
18
|
+
Dir.mkdir("#{chef_repo_path}/#{child}") if !File.exists?("#{chef_repo_path}/#{child}")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Start the new server
|
23
|
+
Chef::Config.repo_mode = 'everything'
|
24
|
+
Chef::Config.chef_repo_path = chef_repo_path
|
25
|
+
Chef::Config.versioned_cookbooks = true
|
26
|
+
chef_fs = Chef::ChefFS::Config.new.local_fs
|
27
|
+
data_store = Chef::ChefFS::ChefFSDataStore.new(chef_fs)
|
28
|
+
server = ChefZero::Server.new(:port => 8889, :data_store => data_store)#, :log_level => :debug)
|
29
|
+
server.start_background
|
30
|
+
server
|
31
|
+
end
|
32
|
+
|
33
|
+
tmpdir = Dir.mktmpdir
|
34
|
+
begin
|
35
|
+
# Create chef repository
|
36
|
+
chef_repo_path = "#{tmpdir}/repo"
|
37
|
+
|
38
|
+
# Capture setup data into master_chef_repo_path
|
39
|
+
server = start_server(chef_repo_path)
|
40
|
+
|
41
|
+
require 'pedant'
|
42
|
+
require 'pedant/opensource'
|
43
|
+
|
44
|
+
#Pedant::Config.rerun = true
|
45
|
+
|
46
|
+
Pedant.config.suite = 'api'
|
47
|
+
Pedant.config[:config_file] = 'spec/support/pedant/pedant_config.rb'
|
48
|
+
Pedant.setup([
|
49
|
+
'--skip-knife',
|
50
|
+
'--skip-validation',
|
51
|
+
'--skip-authentication',
|
52
|
+
'--skip-authorization',
|
53
|
+
'--skip-omnibus'
|
54
|
+
])
|
55
|
+
|
56
|
+
result = RSpec::Core::Runner.run(Pedant.config.rspec_args)
|
57
|
+
|
58
|
+
server.stop if server.running?
|
59
|
+
ensure
|
60
|
+
FileUtils.remove_entry_secure(tmpdir) if tmpdir
|
61
|
+
end
|
62
|
+
|
63
|
+
exit(result)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
-----BEGIN RSA PRIVATE KEY-----
|
2
|
+
MIIEpQIBAAKCAQEApNCkX2k+lFGDWRVhX4uClaVQrumG9XXvk6X7M2izrIg7RzMP
|
3
|
+
Dk4thhZkpx5gr22By7PZQdMEjWC/Zo8MBjtoJ0GV0jw8npefbU1MGKs2dtpYgo0N
|
4
|
+
Fq8fX8MdFPu4h2W3g0dMEdhT8icc2H4EjhZmdeUhUn3RIEt2duCgp3YDYnUUZx3j
|
5
|
+
N7MHcTIdzD58ikr6zQrZzHOv+OOI86Xk9EpyEEQizOLoQxkICNrhqN7ElQDuvXaX
|
6
|
+
BSBrYDRKH2umBMMcXzvsR/SvkmqxoEESSpIlW8zeKAWQ+znNjDC0tmTg7jZmgSP7
|
7
|
+
siKrwo4t4ebjcmjpIoi/JKww/nGN3Uhz1ZOZuwIDAQABAoIBAQCaJQD2s0nyEeKU
|
8
|
+
uKhfYe155Cl3zbWJcQnmv4AXbr9MiAVY6+oS6Q8ur1bn7kNjDzoruENjiuZhC7E3
|
9
|
+
TGZklb8tp+tluyy+7vQOmBKpp8fClSfewekR5CultqhGbb8B8yIVR+NfdUHd4rLZ
|
10
|
+
z9KWyWB+txPZQQ8L80gSmrfmpzs3IuT7oPvmtBU1Wq9QapC4n/rUohHUpUV1du4G
|
11
|
+
0wCIF4zQTg6cbYW2YXozwVQvw+P7P3RVEqZt+aZlbVcy0fNr6jNao0hi1KFC9OH2
|
12
|
+
VjjU+PioreoA/NU3aZPIUzmJpWtsu31yuOZxXmytAkYooCZgiEQNEHnJlNPv0RmC
|
13
|
+
6BPMzVoBAoGBAM7yZoSNJpzdP/q1/4+H3zyy7o4I0VTW9u/GqUzhnbjm5poK30X9
|
14
|
+
YXh/7WOVV0OoVqdO6ljRKygP3Oggf41ZEbi1C6bbsO57pksBWgx9bD9V35XscZ0J
|
15
|
+
F1ERe//kMHwVQy74R8/cIuRwm75haLSBj5/fwGbLeeVDglJkCVqPjtuBAoGBAMvh
|
16
|
+
qsAGG5k9u6voTcXlFwS+B5YjULhK4NSxdJ2BnOxzYzxQ3IYQZMlb2xt8yZYx/ZZK
|
17
|
+
wjkr9rcAPEQIQZ2A6NUbGq6qCD7sSmg6UAi0CgiqTokQ/Wtag0UDvFMzwerdg/On
|
18
|
+
37uxffpxpte8z1jYi/MxRaoTYueuc1UVnqofVIM7AoGBALZJzwPzUY/bVAADUJmd
|
19
|
+
lYZiFsAGBF42/E05MOgH1GaK/ZWy/fkouDLsfK67XaK7JZk6ajLSDLG9R1kxRym6
|
20
|
+
y2FoGFtiKPfo8xIenrNhx3gCrG/jVjB9UYyXWiKNXifukr9M8/SkdBfFGWsZYqGd
|
21
|
+
fmXVMiVaFoVcce8hLxwWWEABAoGBAKcyhKX/HEj6YFqlIoqkydDAylXs1jicZ27l
|
22
|
+
rF2yum8KXZpMMdzbutuKsdAD8Ql0K6NB4a+jByuiTMn5/11cJxUEqkgM9sArZQW+
|
23
|
+
tH2+r+/VQpyTS0/rpXVGj/2nl2K1kI2T4R36e/aTl6CanWweAf9JK/lC9rxKyxg+
|
24
|
+
p6SaFuObAoGACP6TKCkp2oymXlKgdUUgPrnsaz2VAw8jD5QHtx10U4wty0C8gxsk
|
25
|
+
MLe00h09iLPyFmvJpD+MgbxV/r6RrZeVdsKdU/5LG52YgiVSTaizyy+ciEfW7xoQ
|
26
|
+
CL5EtZd8Cn5OKinBEzzFpELqunlqepIKCIDOcLKz/cjR+3a+E6Zx5Wo=
|
27
|
+
-----END RSA PRIVATE KEY-----
|
@@ -0,0 +1,242 @@
|
|
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
|
+
#
|
20
|
+
# shared code for Chef::REST and Chef::HTTP::Simple and other Chef::HTTP wrappers
|
21
|
+
#
|
22
|
+
|
23
|
+
module ChefHTTPShared
|
24
|
+
def nyan_uncompressed_filename
|
25
|
+
File.join(CHEF_SPEC_DATA, 'remote_file', 'nyan_cat.png')
|
26
|
+
end
|
27
|
+
|
28
|
+
def nyan_compressed_filename
|
29
|
+
File.join(CHEF_SPEC_DATA, 'remote_file', 'nyan_cat.png.gz')
|
30
|
+
end
|
31
|
+
|
32
|
+
def binread(file)
|
33
|
+
content = File.open(file, "rb") do |f|
|
34
|
+
f.read
|
35
|
+
end
|
36
|
+
content.force_encoding(Encoding::BINARY) if "".respond_to?(:force_encoding)
|
37
|
+
content
|
38
|
+
end
|
39
|
+
|
40
|
+
def start_tiny_server(server_opts={})
|
41
|
+
nyan_uncompressed_size = File::Stat.new(nyan_uncompressed_filename).size
|
42
|
+
nyan_compressed_size = File::Stat.new(nyan_compressed_filename).size
|
43
|
+
|
44
|
+
@server = TinyServer::Manager.new(server_opts)
|
45
|
+
@server.start
|
46
|
+
@api = TinyServer::API.instance
|
47
|
+
@api.clear
|
48
|
+
|
49
|
+
#
|
50
|
+
# trivial endpoints
|
51
|
+
#
|
52
|
+
|
53
|
+
# just a normal file
|
54
|
+
# (expected_content should be uncompressed)
|
55
|
+
@api.get("/nyan_cat.png", 200) {
|
56
|
+
File.open(nyan_uncompressed_filename, "rb") do |f|
|
57
|
+
f.read
|
58
|
+
end
|
59
|
+
}
|
60
|
+
|
61
|
+
# this ends in .gz, we do not uncompress it and drop it on the filesystem as a .gz file (the internet often lies)
|
62
|
+
# (expected_content should be compressed)
|
63
|
+
@api.get("/nyan_cat.png.gz", 200, nil, { 'Content-Type' => 'application/gzip', 'Content-Encoding' => 'gzip' } ) {
|
64
|
+
File.open(nyan_compressed_filename, "rb") do |f|
|
65
|
+
f.read
|
66
|
+
end
|
67
|
+
}
|
68
|
+
|
69
|
+
# this is an uncompressed file that was compressed by some mod_gzip-ish webserver thingy, so we will expand it
|
70
|
+
# (expected_content should be uncompressed)
|
71
|
+
@api.get("/nyan_cat_compressed.png", 200, nil, { 'Content-Type' => 'application/gzip', 'Content-Encoding' => 'gzip' } ) {
|
72
|
+
File.open(nyan_compressed_filename, "rb") do |f|
|
73
|
+
f.read
|
74
|
+
end
|
75
|
+
}
|
76
|
+
|
77
|
+
#
|
78
|
+
# endpoints that set Content-Length correctly
|
79
|
+
#
|
80
|
+
|
81
|
+
# (expected_content should be uncompressed)
|
82
|
+
@api.get("/nyan_cat_content_length.png", 200, nil,
|
83
|
+
{
|
84
|
+
'Content-Length' => nyan_uncompressed_size.to_s,
|
85
|
+
}
|
86
|
+
) {
|
87
|
+
File.open(nyan_uncompressed_filename, "rb") do |f|
|
88
|
+
f.read
|
89
|
+
end
|
90
|
+
}
|
91
|
+
|
92
|
+
# (expected_content should be uncompressed)
|
93
|
+
@api.get("/nyan_cat_content_length_compressed.png", 200, nil,
|
94
|
+
{
|
95
|
+
'Content-Length' => nyan_compressed_size.to_s,
|
96
|
+
'Content-Type' => 'application/gzip',
|
97
|
+
'Content-Encoding' => 'gzip'
|
98
|
+
}
|
99
|
+
) {
|
100
|
+
File.open(nyan_compressed_filename, "rb") do |f|
|
101
|
+
f.read
|
102
|
+
end
|
103
|
+
}
|
104
|
+
|
105
|
+
#
|
106
|
+
# endpoints that simulate truncated downloads (bad content-length header)
|
107
|
+
#
|
108
|
+
|
109
|
+
# (expected_content should be uncompressed)
|
110
|
+
@api.get("/nyan_cat_truncated.png", 200, nil,
|
111
|
+
{
|
112
|
+
'Content-Length' => (nyan_uncompressed_size + 1).to_s,
|
113
|
+
}
|
114
|
+
) {
|
115
|
+
File.open(nyan_uncompressed_filename, "rb") do |f|
|
116
|
+
f.read
|
117
|
+
end
|
118
|
+
}
|
119
|
+
|
120
|
+
# (expected_content should be uncompressed)
|
121
|
+
@api.get("/nyan_cat_truncated_compressed.png", 200, nil,
|
122
|
+
{
|
123
|
+
'Content-Length' => (nyan_compressed_size + 1).to_s,
|
124
|
+
'Content-Type' => 'application/gzip',
|
125
|
+
'Content-Encoding' => 'gzip'
|
126
|
+
}
|
127
|
+
) {
|
128
|
+
File.open(nyan_compressed_filename, "rb") do |f|
|
129
|
+
f.read
|
130
|
+
end
|
131
|
+
}
|
132
|
+
|
133
|
+
#
|
134
|
+
# in the presense of a transfer-encoding header, we must ignore the content-length (this bad content-length should work)
|
135
|
+
#
|
136
|
+
|
137
|
+
# (expected_content should be uncompressed)
|
138
|
+
@api.get("/nyan_cat_transfer_encoding.png", 200, nil,
|
139
|
+
{
|
140
|
+
'Content-Length' => (nyan_uncompressed_size + 1).to_s,
|
141
|
+
'Transfer-Encoding' => 'anything',
|
142
|
+
}
|
143
|
+
) {
|
144
|
+
File.open(nyan_uncompressed_filename, "rb") do |f|
|
145
|
+
f.read
|
146
|
+
end
|
147
|
+
}
|
148
|
+
|
149
|
+
#
|
150
|
+
# 403 with a Content-Length
|
151
|
+
#
|
152
|
+
@api.get('/forbidden', 403, 'Forbidden',
|
153
|
+
{
|
154
|
+
'Content-Length' => 'Forbidden'.bytesize.to_s
|
155
|
+
}
|
156
|
+
)
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
def stop_tiny_server
|
161
|
+
@server.stop
|
162
|
+
@server = @api = nil
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
shared_examples_for "downloading all the things" do
|
168
|
+
|
169
|
+
describe "when downloading a simple uncompressed file" do
|
170
|
+
let(:source) { 'http://localhost:9000/nyan_cat.png' }
|
171
|
+
let(:expected_content) { binread(nyan_uncompressed_filename) }
|
172
|
+
|
173
|
+
it_behaves_like "downloads requests correctly"
|
174
|
+
end
|
175
|
+
|
176
|
+
describe "when downloading a compressed file that should be left compressed" do
|
177
|
+
let(:source) { 'http://localhost:9000/nyan_cat.png.gz' }
|
178
|
+
let(:expected_content) { binread(nyan_compressed_filename) }
|
179
|
+
|
180
|
+
# its the callers responsibility to disable_gzip when downloading a .gz url
|
181
|
+
let(:http_client) { http_client_disable_gzip }
|
182
|
+
|
183
|
+
it_behaves_like "downloads requests correctly"
|
184
|
+
end
|
185
|
+
|
186
|
+
describe "when downloading a file that has been compressed by the webserver" do
|
187
|
+
let(:source) { 'http://localhost:9000/nyan_cat_compressed.png' }
|
188
|
+
let(:expected_content) { binread(nyan_uncompressed_filename) }
|
189
|
+
|
190
|
+
it_behaves_like "downloads requests correctly"
|
191
|
+
end
|
192
|
+
|
193
|
+
describe "when downloading an uncompressed file with a correct content_length" do
|
194
|
+
let(:source) { 'http://localhost:9000/nyan_cat_content_length.png' }
|
195
|
+
let(:expected_content) { binread(nyan_uncompressed_filename) }
|
196
|
+
|
197
|
+
it_behaves_like "downloads requests correctly"
|
198
|
+
end
|
199
|
+
|
200
|
+
describe "when downloading a file that has been compressed by the webserver with a correct content_length" do
|
201
|
+
let(:source) { 'http://localhost:9000/nyan_cat_content_length_compressed.png' }
|
202
|
+
let(:expected_content) { binread(nyan_uncompressed_filename) }
|
203
|
+
|
204
|
+
it_behaves_like "downloads requests correctly"
|
205
|
+
end
|
206
|
+
|
207
|
+
describe "when downloading an uncompressed file that is truncated" do
|
208
|
+
let(:source) { 'http://localhost:9000/nyan_cat_truncated.png' }
|
209
|
+
let(:expected_content) { binread(nyan_uncompressed_filename) }
|
210
|
+
|
211
|
+
it_behaves_like "validates content length and throws an exception"
|
212
|
+
end
|
213
|
+
|
214
|
+
describe "when downloading a file that has been compressed by the webserver that is truncated" do
|
215
|
+
let(:source) { 'http://localhost:9000/nyan_cat_truncated_compressed.png' }
|
216
|
+
let(:expected_content) { binread(nyan_uncompressed_filename) }
|
217
|
+
|
218
|
+
it_behaves_like "validates content length and throws an exception"
|
219
|
+
end
|
220
|
+
|
221
|
+
describe "when downloading a file that has transfer encoding set with a bad content length that should be ignored" do
|
222
|
+
let(:source) { 'http://localhost:9000/nyan_cat_transfer_encoding.png' }
|
223
|
+
let(:expected_content) { binread(nyan_uncompressed_filename) }
|
224
|
+
|
225
|
+
it_behaves_like "downloads requests correctly"
|
226
|
+
end
|
227
|
+
|
228
|
+
describe "when downloading an endpoint that 403s" do
|
229
|
+
let(:source) { 'http://localhost:9000/forbidden' }
|
230
|
+
|
231
|
+
it_behaves_like "an endpoint that 403s"
|
232
|
+
end
|
233
|
+
|
234
|
+
describe "when downloading an endpoint that 403s" do
|
235
|
+
let(:source) { 'http://localhost:9000/nyan_cat_content_length_compressed.png' }
|
236
|
+
let(:expected_content) { binread(nyan_uncompressed_filename) }
|
237
|
+
let(:source2) { 'http://localhost:9000/forbidden' }
|
238
|
+
|
239
|
+
it_behaves_like "a 403 after a successful request when reusing the request object"
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|