chef 12.13.37-universal-mingw32 → 12.14.60-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 +4 -4
- data/CONTRIBUTING.md +48 -95
- data/Gemfile +6 -1
- data/README.md +9 -11
- data/VERSION +1 -1
- data/acceptance/.shared/kitchen_acceptance/.kitchen.ec2.yml +0 -1
- data/acceptance/Gemfile +4 -7
- data/acceptance/Gemfile.lock +59 -92
- data/acceptance/basics/test/integration/helpers/serverspec/Gemfile +8 -0
- data/acceptance/data-collector/test/integration/helpers/serverspec/Gemfile +8 -0
- data/acceptance/fips/test/integration/fips-integration/serverspec/Gemfile +6 -0
- data/acceptance/fips/test/integration/fips-unit-functional/serverspec/Gemfile +4 -0
- data/chef.gemspec +3 -2
- data/lib/chef/application/client.rb +4 -4
- data/lib/chef/application/solo.rb +2 -2
- data/lib/chef/chef_fs/command_line.rb +36 -34
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -2
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system.rb +139 -137
- data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +2 -6
- data/lib/chef/cookbook/cookbook_version_loader.rb +27 -22
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/synchronizer.rb +3 -3
- data/lib/chef/cookbook_site_streaming_uploader.rb +3 -3
- data/lib/chef/cookbook_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +6 -6
- data/lib/chef/dsl/powershell.rb +1 -1
- data/lib/chef/event_dispatch/base.rb +2 -2
- data/lib/chef/exceptions.rb +1 -1
- data/lib/chef/file_cache.rb +1 -1
- data/lib/chef/formatters/base.rb +2 -2
- data/lib/chef/formatters/doc.rb +2 -2
- data/lib/chef/http.rb +48 -18
- data/lib/chef/http/auth_credentials.rb +1 -1
- data/lib/chef/http/basic_client.rb +11 -2
- data/lib/chef/http/socketless_chef_zero_client.rb +2 -2
- data/lib/chef/key.rb +55 -56
- data/lib/chef/knife.rb +70 -61
- data/lib/chef/knife/client_delete.rb +2 -2
- data/lib/chef/knife/cookbook_bulk_delete.rb +1 -1
- data/lib/chef/knife/cookbook_show.rb +1 -1
- data/lib/chef/knife/core/gem_glob_loader.rb +3 -3
- data/lib/chef/knife/search.rb +2 -2
- data/lib/chef/knife/ssh.rb +19 -21
- data/lib/chef/knife/status.rb +2 -2
- data/lib/chef/mixin/command/unix.rb +2 -2
- data/lib/chef/mixin/powershell_type_coercions.rb +1 -1
- data/lib/chef/mixin/properties.rb +3 -0
- data/lib/chef/mixin/securable.rb +2 -2
- data/lib/chef/mixin/shell_out.rb +30 -0
- data/lib/chef/mixin/uris.rb +2 -1
- data/lib/chef/mixin/windows_architecture_helper.rb +3 -4
- data/lib/chef/monkey_patches/webrick-utils.rb +2 -2
- data/lib/chef/monologger.rb +1 -1
- data/lib/chef/node.rb +2 -2
- data/lib/chef/node/attribute.rb +3 -3
- data/lib/chef/platform/provider_mapping.rb +5 -2
- data/lib/chef/property.rb +14 -3
- data/lib/chef/provider/apt_repository.rb +3 -7
- data/lib/chef/provider/apt_update.rb +4 -6
- data/lib/chef/provider/cron.rb +1 -2
- data/lib/chef/provider/dsc_script.rb +4 -4
- data/lib/chef/provider/group/usermod.rb +1 -1
- data/lib/chef/provider/link.rb +10 -3
- data/lib/chef/provider/osx_profile.rb +10 -10
- data/lib/chef/provider/package.rb +2 -12
- data/lib/chef/provider/package/rubygems.rb +17 -16
- data/lib/chef/provider/package/windows.rb +2 -0
- data/lib/chef/provider/package/windows/exe.rb +1 -1
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +0 -2
- data/lib/chef/provider/package/yum/rpm_utils.rb +8 -8
- data/lib/chef/provider/package/yum/yum_cache.rb +1 -1
- data/lib/chef/provider/remote_file/ftp.rb +2 -2
- data/lib/chef/provider/remote_file/sftp.rb +2 -2
- data/lib/chef/provider/service/debian.rb +2 -2
- data/lib/chef/provider/service/simple.rb +4 -3
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +2 -2
- data/lib/chef/provider/service/upstart.rb +8 -5
- data/lib/chef/provider/support/yum_repo.erb +125 -0
- data/lib/chef/provider/systemd_unit.rb +11 -2
- data/lib/chef/provider/template_finder.rb +1 -1
- data/lib/chef/provider/user.rb +20 -16
- data/lib/chef/provider/user/aix.rb +5 -2
- data/lib/chef/provider/user/dscl.rb +1 -0
- data/lib/chef/provider/user/linux.rb +128 -0
- data/lib/chef/provider/user/pw.rb +2 -1
- data/lib/chef/provider/user/solaris.rb +3 -2
- data/lib/chef/provider/user/useradd.rb +5 -4
- data/lib/chef/provider/user/windows.rb +1 -1
- data/lib/chef/provider/windows_script.rb +5 -2
- data/lib/chef/provider/yum_repository.rb +121 -0
- data/lib/chef/providers.rb +4 -2
- data/lib/chef/resource.rb +7 -9
- data/lib/chef/resource/conditional.rb +9 -1
- data/lib/chef/resource/launchd.rb +1 -1
- data/lib/chef/resource/user.rb +3 -3
- data/lib/chef/resource/user/aix_user.rb +31 -0
- data/lib/chef/resource/user/dscl_user.rb +31 -0
- data/lib/chef/resource/user/linux_user.rb +51 -0
- data/lib/chef/resource/user/pw_user.rb +31 -0
- data/lib/chef/resource/user/solaris_user.rb +31 -0
- data/lib/chef/resource/user/windows_user.rb +31 -0
- data/lib/chef/resource/yum_package.rb +13 -12
- data/lib/chef/resource/yum_repository.rb +76 -0
- data/lib/chef/resource_builder.rb +1 -1
- data/lib/chef/resource_collection/stepable_iterator.rb +1 -3
- data/lib/chef/resource_reporter.rb +5 -5
- data/lib/chef/resources.rb +7 -0
- data/lib/chef/run_context.rb +5 -3
- data/lib/chef/run_context/cookbook_compiler.rb +3 -2
- data/lib/chef/run_list.rb +2 -2
- data/lib/chef/search/query.rb +11 -8
- data/lib/chef/shell/ext.rb +2 -2
- data/lib/chef/shell/shell_session.rb +1 -1
- data/lib/chef/util/dsc/configuration_generator.rb +1 -1
- data/lib/chef/util/powershell/cmdlet.rb +5 -2
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_class.rb +2 -2
- data/lib/chef/version_constraint.rb +2 -2
- data/lib/chef/win32/api/error.rb +2 -2
- data/lib/chef/win32/api/net.rb +1 -1
- data/lib/chef/win32/eventlog.rb +1 -1
- data/lib/chef/win32/net.rb +1 -1
- data/lib/chef/win32/security/sid.rb +1 -1
- data/spec/functional/assets/testchefsubsys +2 -3
- data/spec/functional/event_loggers/windows_eventlog_spec.rb +11 -8
- data/spec/functional/file_content_management/deploy_strategies_spec.rb +1 -1
- data/spec/functional/http/simple_spec.rb +2 -2
- data/spec/functional/knife/cookbook_delete_spec.rb +5 -5
- data/spec/functional/knife/exec_spec.rb +6 -6
- data/spec/functional/knife/ssh_spec.rb +4 -4
- data/spec/functional/notifications_spec.rb +2 -2
- data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +2 -2
- data/spec/functional/rebooter_spec.rb +5 -5
- data/spec/functional/resource/bash_spec.rb +2 -2
- data/spec/functional/resource/deploy_revision_spec.rb +1 -1
- data/spec/functional/resource/dpkg_package_spec.rb +2 -2
- data/spec/functional/resource/dsc_resource_spec.rb +5 -5
- data/spec/functional/resource/dsc_script_spec.rb +27 -22
- data/spec/functional/resource/env_spec.rb +4 -4
- data/spec/functional/resource/execute_spec.rb +4 -4
- data/spec/functional/resource/group_spec.rb +20 -8
- data/spec/functional/resource/link_spec.rb +34 -0
- data/spec/functional/resource/ohai_spec.rb +6 -6
- data/spec/functional/resource/reboot_spec.rb +2 -2
- data/spec/functional/resource/remote_file_spec.rb +16 -7
- data/spec/functional/resource/user/dscl_spec.rb +3 -3
- data/spec/functional/resource/user/useradd_spec.rb +32 -26
- data/spec/functional/resource/windows_service_spec.rb +15 -15
- data/spec/functional/rest_spec.rb +2 -2
- data/spec/functional/run_lock_spec.rb +9 -9
- data/spec/functional/tiny_server_spec.rb +9 -8
- data/spec/functional/win32/crypto_spec.rb +1 -1
- data/spec/functional/win32/security_spec.rb +8 -8
- data/spec/integration/client/client_spec.rb +6 -4
- data/spec/integration/knife/chef_repo_path_spec.rb +70 -1
- data/spec/integration/knife/upload_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +6 -6
- data/spec/integration/recipes/noop_resource_spec.rb +4 -4
- data/spec/integration/recipes/provider_choice.rb +3 -3
- data/spec/integration/recipes/recipe_dsl_spec.rb +318 -317
- data/spec/integration/recipes/resource_action_spec.rb +50 -54
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +34 -34
- data/spec/integration/recipes/resource_load_spec.rb +24 -24
- data/spec/integration/solo/solo_spec.rb +21 -30
- data/spec/scripts/ssl-serve.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/stress/win32/security_spec.rb +4 -4
- data/spec/support/chef_helpers.rb +22 -0
- data/spec/support/platform_helpers.rb +5 -1
- data/spec/support/shared/context/client.rb +3 -2
- data/spec/support/shared/functional/file_resource.rb +5 -4
- data/spec/support/shared/functional/http.rb +16 -16
- data/spec/support/shared/functional/securable_resource.rb +5 -5
- data/spec/support/shared/functional/win32_service.rb +5 -7
- data/spec/support/shared/integration/app_server_support.rb +1 -3
- data/spec/support/shared/integration/knife_support.rb +0 -2
- data/spec/support/shared/shared_examples.rb +2 -2
- data/spec/support/shared/unit/api_versioning.rb +2 -2
- data/spec/support/shared/unit/application_dot_d.rb +9 -6
- data/spec/support/shared/unit/provider/file.rb +2 -2
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +49 -80
- data/spec/support/shared/unit/resource/static_provider_resolution.rb +2 -2
- data/spec/support/shared/unit/script_resource.rb +4 -4
- data/spec/support/shared/unit/user_and_client_shared.rb +4 -4
- data/spec/tiny_server.rb +51 -66
- data/spec/unit/api_client_v1_spec.rb +2 -2
- data/spec/unit/application_spec.rb +1 -1
- data/spec/unit/audit/audit_event_proxy_spec.rb +34 -27
- data/spec/unit/audit/audit_reporter_spec.rb +32 -23
- data/spec/unit/audit/control_group_data_spec.rb +19 -14
- data/spec/unit/chef_class_spec.rb +1 -1
- data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +1 -1
- data/spec/unit/chef_fs/diff_spec.rb +4 -4
- data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +4 -4
- data/spec/unit/chef_fs/file_system_spec.rb +2 -2
- data/spec/unit/chef_fs/parallelizer.rb +5 -7
- data/spec/unit/cookbook/metadata_spec.rb +98 -98
- data/spec/unit/cookbook/synchronizer_spec.rb +7 -0
- data/spec/unit/cookbook_loader_spec.rb +24 -24
- data/spec/unit/cookbook_version_file_specificity_spec.rb +8 -8
- data/spec/unit/daemon_spec.rb +1 -1
- data/spec/unit/data_bag_item_spec.rb +18 -18
- data/spec/unit/data_bag_spec.rb +2 -2
- data/spec/unit/data_collector/messages/helpers_spec.rb +9 -9
- data/spec/unit/data_collector/messages_spec.rb +2 -2
- data/spec/unit/data_collector_spec.rb +19 -19
- data/spec/unit/dsl/audit_spec.rb +3 -3
- data/spec/unit/dsl/data_query_spec.rb +3 -2
- data/spec/unit/dsl/declare_resource_spec.rb +10 -10
- data/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +3 -2
- data/spec/unit/encrypted_data_bag_item_spec.rb +3 -2
- data/spec/unit/environment_spec.rb +6 -6
- data/spec/unit/event_dispatch/dispatcher_spec.rb +2 -2
- data/spec/unit/file_access_control_spec.rb +3 -3
- data/spec/unit/file_content_management/tempfile_spec.rb +2 -2
- data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +2 -2
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +2 -2
- data/spec/unit/http/basic_client_spec.rb +20 -0
- data/spec/unit/http/validate_content_length_spec.rb +8 -8
- data/spec/unit/http_spec.rb +14 -0
- data/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +2 -2
- data/spec/unit/knife/bootstrap/client_builder_spec.rb +2 -2
- data/spec/unit/knife/bootstrap_spec.rb +8 -6
- data/spec/unit/knife/client_bulk_delete_spec.rb +8 -8
- data/spec/unit/knife/client_edit_spec.rb +2 -2
- data/spec/unit/knife/configure_client_spec.rb +2 -2
- data/spec/unit/knife/cookbook_metadata_spec.rb +4 -4
- data/spec/unit/knife/cookbook_site_install_spec.rb +6 -5
- data/spec/unit/knife/cookbook_site_share_spec.rb +2 -2
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +5 -4
- data/spec/unit/knife/core/node_editor_spec.rb +3 -3
- data/spec/unit/knife/core/ui_spec.rb +2 -2
- data/spec/unit/knife/data_bag_from_file_spec.rb +4 -3
- data/spec/unit/knife/data_bag_show_spec.rb +3 -2
- data/spec/unit/knife/key_create_spec.rb +14 -14
- data/spec/unit/knife/key_delete_spec.rb +2 -2
- data/spec/unit/knife/key_edit_spec.rb +16 -16
- data/spec/unit/knife/key_list_spec.rb +6 -6
- data/spec/unit/knife/key_show_spec.rb +4 -4
- data/spec/unit/knife/status_spec.rb +3 -2
- data/spec/unit/knife/user_create_spec.rb +4 -4
- data/spec/unit/knife_spec.rb +7 -6
- data/spec/unit/lwrp_spec.rb +6 -6
- data/spec/unit/mixin/api_version_request_handling_spec.rb +2 -2
- data/spec/unit/mixin/command_spec.rb +17 -14
- data/spec/unit/mixin/deprecation_spec.rb +1 -1
- data/spec/unit/mixin/homebrew_user_spec.rb +2 -2
- data/spec/unit/mixin/params_validate_spec.rb +53 -52
- data/spec/unit/mixin/powershell_out_spec.rb +2 -2
- data/spec/unit/mixin/powershell_type_coercions_spec.rb +2 -2
- data/spec/unit/mixin/shell_out_spec.rb +1 -1
- data/spec/unit/mixin/xml_escape_spec.rb +3 -3
- data/spec/unit/node_spec.rb +2 -2
- data/spec/unit/platform/query_helpers_spec.rb +3 -3
- data/spec/unit/property_spec.rb +4 -4
- data/spec/unit/provider/cookbook_file_spec.rb +4 -4
- data/spec/unit/provider/cron/unix_spec.rb +4 -4
- data/spec/unit/provider/cron_spec.rb +2 -2
- data/spec/unit/provider/deploy_spec.rb +8 -8
- data/spec/unit/provider/dsc_resource_spec.rb +11 -10
- data/spec/unit/provider/dsc_script_spec.rb +9 -9
- data/spec/unit/provider/env/windows_spec.rb +8 -8
- data/spec/unit/provider/file/content_spec.rb +6 -6
- data/spec/unit/provider/file_spec.rb +4 -4
- data/spec/unit/provider/launchd_spec.rb +2 -1
- data/spec/unit/provider/link_spec.rb +155 -0
- data/spec/unit/provider/mount/mount_spec.rb +5 -5
- data/spec/unit/provider/mount/solaris_spec.rb +48 -48
- data/spec/unit/provider/osx_profile_spec.rb +6 -0
- data/spec/unit/provider/package/chocolatey_spec.rb +4 -4
- data/spec/unit/provider/package/freebsd/port_spec.rb +4 -4
- data/spec/unit/provider/package/rubygems_spec.rb +50 -44
- data/spec/unit/provider/package/windows/exe_spec.rb +9 -0
- data/spec/unit/provider/package/yum_spec.rb +61 -60
- data/spec/unit/provider/package_spec.rb +2 -2
- data/spec/unit/provider/powershell_script_spec.rb +4 -4
- data/spec/unit/provider/remote_directory_spec.rb +1 -1
- data/spec/unit/provider/remote_file/ftp_spec.rb +4 -4
- data/spec/unit/provider/remote_file/local_file_spec.rb +4 -2
- data/spec/unit/provider/remote_file/sftp_spec.rb +4 -4
- data/spec/unit/provider/remote_file_spec.rb +4 -4
- data/spec/unit/provider/script_spec.rb +4 -4
- data/spec/unit/provider/service/debian_service_spec.rb +4 -4
- data/spec/unit/provider/service/freebsd_service_spec.rb +12 -8
- data/spec/unit/provider/service/openbsd_service_spec.rb +12 -8
- data/spec/unit/provider/service/systemd_service_spec.rb +4 -4
- data/spec/unit/provider/service/upstart_service_spec.rb +27 -12
- data/spec/unit/provider/service/windows_spec.rb +10 -10
- data/spec/unit/provider/systemd_unit_spec.rb +2 -2
- data/spec/unit/provider/template/content_spec.rb +8 -8
- data/spec/unit/provider/template_spec.rb +8 -8
- data/spec/unit/provider/user/dscl_spec.rb +51 -51
- data/spec/unit/provider/user/linux_spec.rb +76 -0
- data/spec/unit/provider/user/pw_spec.rb +3 -6
- data/spec/unit/provider/user/solaris_spec.rb +5 -5
- data/spec/unit/provider/user/windows_spec.rb +3 -3
- data/spec/unit/provider/user_spec.rb +2 -2
- data/spec/unit/provider/yum_repository_spec.rb +35 -0
- data/spec/unit/provider_resolver_spec.rb +306 -264
- data/spec/unit/recipe_spec.rb +8 -7
- data/spec/unit/resource/apt_repository_spec.rb +4 -4
- data/spec/unit/resource/apt_update_spec.rb +4 -4
- data/spec/unit/resource/conditional_spec.rb +46 -0
- data/spec/unit/resource/dsc_resource_spec.rb +8 -8
- data/spec/unit/resource/dsc_script_spec.rb +4 -4
- data/spec/unit/resource/freebsd_package_spec.rb +6 -6
- data/spec/unit/resource/launchd_spec.rb +3 -2
- data/spec/unit/resource/osx_profile_spec.rb +3 -2
- data/spec/unit/resource/remote_file_spec.rb +6 -6
- data/spec/unit/resource/service_spec.rb +14 -14
- data/spec/unit/resource/user_spec.rb +1 -1
- data/spec/unit/resource/yum_repository_spec.rb +49 -0
- data/spec/unit/resource_collection_spec.rb +4 -4
- data/spec/unit/resource_definition_spec.rb +11 -11
- data/spec/unit/resource_reporter_spec.rb +4 -4
- data/spec/unit/resource_resolver_spec.rb +6 -6
- data/spec/unit/resource_spec.rb +36 -16
- data/spec/unit/run_context/child_run_context_spec.rb +4 -4
- data/spec/unit/run_context/cookbook_compiler_spec.rb +43 -1
- data/spec/unit/run_context_spec.rb +8 -8
- data/spec/unit/run_list/run_list_expansion_spec.rb +2 -2
- data/spec/unit/runner_spec.rb +2 -2
- data/spec/unit/search/query_spec.rb +15 -14
- data/spec/unit/user_v1_spec.rb +8 -8
- data/spec/unit/util/dsc/configuration_generator_spec.rb +12 -12
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +12 -9
- data/spec/unit/util/dsc/resource_store.rb +8 -6
- data/spec/unit/util/editor_spec.rb +6 -6
- data/spec/unit/util/powershell/cmdlet_spec.rb +10 -10
- data/tasks/bin/bundle-platform +1 -0
- data/tasks/bin/bundler_patch.rb +27 -0
- data/tasks/cbgb.rb +2 -2
- data/tasks/maintainers.rb +2 -2
- metadata +37 -8
- data/spec/unit/provider/user/useradd_spec.rb +0 -51
@@ -55,13 +55,13 @@ shared_examples_for "user or client create" do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
context "when chef_key is returned by the server" do
|
58
|
-
let(:chef_key)
|
58
|
+
let(:chef_key) do
|
59
59
|
{
|
60
60
|
"chef_key" => {
|
61
61
|
"public_key" => "some_public_key",
|
62
62
|
},
|
63
63
|
}
|
64
|
-
|
64
|
+
end
|
65
65
|
|
66
66
|
it "puts the public key into the objectr returned by create" do
|
67
67
|
expect(rest_v1).to receive(:post).with(url, payload).and_return(payload.merge(chef_key))
|
@@ -70,14 +70,14 @@ shared_examples_for "user or client create" do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
context "when private_key is returned in chef_key" do
|
73
|
-
let(:chef_key)
|
73
|
+
let(:chef_key) do
|
74
74
|
{
|
75
75
|
"chef_key" => {
|
76
76
|
"public_key" => "some_public_key",
|
77
77
|
"private_key" => "some_private_key",
|
78
78
|
},
|
79
79
|
}
|
80
|
-
|
80
|
+
end
|
81
81
|
|
82
82
|
it "puts the private key into the object returned by create" do
|
83
83
|
expect(rest_v1).to receive(:post).with(url, payload).and_return(payload.merge(chef_key))
|
data/spec/tiny_server.rb
CHANGED
@@ -20,97 +20,82 @@ require "rubygems"
|
|
20
20
|
require "webrick"
|
21
21
|
require "webrick/https"
|
22
22
|
require "rack"
|
23
|
-
|
23
|
+
require "thread"
|
24
24
|
require "singleton"
|
25
25
|
require "open-uri"
|
26
26
|
require "chef/config"
|
27
27
|
|
28
28
|
module TinyServer
|
29
29
|
|
30
|
-
class Server < Rack::Server
|
31
|
-
|
32
|
-
attr_writer :app
|
33
|
-
|
34
|
-
def self.setup(options = nil, &block)
|
35
|
-
tiny_app = new(options)
|
36
|
-
app_code = Rack::Builder.new(&block).to_app
|
37
|
-
tiny_app.app = app_code
|
38
|
-
tiny_app
|
39
|
-
end
|
40
|
-
|
41
|
-
def shutdown
|
42
|
-
server.shutdown
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
30
|
class Manager
|
47
31
|
|
48
32
|
# 5 == debug, 3 == warning
|
49
33
|
LOGGER = WEBrick::Log.new(STDOUT, 3)
|
50
34
|
DEFAULT_OPTIONS = {
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
35
|
+
Port: 9000,
|
36
|
+
Host: "localhost",
|
37
|
+
Logger: LOGGER,
|
38
|
+
# SSLEnable: options[:ssl],
|
39
|
+
# SSLCertName: [ [ 'CN', WEBrick::Utils::getservername ] ],
|
40
|
+
AccessLog: [], # Remove this option to enable the access log when debugging.
|
57
41
|
}
|
58
42
|
|
59
|
-
def initialize(options
|
60
|
-
@options =
|
43
|
+
def initialize(**options)
|
44
|
+
@options = DEFAULT_OPTIONS.merge(options)
|
61
45
|
@creator = caller.first
|
62
46
|
end
|
63
47
|
|
64
|
-
|
48
|
+
attr_reader :options
|
49
|
+
attr_reader :creator
|
50
|
+
attr_reader :server
|
51
|
+
|
52
|
+
def start(timeout = 5)
|
53
|
+
raise "Server already started!" if server
|
54
|
+
|
55
|
+
# Create the server (but don't start yet)
|
56
|
+
start_queue = Queue.new
|
57
|
+
@server = create_server(StartCallback: proc { start_queue << true })
|
58
|
+
|
65
59
|
@server_thread = Thread.new do
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
@old_handler = trap(:INT, "EXIT")
|
70
|
-
@server.start
|
60
|
+
# Ensure any exceptions will cause the main rspec thread to fail too
|
61
|
+
Thread.current.abort_on_exception = true
|
62
|
+
server.start
|
71
63
|
end
|
72
|
-
block_until_started
|
73
|
-
trap(:INT, @old_handler)
|
74
|
-
end
|
75
64
|
|
76
|
-
|
77
|
-
|
65
|
+
# Wait for the StartCallback to tell us we've started
|
66
|
+
Timeout.timeout(timeout) do
|
67
|
+
start_queue.pop
|
68
|
+
end
|
78
69
|
end
|
79
70
|
|
80
|
-
def
|
81
|
-
|
82
|
-
|
83
|
-
|
71
|
+
def stop(timeout = 5)
|
72
|
+
if server
|
73
|
+
server.shutdown
|
74
|
+
@server = nil
|
75
|
+
end
|
76
|
+
|
77
|
+
if server_thread
|
78
|
+
begin
|
79
|
+
# Wait for a normal shutdown
|
80
|
+
server_thread.join(timeout)
|
81
|
+
rescue
|
82
|
+
# If it wouldn't shut down normally, kill it.
|
83
|
+
server_thread.kill
|
84
|
+
server_thread.join(timeout)
|
84
85
|
end
|
86
|
+
@server_thread = nil
|
85
87
|
end
|
86
|
-
raise "ivar weirdness" if started? && @server.nil?
|
87
|
-
raise "TinyServer failed to boot :/"
|
88
|
-
end
|
89
|
-
|
90
|
-
def started?
|
91
|
-
open(url)
|
92
|
-
true
|
93
|
-
rescue OpenURI::HTTPError
|
94
|
-
true
|
95
|
-
rescue Errno::ECONNREFUSED, EOFError, Errno::ECONNRESET => e
|
96
|
-
sleep 0.1
|
97
|
-
true
|
98
|
-
# If the host has ":::1 localhost" in its hosts file and if IPv6
|
99
|
-
# is not enabled we can get NetworkUnreachable exception...
|
100
|
-
rescue Errno::ENETUNREACH, Net::ReadTimeout, IO::EAGAINWaitReadable,
|
101
|
-
Errno::EHOSTUNREACH => e
|
102
|
-
sleep 0.1
|
103
|
-
false
|
104
|
-
end
|
105
|
-
|
106
|
-
def stop
|
107
|
-
# yes, this is terrible.
|
108
|
-
@server.shutdown
|
109
|
-
@server_thread.kill
|
110
|
-
@server_thread.join
|
111
|
-
@server_thread = nil
|
112
88
|
end
|
113
89
|
|
90
|
+
private
|
91
|
+
|
92
|
+
attr_reader :server_thread
|
93
|
+
|
94
|
+
def create_server(**extra_options)
|
95
|
+
server = WEBrick::HTTPServer.new(**options, **extra_options)
|
96
|
+
server.mount("/", Rack::Handler::WEBrick, API.instance)
|
97
|
+
server
|
98
|
+
end
|
114
99
|
end
|
115
100
|
|
116
101
|
class API
|
@@ -326,13 +326,13 @@ describe Chef::ApiClientV1 do
|
|
326
326
|
describe "Versioned API Interactions" do
|
327
327
|
let(:response_406) { OpenStruct.new(:code => "406") }
|
328
328
|
let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
|
329
|
-
let(:payload)
|
329
|
+
let(:payload) do
|
330
330
|
{
|
331
331
|
:name => "some_name",
|
332
332
|
:validator => true,
|
333
333
|
:admin => true,
|
334
334
|
}
|
335
|
-
|
335
|
+
end
|
336
336
|
|
337
337
|
before do
|
338
338
|
@client = Chef::ApiClientV1.new
|
@@ -361,7 +361,7 @@ describe Chef::Application do
|
|
361
361
|
end
|
362
362
|
end
|
363
363
|
|
364
|
-
context
|
364
|
+
context "when called with an Array-like argument (#size)" do
|
365
365
|
before do
|
366
366
|
allow(app).to receive(:fork_chef_client).and_return(true)
|
367
367
|
allow(app).to receive(:run_with_graceful_exit_option).and_return(true)
|
@@ -34,8 +34,9 @@ describe Chef::Audit::AuditEventProxy do
|
|
34
34
|
describe "#example_group_started" do
|
35
35
|
|
36
36
|
let(:description) { "poots" }
|
37
|
-
let(:group)
|
38
|
-
|
37
|
+
let(:group) do
|
38
|
+
double("ExampleGroup", :parent_groups => parents,
|
39
|
+
:description => description) end
|
39
40
|
let(:notification) { double("Notification", :group => group) }
|
40
41
|
|
41
42
|
context "when notified from a top-level example group" do
|
@@ -120,35 +121,36 @@ describe Chef::Audit::AuditEventProxy do
|
|
120
121
|
|
121
122
|
let(:examples) { [example] }
|
122
123
|
|
123
|
-
let(:example)
|
124
|
-
|
125
|
-
|
124
|
+
let(:example) do
|
125
|
+
double("Example", :metadata => metadata,
|
126
|
+
:description => example_description,
|
127
|
+
:full_description => full_description, :exception => nil) end
|
126
128
|
|
127
|
-
let(:metadata)
|
129
|
+
let(:metadata) do
|
128
130
|
{
|
129
131
|
:described_class => described_class,
|
130
132
|
:example_group => example_group,
|
131
133
|
:line_number => line,
|
132
134
|
}
|
133
|
-
|
135
|
+
end
|
134
136
|
|
135
|
-
let(:example_group)
|
137
|
+
let(:example_group) do
|
136
138
|
{
|
137
139
|
:description => group_description,
|
138
140
|
:parent_example_group => parent_group,
|
139
141
|
}
|
140
|
-
|
142
|
+
end
|
141
143
|
|
142
|
-
let(:parent_group)
|
144
|
+
let(:parent_group) do
|
143
145
|
{
|
144
146
|
:description => control_group_name,
|
145
147
|
:parent_example_group => nil,
|
146
148
|
}
|
147
|
-
|
149
|
+
end
|
148
150
|
|
149
151
|
let(:line) { 27 }
|
150
152
|
|
151
|
-
let(:control_data)
|
153
|
+
let(:control_data) do
|
152
154
|
{
|
153
155
|
:name => example_description,
|
154
156
|
:desc => full_description,
|
@@ -157,7 +159,7 @@ describe Chef::Audit::AuditEventProxy do
|
|
157
159
|
:context => context,
|
158
160
|
:line_number => line,
|
159
161
|
}
|
160
|
-
|
162
|
+
end
|
161
163
|
|
162
164
|
shared_examples "built control" do
|
163
165
|
|
@@ -218,12 +220,14 @@ describe Chef::Audit::AuditEventProxy do
|
|
218
220
|
let(:control_group_name) { "application ports" }
|
219
221
|
let(:group_description) { "#{resource_type} #{resource_name}" }
|
220
222
|
let(:example_description) { "should not be listening" }
|
221
|
-
let(:full_description)
|
222
|
-
|
223
|
+
let(:full_description) do
|
224
|
+
[control_group_name, group_description,
|
225
|
+
example_description].join(" ") end
|
223
226
|
|
224
227
|
# Metadata fields
|
225
|
-
let(:described_class)
|
226
|
-
|
228
|
+
let(:described_class) do
|
229
|
+
double("Serverspec::Type::Port",
|
230
|
+
:class => "Serverspec::Type::Port", :name => resource_name) end
|
227
231
|
|
228
232
|
# Control data fields
|
229
233
|
let(:resource_type) { "Port" }
|
@@ -246,8 +250,9 @@ describe Chef::Audit::AuditEventProxy do
|
|
246
250
|
let(:control_group_name) { "application ports" }
|
247
251
|
let(:group_description) { "port 111" }
|
248
252
|
let(:example_description) { "is not listening" }
|
249
|
-
let(:full_description)
|
250
|
-
|
253
|
+
let(:full_description) do
|
254
|
+
[control_group_name, group_description,
|
255
|
+
example_description].join(" ") end
|
251
256
|
|
252
257
|
# Metadata fields
|
253
258
|
let(:described_class) { nil }
|
@@ -276,27 +281,29 @@ describe Chef::Audit::AuditEventProxy do
|
|
276
281
|
let(:outer_group_description) { "File \"tmp/audit\"" }
|
277
282
|
let(:group_description) { "#{resource_type} #{resource_name}" }
|
278
283
|
let(:example_description) { "is a file" }
|
279
|
-
let(:full_description)
|
280
|
-
|
284
|
+
let(:full_description) do
|
285
|
+
[control_group_name, outer_group_description,
|
286
|
+
group_description, example_description].join(" ") end
|
281
287
|
|
282
288
|
# Metadata parts
|
283
|
-
let(:described_class)
|
284
|
-
|
289
|
+
let(:described_class) do
|
290
|
+
double("Serverspec::Type::File",
|
291
|
+
:class => "Serverspec::Type::File", :name => resource_name) end
|
285
292
|
|
286
293
|
# Example group parts
|
287
|
-
let(:parent_group)
|
294
|
+
let(:parent_group) do
|
288
295
|
{
|
289
296
|
:description => outer_group_description,
|
290
297
|
:parent_example_group => control_group,
|
291
298
|
}
|
292
|
-
|
299
|
+
end
|
293
300
|
|
294
|
-
let(:control_group)
|
301
|
+
let(:control_group) do
|
295
302
|
{
|
296
303
|
:description => control_group_name,
|
297
304
|
:parent_example_group => nil,
|
298
305
|
}
|
299
|
-
|
306
|
+
end
|
300
307
|
|
301
308
|
# Control data parts
|
302
309
|
let(:resource_type) { "File" }
|
@@ -28,8 +28,9 @@ describe Chef::Audit::AuditReporter do
|
|
28
28
|
let(:run_id) { 0 }
|
29
29
|
let(:start_time) { Time.new(2014, 12, 3, 9, 31, 05, "-08:00") }
|
30
30
|
let(:end_time) { Time.new(2014, 12, 3, 9, 36, 14, "-08:00") }
|
31
|
-
let(:run_status)
|
32
|
-
|
31
|
+
let(:run_status) do
|
32
|
+
instance_double(Chef::RunStatus, :node => node, :run_id => run_id,
|
33
|
+
:start_time => start_time, :end_time => end_time) end
|
33
34
|
|
34
35
|
describe "#audit_phase_start" do
|
35
36
|
|
@@ -85,9 +86,10 @@ describe Chef::Audit::AuditReporter do
|
|
85
86
|
|
86
87
|
context "when audit phase failed" do
|
87
88
|
|
88
|
-
let(:audit_error)
|
89
|
-
|
90
|
-
|
89
|
+
let(:audit_error) do
|
90
|
+
double("AuditError", :class => "Chef::Exceptions::AuditError",
|
91
|
+
:message => "Audit phase failed with error message: derpderpderp",
|
92
|
+
:backtrace => ["/path/recipe.rb:57", "/path/library.rb:106"]) end
|
91
93
|
|
92
94
|
before do
|
93
95
|
reporter.instance_variable_set(:@audit_phase_error, audit_error)
|
@@ -233,13 +235,15 @@ EOM
|
|
233
235
|
let(:audit_data) { Chef::Audit::AuditData.new(node.name, run_id) }
|
234
236
|
let(:run_data) { audit_data.to_hash }
|
235
237
|
|
236
|
-
let(:audit_error)
|
237
|
-
|
238
|
-
|
238
|
+
let(:audit_error) do
|
239
|
+
double("AuditError", :class => "Chef::Exceptions::AuditError",
|
240
|
+
:message => "Audit phase failed with error message: derpderpderp",
|
241
|
+
:backtrace => ["/path/recipe.rb:57", "/path/library.rb:106"]) end
|
239
242
|
|
240
|
-
let(:run_error)
|
241
|
-
|
242
|
-
|
243
|
+
let(:run_error) do
|
244
|
+
double("RunError", :class => "Chef::Exceptions::RunError",
|
245
|
+
:message => "This error shouldn't be reported.",
|
246
|
+
:backtrace => ["fix it", "fix it", "fix it"]) end
|
243
247
|
|
244
248
|
before do
|
245
249
|
allow(reporter).to receive(:auditing_enabled?).and_return(true)
|
@@ -276,23 +280,27 @@ EOM
|
|
276
280
|
|
277
281
|
shared_context "audit data" do
|
278
282
|
|
279
|
-
let(:control_group_foo)
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
+
let(:control_group_foo) do
|
284
|
+
instance_double(Chef::Audit::ControlGroupData,
|
285
|
+
:metadata => double("foo metadata")) end
|
286
|
+
let(:control_group_bar) do
|
287
|
+
instance_double(Chef::Audit::ControlGroupData,
|
288
|
+
:metadata => double("bar metadata")) end
|
283
289
|
|
284
|
-
let(:ordered_control_groups)
|
290
|
+
let(:ordered_control_groups) do
|
285
291
|
{
|
286
292
|
"foo" => control_group_foo,
|
287
293
|
"bar" => control_group_bar,
|
288
294
|
}
|
289
|
-
|
295
|
+
end
|
290
296
|
|
291
|
-
let(:audit_data)
|
292
|
-
|
297
|
+
let(:audit_data) do
|
298
|
+
instance_double(Chef::Audit::AuditData,
|
299
|
+
:add_control_group => true) end
|
293
300
|
|
294
|
-
let(:run_context)
|
295
|
-
|
301
|
+
let(:run_context) do
|
302
|
+
instance_double(Chef::RunContext,
|
303
|
+
:audits => ordered_control_groups) end
|
296
304
|
|
297
305
|
before do
|
298
306
|
allow(reporter).to receive(:ordered_control_groups).and_return(ordered_control_groups)
|
@@ -340,8 +348,9 @@ EOM
|
|
340
348
|
include_context "audit data"
|
341
349
|
|
342
350
|
let(:name) { "bat" }
|
343
|
-
let(:control_group)
|
344
|
-
|
351
|
+
let(:control_group) do
|
352
|
+
instance_double(Chef::Audit::ControlGroupData,
|
353
|
+
:metadata => double("metadata")) end
|
345
354
|
|
346
355
|
before do
|
347
356
|
allow(Chef::Audit::ControlGroupData).to receive(:new).
|
@@ -122,9 +122,10 @@ describe Chef::Audit::ControlData do
|
|
122
122
|
let(:context) { nil }
|
123
123
|
let(:line_number) { 27 }
|
124
124
|
|
125
|
-
let(:control_data)
|
126
|
-
|
127
|
-
|
125
|
+
let(:control_data) do
|
126
|
+
described_class.new(name: name,
|
127
|
+
resource_type: resource_type, resource_name: resource_name,
|
128
|
+
context: context, line_number: line_number) end
|
128
129
|
|
129
130
|
describe "#to_hash" do
|
130
131
|
|
@@ -171,7 +172,7 @@ describe Chef::Audit::ControlGroupData do
|
|
171
172
|
let(:context) { nil }
|
172
173
|
let(:line_number) { 0 }
|
173
174
|
|
174
|
-
let(:control_data)
|
175
|
+
let(:control_data) do
|
175
176
|
{
|
176
177
|
:name => name,
|
177
178
|
:resource_type => resource_type,
|
@@ -179,16 +180,17 @@ describe Chef::Audit::ControlGroupData do
|
|
179
180
|
:context => context,
|
180
181
|
:line_number => line_number,
|
181
182
|
}
|
182
|
-
|
183
|
+
end
|
183
184
|
|
184
185
|
end
|
185
186
|
|
186
187
|
shared_context "control" do
|
187
188
|
include_context "control data"
|
188
189
|
|
189
|
-
let(:control)
|
190
|
-
|
191
|
-
|
190
|
+
let(:control) do
|
191
|
+
Chef::Audit::ControlData.new(name: name,
|
192
|
+
resource_type: resource_type, resource_name: resource_name,
|
193
|
+
context: context, line_number: line_number) end
|
192
194
|
|
193
195
|
before do
|
194
196
|
allow(Chef::Audit::ControlData).to receive(:new).
|
@@ -436,15 +438,18 @@ describe Chef::Audit::ControlGroupData do
|
|
436
438
|
let(:control_hash_2) { { :line_number => 13 } }
|
437
439
|
let(:control_hash_3) { { :line_number => 35 } }
|
438
440
|
|
439
|
-
let(:control_1)
|
441
|
+
let(:control_1) do
|
442
|
+
double("control 1",
|
440
443
|
:line_number => control_hash_1[:line_number],
|
441
|
-
:to_hash => control_hash_1)
|
442
|
-
let(:control_2)
|
444
|
+
:to_hash => control_hash_1) end
|
445
|
+
let(:control_2) do
|
446
|
+
double("control 2",
|
443
447
|
:line_number => control_hash_2[:line_number],
|
444
|
-
:to_hash => control_hash_2)
|
445
|
-
let(:control_3)
|
448
|
+
:to_hash => control_hash_2) end
|
449
|
+
let(:control_3) do
|
450
|
+
double("control 3",
|
446
451
|
:line_number => control_hash_3[:line_number],
|
447
|
-
:to_hash => control_hash_3)
|
452
|
+
:to_hash => control_hash_3) end
|
448
453
|
|
449
454
|
let(:control_list) { [control_1, control_2, control_3] }
|
450
455
|
let(:ordered_control_hashes) { [control_hash_2, control_hash_1, control_hash_3] }
|