chef 12.4.3-universal-mingw32 → 12.5.1-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +21 -25
- data/Gemfile +46 -0
- data/README.md +4 -4
- data/Rakefile +4 -110
- data/bin/chef-service-manager +3 -1
- data/distro/common/html/knife_cookbook_site.html +18 -18
- data/distro/common/man/man1/knife-cookbook-site.1 +11 -11
- data/lib/chef.rb +1 -1
- data/lib/chef/application.rb +1 -1
- data/lib/chef/application/apply.rb +19 -1
- data/lib/chef/application/client.rb +11 -5
- data/lib/chef/application/knife.rb +2 -2
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/application/windows_service_manager.rb +19 -12
- data/lib/chef/chef_class.rb +46 -0
- data/lib/chef/chef_fs/config.rb +22 -24
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +3 -1
- data/lib/chef/chef_fs/file_pattern.rb +4 -15
- data/lib/chef/chef_fs/file_system/acl_dir.rb +3 -4
- data/lib/chef/chef_fs/file_system/acls_dir.rb +5 -1
- data/lib/chef/chef_fs/file_system/base_fs_dir.rb +0 -5
- data/lib/chef/chef_fs/file_system/base_fs_object.rb +5 -2
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +2 -9
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_entry.rb +2 -9
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +10 -17
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -12
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +15 -11
- data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +8 -2
- data/lib/chef/chef_fs/file_system/cookbook_dir.rb +4 -4
- data/lib/chef/chef_fs/file_system/cookbooks_acl_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +3 -11
- data/lib/chef/chef_fs/file_system/data_bags_dir.rb +3 -5
- data/lib/chef/chef_fs/file_system/environments_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/file_system_entry.rb +7 -4
- data/lib/chef/chef_fs/file_system/memory_dir.rb +2 -3
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +15 -0
- data/lib/chef/chef_fs/file_system/nodes_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/organization_members_entry.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +4 -9
- data/lib/chef/chef_fs/knife.rb +35 -7
- data/lib/chef/chef_fs/path_utils.rb +65 -34
- data/lib/chef/client.rb +2 -3
- data/lib/chef/config.rb +34 -2
- data/lib/chef/{mixin/wstring.rb → constants.rb} +9 -13
- data/lib/chef/cookbook/metadata.rb +25 -3
- data/lib/chef/cookbook/synchronizer.rb +1 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +3 -3
- data/lib/chef/delayed_evaluator.rb +21 -0
- data/lib/chef/deprecation/mixin/template.rb +1 -2
- data/lib/chef/deprecation/provider/cookbook_file.rb +1 -1
- data/lib/chef/deprecation/provider/file.rb +1 -1
- data/lib/chef/deprecation/provider/remote_directory.rb +52 -0
- data/lib/chef/deprecation/provider/remote_file.rb +1 -2
- data/lib/chef/deprecation/provider/template.rb +1 -1
- data/lib/chef/deprecation/warnings.rb +3 -4
- data/lib/chef/dsl/reboot_pending.rb +3 -2
- data/lib/chef/dsl/recipe.rb +26 -7
- data/lib/chef/dsl/resources.rb +2 -2
- data/lib/chef/event_dispatch/base.rb +51 -22
- data/lib/chef/event_dispatch/dispatcher.rb +21 -6
- data/lib/chef/event_dispatch/dsl.rb +64 -0
- data/lib/chef/exceptions.rb +28 -1
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/base.rb +3 -0
- data/lib/chef/formatters/doc.rb +56 -6
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +36 -0
- data/lib/chef/formatters/minimal.rb +2 -2
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +3 -1
- data/lib/chef/http/http_request.rb +1 -1
- data/lib/chef/knife.rb +35 -55
- data/lib/chef/knife/bootstrap.rb +41 -0
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +1 -0
- data/lib/chef/knife/bootstrap/client_builder.rb +16 -0
- data/lib/chef/knife/bootstrap/templates/README.md +3 -4
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +1 -1
- data/lib/chef/knife/cookbook_create.rb +1 -1
- data/lib/chef/knife/cookbook_site_download.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +6 -6
- data/lib/chef/knife/cookbook_site_unshare.rb +2 -2
- data/lib/chef/knife/core/bootstrap_context.rb +12 -4
- data/lib/chef/knife/core/custom_manifest_loader.rb +69 -0
- data/lib/chef/knife/core/gem_glob_loader.rb +138 -0
- data/lib/chef/knife/core/hashed_command_loader.rb +80 -0
- data/lib/chef/knife/core/node_presenter.rb +24 -1
- data/lib/chef/knife/core/object_loader.rb +1 -0
- data/lib/chef/knife/core/subcommand_loader.rb +131 -146
- data/lib/chef/knife/node_run_list_remove.rb +12 -1
- data/lib/chef/knife/null.rb +10 -0
- data/lib/chef/knife/rehash.rb +62 -0
- data/lib/chef/knife/search.rb +3 -3
- data/lib/chef/knife/ssh.rb +52 -30
- data/lib/chef/knife/ssl_check.rb +3 -2
- data/lib/chef/knife/user_edit.rb +1 -2
- data/lib/chef/local_mode.rb +5 -0
- data/lib/chef/log.rb +5 -1
- data/lib/chef/mixin/deprecation.rb +8 -8
- data/lib/chef/mixin/params_validate.rb +362 -135
- data/lib/chef/mixin/template.rb +48 -0
- data/lib/chef/mixin/which.rb +1 -1
- data/lib/chef/mixin/wide_string.rb +72 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +15 -39
- data/lib/chef/mixin/windows_env_helper.rb +4 -1
- data/lib/chef/monkey_patches/webrick-utils.rb +51 -0
- data/lib/chef/monkey_patches/win32/registry.rb +72 -0
- data/lib/chef/node.rb +116 -3
- data/lib/chef/node_map.rb +2 -2
- data/lib/chef/platform/handler_map.rb +0 -5
- data/lib/chef/platform/provider_mapping.rb +5 -6
- data/lib/chef/platform/query_helpers.rb +46 -4
- data/lib/chef/platform/rebooter.rb +1 -1
- data/lib/chef/platform/service_helpers.rb +30 -32
- data/lib/chef/policy_builder.rb +1 -8
- data/lib/chef/policy_builder/dynamic.rb +186 -0
- data/lib/chef/policy_builder/expand_node_object.rb +30 -15
- data/lib/chef/policy_builder/policyfile.rb +155 -18
- data/lib/chef/property.rb +568 -0
- data/lib/chef/provider.rb +222 -13
- data/lib/chef/provider/batch.rb +8 -0
- data/lib/chef/provider/deploy.rb +5 -7
- data/lib/chef/provider/directory.rb +14 -2
- data/lib/chef/provider/dsc_resource.rb +5 -9
- data/lib/chef/provider/group/pw.rb +1 -1
- data/lib/chef/provider/ifconfig.rb +2 -2
- data/lib/chef/provider/lwrp_base.rb +1 -75
- data/lib/chef/provider/mount.rb +7 -3
- data/lib/chef/provider/package.rb +1 -1
- data/lib/chef/provider/package/dpkg.rb +5 -11
- data/lib/chef/provider/package/rpm.rb +2 -2
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/windows/msi.rb +2 -2
- data/lib/chef/provider/package/yum.rb +17 -5
- data/lib/chef/provider/powershell_script.rb +59 -23
- data/lib/chef/provider/registry_key.rb +5 -5
- data/lib/chef/provider/remote_directory.rb +190 -102
- data/lib/chef/provider/service.rb +12 -2
- data/lib/chef/provider/service/aix.rb +1 -1
- data/lib/chef/provider/service/debian.rb +3 -5
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/gentoo.rb +3 -3
- data/lib/chef/provider/service/init.rb +3 -3
- data/lib/chef/provider/service/insserv.rb +2 -4
- data/lib/chef/provider/service/invokercd.rb +2 -4
- data/lib/chef/provider/service/macosx.rb +5 -1
- data/lib/chef/provider/service/openbsd.rb +2 -1
- data/lib/chef/provider/service/redhat.rb +52 -16
- data/lib/chef/provider/service/simple.rb +2 -2
- data/lib/chef/provider/service/systemd.rb +3 -5
- data/lib/chef/provider/service/upstart.rb +4 -6
- data/lib/chef/provider/subversion.rb +13 -7
- data/lib/chef/provider/template/content.rb +16 -6
- data/lib/chef/provider/user/solaris.rb +32 -4
- data/lib/chef/provider/windows_script.rb +3 -5
- data/lib/chef/provider_resolver.rb +2 -2
- data/lib/chef/recipe.rb +1 -8
- data/lib/chef/resource.rb +563 -90
- data/lib/chef/resource/action_class.rb +83 -0
- data/lib/chef/resource/chef_gem.rb +3 -3
- data/lib/chef/resource/deploy.rb +8 -2
- data/lib/chef/resource/dsc_script.rb +2 -0
- data/lib/chef/resource/file/verification.rb +7 -1
- data/lib/chef/resource/lwrp_base.rb +1 -7
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/service.rb +10 -2
- data/lib/chef/resource/subversion.rb +5 -0
- data/lib/chef/resource/windows_script.rb +6 -2
- data/lib/chef/resource/yum_package.rb +10 -1
- data/lib/chef/resource_resolver.rb +3 -3
- data/lib/chef/run_context.rb +402 -83
- data/lib/chef/run_list/versioned_recipe_list.rb +15 -0
- data/lib/chef/run_lock.rb +30 -21
- data/lib/chef/util/powershell/ps_credential.rb +4 -0
- data/lib/chef/util/windows.rb +0 -32
- data/lib/chef/util/windows/net_group.rb +85 -106
- data/lib/chef/util/windows/net_use.rb +35 -71
- data/lib/chef/util/windows/net_user.rb +0 -1
- data/lib/chef/util/windows/volume.rb +19 -19
- data/lib/chef/version.rb +3 -3
- data/lib/chef/win32/api.rb +1 -0
- data/lib/chef/win32/api/file.rb +20 -0
- data/lib/chef/win32/api/net.rb +163 -43
- data/lib/chef/win32/api/registry.rb +51 -0
- data/lib/chef/win32/api/system.rb +23 -0
- data/lib/chef/win32/api/unicode.rb +0 -43
- data/lib/chef/win32/crypto.rb +2 -1
- data/lib/chef/win32/file.rb +28 -3
- data/lib/chef/win32/mutex.rb +1 -2
- data/lib/chef/win32/net.rb +162 -8
- data/lib/chef/win32/process.rb +13 -0
- data/lib/chef/win32/registry.rb +35 -30
- data/lib/chef/win32/security.rb +1 -1
- data/lib/chef/win32/security/token.rb +1 -1
- data/lib/chef/win32/system.rb +62 -0
- data/lib/chef/win32/unicode.rb +7 -2
- data/lib/chef/win32/version.rb +0 -4
- data/lib/chef/workstation_config_loader.rb +3 -158
- data/spec/data/cookbooks/openldap/templates/default/helpers.erb +14 -0
- data/spec/data/cookbooks/openldap/templates/default/nested_openldap_partials.erb +1 -0
- data/spec/data/cookbooks/openldap/templates/default/nested_partial.erb +1 -0
- data/spec/data/dsc_lcm.pfx +0 -0
- data/spec/data/run_context/cookbooks/include/recipes/default.rb +24 -0
- data/spec/data/run_context/cookbooks/include/recipes/includee.rb +3 -0
- data/spec/functional/dsl/reboot_pending_spec.rb +33 -43
- data/spec/functional/knife/cookbook_delete_spec.rb +17 -7
- data/spec/functional/knife/ssh_spec.rb +16 -0
- data/spec/functional/rebooter_spec.rb +1 -1
- data/spec/functional/resource/deploy_revision_spec.rb +1 -1
- data/spec/functional/resource/dsc_resource_spec.rb +2 -0
- data/spec/functional/resource/dsc_script_spec.rb +91 -2
- data/spec/functional/resource/group_spec.rb +67 -44
- data/spec/functional/resource/{powershell_spec.rb → powershell_script_spec.rb} +107 -18
- data/spec/functional/resource/windows_service_spec.rb +1 -1
- data/spec/functional/run_lock_spec.rb +368 -189
- data/spec/functional/win32/{registry_helper_spec.rb → registry_spec.rb} +16 -23
- data/spec/functional/win32/service_manager_spec.rb +2 -2
- data/spec/integration/client/client_spec.rb +51 -0
- data/spec/integration/knife/chef_repo_path_spec.rb +13 -11
- data/spec/integration/knife/download_spec.rb +4 -0
- data/spec/integration/knife/list_spec.rb +8 -0
- data/spec/integration/knife/upload_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +1 -16
- data/spec/integration/recipes/remote_directory.rb +74 -0
- data/spec/integration/recipes/resource_action_spec.rb +363 -0
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +423 -0
- data/spec/integration/recipes/resource_load_spec.rb +206 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/support/platform_helpers.rb +13 -0
- data/spec/support/shared/context/win32.rb +34 -0
- data/spec/support/shared/functional/win32_service.rb +2 -1
- data/spec/support/shared/functional/windows_script.rb +63 -26
- data/spec/support/shared/unit/mock_shellout.rb +46 -0
- data/spec/support/shared/unit/provider/file.rb +10 -4
- data/spec/unit/application/client_spec.rb +16 -3
- data/spec/unit/application/knife_spec.rb +2 -2
- data/spec/unit/application/solo_spec.rb +4 -3
- data/spec/unit/chef_class_spec.rb +23 -4
- data/spec/unit/chef_fs/path_util_spec.rb +108 -0
- data/spec/unit/client_spec.rb +6 -1
- data/spec/unit/config_spec.rb +31 -0
- data/spec/unit/cookbook/metadata_spec.rb +23 -3
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
- data/spec/unit/deprecation_spec.rb +3 -6
- data/spec/unit/dsl/reboot_pending_spec.rb +12 -6
- data/spec/unit/event_dispatch/dispatcher_spec.rb +65 -3
- data/spec/unit/event_dispatch/dsl_spec.rb +83 -0
- data/spec/unit/formatters/doc_spec.rb +32 -0
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +26 -0
- data/spec/unit/json_compat_spec.rb +4 -3
- data/spec/unit/knife/bootstrap/client_builder_spec.rb +27 -0
- data/spec/unit/knife/bootstrap_spec.rb +55 -3
- data/spec/unit/knife/cookbook_site_share_spec.rb +3 -3
- data/spec/unit/knife/core/bootstrap_context_spec.rb +21 -4
- data/spec/unit/knife/core/custom_manifest_loader_spec.rb +41 -0
- data/spec/unit/knife/core/gem_glob_loader_spec.rb +210 -0
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +93 -0
- data/spec/unit/knife/core/subcommand_loader_spec.rb +16 -192
- data/spec/unit/knife/node_run_list_remove_spec.rb +17 -0
- data/spec/unit/knife/ssl_check_spec.rb +4 -0
- data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +10 -10
- data/spec/unit/mixin/params_validate_spec.rb +4 -2
- data/spec/unit/mixin/template_spec.rb +5 -1
- data/spec/unit/mixin/windows_architecture_helper_spec.rb +13 -8
- data/spec/unit/node_spec.rb +220 -0
- data/spec/unit/platform/query_helpers_spec.rb +146 -3
- data/spec/unit/policy_builder/dynamic_spec.rb +275 -0
- data/spec/unit/policy_builder/expand_node_object_spec.rb +37 -38
- data/spec/unit/policy_builder/policyfile_spec.rb +260 -46
- data/spec/unit/property/state_spec.rb +506 -0
- data/spec/unit/property/validation_spec.rb +663 -0
- data/spec/unit/property_spec.rb +1094 -0
- data/spec/unit/provider/deploy_spec.rb +5 -5
- data/spec/unit/provider/directory_spec.rb +35 -0
- data/spec/unit/provider/dsc_resource_spec.rb +3 -10
- data/spec/unit/provider/ifconfig_spec.rb +22 -2
- data/spec/unit/provider/mount/aix_spec.rb +2 -1
- data/spec/unit/provider/mount/mount_spec.rb +6 -0
- data/spec/unit/provider/mount/windows_spec.rb +14 -0
- data/spec/unit/provider/mount_spec.rb +12 -1
- data/spec/unit/provider/package/dpkg_spec.rb +8 -1
- data/spec/unit/provider/package/rpm_spec.rb +18 -1
- data/spec/unit/provider/package/rubygems_spec.rb +18 -0
- data/spec/unit/provider/package/yum_spec.rb +97 -24
- data/spec/unit/provider/powershell_script_spec.rb +106 -0
- data/spec/unit/provider/registry_key_spec.rb +12 -0
- data/spec/unit/provider/remote_directory_spec.rb +1 -2
- data/spec/unit/provider/service/aix_service_spec.rb +3 -3
- data/spec/unit/provider/service/gentoo_service_spec.rb +4 -4
- data/spec/unit/provider/service/macosx_spec.rb +4 -4
- data/spec/unit/provider/service/openbsd_service_spec.rb +10 -8
- data/spec/unit/provider/service/redhat_spec.rb +88 -8
- data/spec/unit/provider/service/upstart_service_spec.rb +11 -7
- data/spec/unit/provider/service/windows_spec.rb +211 -200
- data/spec/unit/provider/subversion_spec.rb +50 -31
- data/spec/unit/provider/template/content_spec.rb +93 -2
- data/spec/unit/provider/user/solaris_spec.rb +66 -9
- data/spec/unit/provider_resolver_spec.rb +707 -650
- data/spec/unit/provider_spec.rb +1 -3
- data/spec/unit/recipe_spec.rb +0 -4
- data/spec/unit/resource/deploy_spec.rb +7 -1
- data/spec/unit/resource/dsc_script_spec.rb +4 -0
- data/spec/unit/resource/file/verification_spec.rb +33 -5
- data/spec/unit/resource/{powershell_spec.rb → powershell_script_spec.rb} +17 -13
- data/spec/unit/resource/service_spec.rb +4 -4
- data/spec/unit/resource/subversion_spec.rb +4 -0
- data/spec/unit/resource/yum_package_spec.rb +10 -1
- data/spec/unit/resource_spec.rb +2 -2
- data/spec/unit/run_context/child_run_context_spec.rb +133 -0
- data/spec/unit/run_context_spec.rb +7 -0
- data/spec/unit/run_list/versioned_recipe_list_spec.rb +5 -0
- data/spec/unit/win32/registry_spec.rb +394 -0
- data/tasks/external_tests.rb +47 -23
- data/tasks/maintainers.rb +155 -14
- metadata +64 -53
- data/lib/chef/knife/bootstrap/templates/archlinux-gems.erb +0 -76
- data/lib/chef/knife/bootstrap/templates/chef-aix.erb +0 -72
- data/spec/unit/provider/powershell_spec.rb +0 -80
- data/spec/unit/registry_helper_spec.rb +0 -376
- data/spec/unit/workstation_config_loader_spec.rb +0 -283
@@ -0,0 +1,106 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Edwards (<adamed@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2013 Opscode, 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
|
+
describe Chef::Provider::PowershellScript, "action_run" do
|
21
|
+
|
22
|
+
let(:powershell_version) { nil }
|
23
|
+
let(:node) {
|
24
|
+
node = Chef::Node.new
|
25
|
+
node.default["kernel"] = Hash.new
|
26
|
+
node.default["kernel"][:machine] = :x86_64.to_s
|
27
|
+
if ! powershell_version.nil?
|
28
|
+
node.default[:languages] = { :powershell => { :version => powershell_version } }
|
29
|
+
end
|
30
|
+
node
|
31
|
+
}
|
32
|
+
|
33
|
+
let(:provider) {
|
34
|
+
empty_events = Chef::EventDispatch::Dispatcher.new
|
35
|
+
run_context = Chef::RunContext.new(node, {}, empty_events)
|
36
|
+
new_resource = Chef::Resource::PowershellScript.new('run some powershell code', run_context)
|
37
|
+
Chef::Provider::PowershellScript.new(new_resource, run_context)
|
38
|
+
}
|
39
|
+
|
40
|
+
context 'when setting interpreter flags' do
|
41
|
+
context 'on nano' do
|
42
|
+
before(:each) do
|
43
|
+
allow(Chef::Platform).to receive(:windows_nano_server?).and_return(true)
|
44
|
+
allow(provider).to receive(:is_forced_32bit).and_return(false)
|
45
|
+
os_info_double = double("os_info")
|
46
|
+
allow(provider.run_context.node.kernel).to receive(:os_info).and_return(os_info_double)
|
47
|
+
allow(os_info_double).to receive(:system_directory).and_return("C:\\Windows\\system32")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "sets the -Command flag as the last flag" do
|
51
|
+
flags = provider.command.split(' ').keep_if { |flag| flag =~ /^-/ }
|
52
|
+
expect(flags.pop).to eq("-Command")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'not on nano' do
|
57
|
+
before(:each) do
|
58
|
+
allow(Chef::Platform).to receive(:windows_nano_server?).and_return(false)
|
59
|
+
allow(provider).to receive(:is_forced_32bit).and_return(false)
|
60
|
+
os_info_double = double("os_info")
|
61
|
+
allow(provider.run_context.node.kernel).to receive(:os_info).and_return(os_info_double)
|
62
|
+
allow(os_info_double).to receive(:system_directory).and_return("C:\\Windows\\system32")
|
63
|
+
end
|
64
|
+
|
65
|
+
it "sets the -File flag as the last flag" do
|
66
|
+
flags = provider.command.split(' ').keep_if { |flag| flag =~ /^-/ }
|
67
|
+
expect(flags.pop).to eq("-File")
|
68
|
+
end
|
69
|
+
|
70
|
+
let(:execution_policy_flag) do
|
71
|
+
execution_policy_index = 0
|
72
|
+
provider_flags = provider.flags.split(' ')
|
73
|
+
execution_policy_specified = false
|
74
|
+
|
75
|
+
provider_flags.find do | value |
|
76
|
+
execution_policy_index += 1
|
77
|
+
execution_policy_specified = value.downcase == '-ExecutionPolicy'.downcase
|
78
|
+
end
|
79
|
+
|
80
|
+
execution_policy = execution_policy_specified ? provider_flags[execution_policy_index] : nil
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when running with an unspecified PowerShell version' do
|
84
|
+
let(:powershell_version) { nil }
|
85
|
+
it "sets the -ExecutionPolicy flag to 'Unrestricted' by default" do
|
86
|
+
expect(execution_policy_flag.downcase).to eq('unrestricted'.downcase)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
{ '2.0' => 'Unrestricted',
|
91
|
+
'2.5' => 'Unrestricted',
|
92
|
+
'3.0' => 'Bypass',
|
93
|
+
'3.6' => 'Bypass',
|
94
|
+
'4.0' => 'Bypass',
|
95
|
+
'5.0' => 'Bypass' }.each do | version_policy |
|
96
|
+
let(:powershell_version) { version_policy[0].to_f }
|
97
|
+
context "when running PowerShell version #{version_policy[0]}" do
|
98
|
+
let(:powershell_version) { version_policy[0].to_f }
|
99
|
+
it "sets the -ExecutionPolicy flag to '#{version_policy[1]}'" do
|
100
|
+
expect(execution_policy_flag.downcase).to eq(version_policy[1].downcase)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -77,6 +77,18 @@ shared_examples_for "a registry key" do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
describe "action_create" do
|
80
|
+
context "when a case insensitive match for the key exists" do
|
81
|
+
before(:each) do
|
82
|
+
expect(@double_registry).to receive(:key_exists?).twice.with(keyname.downcase).and_return(true)
|
83
|
+
end
|
84
|
+
it "should do nothing if the if a case insensitive key and the value both exist" do
|
85
|
+
@provider.new_resource.key(keyname.downcase)
|
86
|
+
expect(@double_registry).to receive(:get_values).with(keyname.downcase).and_return( testval1 )
|
87
|
+
expect(@double_registry).not_to receive(:set_value)
|
88
|
+
@provider.load_current_resource
|
89
|
+
@provider.action_create
|
90
|
+
end
|
91
|
+
end
|
80
92
|
context "when the key exists" do
|
81
93
|
before(:each) do
|
82
94
|
expect(@double_registry).to receive(:key_exists?).twice.with(keyname).and_return(true)
|
@@ -79,7 +79,7 @@ describe Chef::Provider::RemoteDirectory do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
it "configures access control on intermediate directorys" do
|
82
|
-
directory_resource = @provider.send(:
|
82
|
+
directory_resource = @provider.send(:directory_resource, File.join(Dir.tmpdir, "intermediate_dir"))
|
83
83
|
expect(directory_resource.path).to eq(File.join(Dir.tmpdir, "intermediate_dir"))
|
84
84
|
expect(directory_resource.mode).to eq("0750")
|
85
85
|
expect(directory_resource.group).to eq("wheel")
|
@@ -219,4 +219,3 @@ describe Chef::Provider::RemoteDirectory do
|
|
219
219
|
|
220
220
|
end
|
221
221
|
end
|
222
|
-
|
@@ -94,7 +94,7 @@ describe Chef::Provider::Service::Aix do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it "service is a group" do
|
97
|
-
expect(@provider).to receive(:shell_out
|
97
|
+
expect(@provider).to receive(:shell_out).with("lssrc -g chef").and_return(@status)
|
98
98
|
@provider.load_current_resource
|
99
99
|
expect(@provider.instance_eval("@is_resource_group")).to be_truthy
|
100
100
|
end
|
@@ -106,7 +106,7 @@ describe Chef::Provider::Service::Aix do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
it "service is a group" do
|
109
|
-
expect(@provider).to receive(:shell_out
|
109
|
+
expect(@provider).to receive(:shell_out).with("lssrc -g chef").and_return(@status)
|
110
110
|
@provider.load_current_resource
|
111
111
|
expect(@provider.instance_eval("@is_resource_group")).to be_truthy
|
112
112
|
end
|
@@ -119,7 +119,7 @@ describe Chef::Provider::Service::Aix do
|
|
119
119
|
end
|
120
120
|
|
121
121
|
it "service is a subsystem" do
|
122
|
-
expect(@provider).to receive(:shell_out
|
122
|
+
expect(@provider).to receive(:shell_out).with("lssrc -g chef").and_return(@group_status)
|
123
123
|
expect(@provider).to receive(:shell_out!).with("lssrc -s chef").and_return(@service_status)
|
124
124
|
@provider.load_current_resource
|
125
125
|
expect(@provider.instance_eval("@is_resource_group")).to be_falsey
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Lee Jensen (<ljensen@engineyard.com>)
|
3
3
|
# Author:: AJ Christensen (<aj@opscode.com>)
|
4
|
-
# Copyright:: Copyright (c) 2008
|
4
|
+
# Copyright:: Copyright (c) 2008-2015 Chef Software, Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -108,17 +108,17 @@ describe Chef::Provider::Service::Gentoo do
|
|
108
108
|
|
109
109
|
it "should support the status command automatically" do
|
110
110
|
@provider.load_current_resource
|
111
|
-
expect(@
|
111
|
+
expect(@provider.supports[:status]).to be true
|
112
112
|
end
|
113
113
|
|
114
114
|
it "should support the restart command automatically" do
|
115
115
|
@provider.load_current_resource
|
116
|
-
expect(@
|
116
|
+
expect(@provider.supports[:restart]).to be true
|
117
117
|
end
|
118
118
|
|
119
119
|
it "should not support the reload command automatically" do
|
120
120
|
@provider.load_current_resource
|
121
|
-
expect(@
|
121
|
+
expect(@provider.supports[:reload]).to be_falsey
|
122
122
|
end
|
123
123
|
|
124
124
|
end
|
@@ -60,15 +60,15 @@ XML
|
|
60
60
|
|
61
61
|
["Daemon", "Agent"].each do |service_type|
|
62
62
|
["redis-server", "io.redis.redis-server"].each do |service_name|
|
63
|
-
["10.9", "10.10"].each do |platform_version|
|
63
|
+
["10.9", "10.10", "10.11"].each do |platform_version|
|
64
64
|
let(:plist) {'/Library/LaunchDaemons/io.redis.redis-server.plist'}
|
65
65
|
let(:session) { StringIO.new }
|
66
66
|
if service_type == 'Agent'
|
67
67
|
let(:plist) {'/Library/LaunchAgents/io.redis.redis-server.plist'}
|
68
68
|
let(:session) {'-S Aqua '}
|
69
|
-
let(:su_cmd) {'su igor -c'}
|
70
|
-
if platform_version
|
71
|
-
let(:su_cmd) {'su
|
69
|
+
let(:su_cmd) {'su -l igor -c'}
|
70
|
+
if platform_version == "10.9"
|
71
|
+
let(:su_cmd) {'su igor -c'}
|
72
72
|
end
|
73
73
|
end
|
74
74
|
let(:service_label) {'io.redis.redis-server'}
|
@@ -35,10 +35,12 @@ describe Chef::Provider::Service::Openbsd do
|
|
35
35
|
node
|
36
36
|
end
|
37
37
|
|
38
|
+
let(:supports) { {:status => false} }
|
39
|
+
|
38
40
|
let(:new_resource) do
|
39
41
|
new_resource = Chef::Resource::Service.new("sndiod")
|
40
42
|
new_resource.pattern("sndiod")
|
41
|
-
new_resource.supports(
|
43
|
+
new_resource.supports(supports)
|
42
44
|
new_resource
|
43
45
|
end
|
44
46
|
|
@@ -106,9 +108,7 @@ describe Chef::Provider::Service::Openbsd do
|
|
106
108
|
context "when the service supports status" do
|
107
109
|
let(:status) { double(:stdout => "", :exitstatus => 0) }
|
108
110
|
|
109
|
-
|
110
|
-
new_resource.supports({:status => true})
|
111
|
-
end
|
111
|
+
let(:supports) { { :status => true } }
|
112
112
|
|
113
113
|
it "should run '/etc/rc.d/service_name status'" do
|
114
114
|
expect(provider).to receive(:shell_out).with("/etc/rc.d/#{new_resource.service_name} check").and_return(status)
|
@@ -305,10 +305,12 @@ describe Chef::Provider::Service::Openbsd do
|
|
305
305
|
end
|
306
306
|
|
307
307
|
describe Chef::Provider::Service::Openbsd, "restart_service" do
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
308
|
+
context "when the new_resource supports restart" do
|
309
|
+
let(:supports) { { restart: true } }
|
310
|
+
it "should call 'restart' on the service_name if the resource supports it" do
|
311
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{new_resource.service_name} restart")
|
312
|
+
provider.restart_service()
|
313
|
+
end
|
312
314
|
end
|
313
315
|
|
314
316
|
it "should call the restart_command if one has been specified" do
|
@@ -64,24 +64,76 @@ describe "Chef::Provider::Service::Redhat" do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
describe "load current resource" do
|
67
|
-
|
67
|
+
before do
|
68
68
|
status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "")
|
69
|
-
|
69
|
+
allow(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "sets supports[:status] to true by default" do
|
70
73
|
chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "")
|
71
74
|
expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
|
72
|
-
expect(@provider.
|
75
|
+
expect(@provider.service_missing).to be false
|
73
76
|
@provider.load_current_resource
|
74
|
-
expect(@
|
77
|
+
expect(@provider.supports[:status]).to be true
|
78
|
+
end
|
79
|
+
|
80
|
+
it "lets the user override supports[:status] in the new_resource" do
|
81
|
+
@new_resource.supports( { status: false } )
|
82
|
+
@new_resource.pattern "myservice"
|
83
|
+
chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "")
|
84
|
+
expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
|
85
|
+
foo_out = double("ps_command", :exitstatus => 0, :stdout => "a line that matches myservice", :stderr => "")
|
86
|
+
expect(@provider).to receive(:shell_out!).with("foo").and_return(foo_out)
|
87
|
+
expect(@provider.service_missing).to be false
|
88
|
+
expect(@provider).not_to receive(:shell_out).with("/sbin/service chef status")
|
89
|
+
@provider.load_current_resource
|
90
|
+
expect(@provider.supports[:status]).to be false
|
91
|
+
end
|
92
|
+
|
93
|
+
it "sets the current enabled status to true if the service is enabled for any run level" do
|
94
|
+
chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "")
|
95
|
+
expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
|
96
|
+
expect(@provider.service_missing).to be false
|
97
|
+
@provider.load_current_resource
|
98
|
+
expect(@current_resource.enabled).to be true
|
75
99
|
end
|
76
100
|
|
77
101
|
it "sets the current enabled status to false if the regex does not match" do
|
78
|
-
status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "")
|
79
|
-
expect(@provider).to receive(:shell_out).with("/sbin/service chef status").and_return(status)
|
80
102
|
chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:off 6:off", :stderr => "")
|
81
103
|
expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
|
82
|
-
expect(@provider.
|
104
|
+
expect(@provider.service_missing).to be false
|
83
105
|
expect(@provider.load_current_resource).to eql(@current_resource)
|
84
|
-
expect(@current_resource.enabled).to
|
106
|
+
expect(@current_resource.enabled).to be false
|
107
|
+
end
|
108
|
+
|
109
|
+
it "sets the current enabled status to true if the service is enabled at specified run levels" do
|
110
|
+
@new_resource.run_levels([1, 2])
|
111
|
+
chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:on 3:off 4:off 5:off 6:off", :stderr => "")
|
112
|
+
expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
|
113
|
+
expect(@provider.service_missing).to be false
|
114
|
+
@provider.load_current_resource
|
115
|
+
expect(@current_resource.enabled).to be true
|
116
|
+
expect(@provider.current_run_levels).to eql([1, 2])
|
117
|
+
end
|
118
|
+
|
119
|
+
it "sets the current enabled status to false if the service is enabled at a run level it should not" do
|
120
|
+
@new_resource.run_levels([1, 2])
|
121
|
+
chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:on 3:on 4:off 5:off 6:off", :stderr => "")
|
122
|
+
expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
|
123
|
+
expect(@provider.service_missing).to be false
|
124
|
+
@provider.load_current_resource
|
125
|
+
expect(@current_resource.enabled).to be false
|
126
|
+
expect(@provider.current_run_levels).to eql([1, 2, 3])
|
127
|
+
end
|
128
|
+
|
129
|
+
it "sets the current enabled status to false if the service is not enabled at specified run levels" do
|
130
|
+
@new_resource.run_levels([ 2 ])
|
131
|
+
chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:on 2:off 3:off 4:off 5:off 6:off", :stderr => "")
|
132
|
+
expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
|
133
|
+
expect(@provider.service_missing).to be false
|
134
|
+
@provider.load_current_resource
|
135
|
+
expect(@current_resource.enabled).to be false
|
136
|
+
expect(@provider.current_run_levels).to eql([1])
|
85
137
|
end
|
86
138
|
end
|
87
139
|
|
@@ -144,6 +196,28 @@ describe "Chef::Provider::Service::Redhat" do
|
|
144
196
|
expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig #{@new_resource.service_name} on")
|
145
197
|
@provider.enable_service
|
146
198
|
end
|
199
|
+
|
200
|
+
it "should call chkconfig to add 'service_name' at specified run_levels" do
|
201
|
+
allow(@provider).to receive(:run_levels).and_return([1, 2])
|
202
|
+
expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --level 12 #{@new_resource.service_name} on")
|
203
|
+
@provider.enable_service
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should call chkconfig to add 'service_name' at specified run_levels when run_levels do not match" do
|
207
|
+
allow(@provider).to receive(:run_levels).and_return([1, 2])
|
208
|
+
allow(@provider).to receive(:current_run_levels).and_return([1, 3])
|
209
|
+
expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --level 12 #{@new_resource.service_name} on")
|
210
|
+
expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --level 3 #{@new_resource.service_name} off")
|
211
|
+
@provider.enable_service
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should call chkconfig to add 'service_name' at specified run_levels if there is an extra run_level" do
|
215
|
+
allow(@provider).to receive(:run_levels).and_return([1, 2])
|
216
|
+
allow(@provider).to receive(:current_run_levels).and_return([1, 2, 3])
|
217
|
+
expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --level 12 #{@new_resource.service_name} on")
|
218
|
+
expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --level 3 #{@new_resource.service_name} off")
|
219
|
+
@provider.enable_service
|
220
|
+
end
|
147
221
|
end
|
148
222
|
|
149
223
|
describe "disable_service" do
|
@@ -151,6 +225,12 @@ describe "Chef::Provider::Service::Redhat" do
|
|
151
225
|
expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig #{@new_resource.service_name} off")
|
152
226
|
@provider.disable_service
|
153
227
|
end
|
228
|
+
|
229
|
+
it "should call chkconfig to del 'service_name' at specified run_levels" do
|
230
|
+
allow(@provider).to receive(:run_levels).and_return([1, 2])
|
231
|
+
expect(@provider).to receive(:shell_out!).with("/sbin/chkconfig --level 12 #{@new_resource.service_name} off")
|
232
|
+
@provider.disable_service
|
233
|
+
end
|
154
234
|
end
|
155
235
|
|
156
236
|
end
|
@@ -19,6 +19,10 @@
|
|
19
19
|
require 'spec_helper'
|
20
20
|
|
21
21
|
describe Chef::Provider::Service::Upstart do
|
22
|
+
let(:shell_out_success) do
|
23
|
+
double('shell_out_with_systems_locale', :exitstatus => 0, :error? => false)
|
24
|
+
end
|
25
|
+
|
22
26
|
before(:each) do
|
23
27
|
@node =Chef::Node.new
|
24
28
|
@node.name('upstarter')
|
@@ -173,7 +177,7 @@ describe Chef::Provider::Service::Upstart do
|
|
173
177
|
end
|
174
178
|
|
175
179
|
it "should run the services status command if one has been specified" do
|
176
|
-
allow(@provider).to receive(:shell_out!).with("/bin/chefhasmonkeypants status").and_return(
|
180
|
+
allow(@provider).to receive(:shell_out!).with("/bin/chefhasmonkeypants status").and_return(shell_out_success)
|
177
181
|
expect(@current_resource).to receive(:running).with(true)
|
178
182
|
@provider.load_current_resource
|
179
183
|
end
|
@@ -246,7 +250,7 @@ describe Chef::Provider::Service::Upstart do
|
|
246
250
|
end
|
247
251
|
|
248
252
|
it "should call '/sbin/start service_name' if no start command is specified" do
|
249
|
-
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(
|
253
|
+
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(shell_out_success)
|
250
254
|
@provider.start_service()
|
251
255
|
end
|
252
256
|
|
@@ -261,7 +265,7 @@ describe Chef::Provider::Service::Upstart do
|
|
261
265
|
@new_resource.parameters({ "OSD_ID" => "2" })
|
262
266
|
@provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context)
|
263
267
|
@provider.current_resource = @current_resource
|
264
|
-
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start rsyslog OSD_ID=2").and_return(
|
268
|
+
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start rsyslog OSD_ID=2").and_return(shell_out_success)
|
265
269
|
@provider.start_service()
|
266
270
|
end
|
267
271
|
|
@@ -274,13 +278,13 @@ describe Chef::Provider::Service::Upstart do
|
|
274
278
|
|
275
279
|
it "should call '/sbin/restart service_name' if no restart command is specified" do
|
276
280
|
allow(@current_resource).to receive(:running).and_return(true)
|
277
|
-
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/restart #{@new_resource.service_name}").and_return(
|
281
|
+
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/restart #{@new_resource.service_name}").and_return(shell_out_success)
|
278
282
|
@provider.restart_service()
|
279
283
|
end
|
280
284
|
|
281
285
|
it "should call '/sbin/start service_name' if restart_service is called for a stopped service" do
|
282
286
|
allow(@current_resource).to receive(:running).and_return(false)
|
283
|
-
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(
|
287
|
+
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(shell_out_success)
|
284
288
|
@provider.restart_service()
|
285
289
|
end
|
286
290
|
|
@@ -293,7 +297,7 @@ describe Chef::Provider::Service::Upstart do
|
|
293
297
|
|
294
298
|
it "should call '/sbin/reload service_name' if no reload command is specified" do
|
295
299
|
allow(@current_resource).to receive(:running).and_return(true)
|
296
|
-
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/reload #{@new_resource.service_name}").and_return(
|
300
|
+
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/reload #{@new_resource.service_name}").and_return(shell_out_success)
|
297
301
|
@provider.reload_service()
|
298
302
|
end
|
299
303
|
|
@@ -306,7 +310,7 @@ describe Chef::Provider::Service::Upstart do
|
|
306
310
|
|
307
311
|
it "should call '/sbin/stop service_name' if no stop command is specified" do
|
308
312
|
allow(@current_resource).to receive(:running).and_return(true)
|
309
|
-
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/stop #{@new_resource.service_name}").and_return(
|
313
|
+
expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/stop #{@new_resource.service_name}").and_return(shell_out_success)
|
310
314
|
@provider.stop_service()
|
311
315
|
end
|
312
316
|
|