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
@@ -21,369 +21,380 @@ require 'spec_helper'
|
|
21
21
|
require 'mixlib/shellout'
|
22
22
|
|
23
23
|
describe Chef::Provider::Service::Windows, "load_current_resource" do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
24
|
+
include_context "Win32"
|
25
|
+
|
26
|
+
let(:new_resource) { Chef::Resource::WindowsService.new("chef") }
|
27
|
+
let(:provider) do
|
28
|
+
prvdr = Chef::Provider::Service::Windows.new(new_resource,
|
29
|
+
Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new))
|
30
|
+
prvdr.current_resource = Chef::Resource::WindowsService.new("current-chef")
|
31
|
+
prvdr
|
32
|
+
end
|
33
|
+
|
34
|
+
before(:all) do
|
33
35
|
Win32::Service = Class.new
|
36
|
+
end
|
37
|
+
|
38
|
+
before(:each) do
|
34
39
|
Win32::Service::AUTO_START = 0x00000002
|
35
40
|
Win32::Service::DEMAND_START = 0x00000003
|
36
41
|
Win32::Service::DISABLED = 0x00000004
|
37
|
-
|
42
|
+
|
43
|
+
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
|
38
44
|
double("StatusStruct", :current_state => "running"))
|
39
|
-
allow(Win32::Service).to receive(:config_info).with(
|
45
|
+
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
|
40
46
|
double("ConfigStruct", :start_type => "auto start"))
|
41
47
|
allow(Win32::Service).to receive(:exists?).and_return(true)
|
42
48
|
allow(Win32::Service).to receive(:configure).and_return(Win32::Service)
|
43
49
|
end
|
44
50
|
|
45
|
-
|
46
|
-
|
47
|
-
|
51
|
+
after(:each) do
|
52
|
+
Win32::Service.send(:remove_const, 'AUTO_START') if defined?(Win32::Service::AUTO_START)
|
53
|
+
Win32::Service.send(:remove_const, 'DEMAND_START') if defined?(Win32::Service::DEMAND_START)
|
54
|
+
Win32::Service.send(:remove_const, 'DISABLED') if defined?(Win32::Service::DISABLED)
|
48
55
|
end
|
49
56
|
|
50
|
-
it "
|
51
|
-
|
57
|
+
it "sets the current resources service name to the new resources service name" do
|
58
|
+
provider.load_current_resource
|
59
|
+
expect(provider.current_resource.service_name).to eq('chef')
|
52
60
|
end
|
53
61
|
|
54
|
-
it "
|
55
|
-
|
56
|
-
expect(@provider.current_resource.running).to be_truthy
|
62
|
+
it "returns the current resource" do
|
63
|
+
expect(provider.load_current_resource).to equal(provider.current_resource)
|
57
64
|
end
|
58
65
|
|
59
|
-
it "
|
60
|
-
|
61
|
-
expect(
|
66
|
+
it "sets the current resources status" do
|
67
|
+
provider.load_current_resource
|
68
|
+
expect(provider.current_resource.running).to be_truthy
|
69
|
+
end
|
70
|
+
|
71
|
+
it "sets the current resources start type" do
|
72
|
+
provider.load_current_resource
|
73
|
+
expect(provider.current_resource.enabled).to be_truthy
|
62
74
|
end
|
63
75
|
|
64
76
|
it "does not set the current resources start type if it is neither AUTO START or DISABLED" do
|
65
|
-
allow(Win32::Service).to receive(:config_info).with(
|
77
|
+
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
|
66
78
|
double("ConfigStruct", :start_type => "manual"))
|
67
|
-
|
68
|
-
expect(
|
79
|
+
provider.load_current_resource
|
80
|
+
expect(provider.current_resource.enabled).to be_nil
|
69
81
|
end
|
70
82
|
|
71
83
|
describe Chef::Provider::Service::Windows, "start_service" do
|
72
84
|
before(:each) do
|
73
|
-
allow(Win32::Service).to receive(:status).with(
|
85
|
+
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
|
74
86
|
double("StatusStruct", :current_state => "stopped"),
|
75
87
|
double("StatusStruct", :current_state => "running"))
|
76
88
|
end
|
77
89
|
|
78
|
-
it "
|
79
|
-
|
80
|
-
expect(
|
81
|
-
|
82
|
-
expect(
|
90
|
+
it "calls the start command if one is specified" do
|
91
|
+
new_resource.start_command "sc start chef"
|
92
|
+
expect(provider).to receive(:shell_out!).with("#{new_resource.start_command}").and_return("Starting custom service")
|
93
|
+
provider.start_service
|
94
|
+
expect(new_resource.updated_by_last_action?).to be_truthy
|
83
95
|
end
|
84
96
|
|
85
|
-
it "
|
86
|
-
expect(Win32::Service).to receive(:start).with(
|
87
|
-
|
88
|
-
expect(
|
97
|
+
it "uses the built-in command if no start command is specified" do
|
98
|
+
expect(Win32::Service).to receive(:start).with(new_resource.service_name)
|
99
|
+
provider.start_service
|
100
|
+
expect(new_resource.updated_by_last_action?).to be_truthy
|
89
101
|
end
|
90
102
|
|
91
|
-
it "
|
92
|
-
allow(Win32::Service).to receive(:exists?).with(
|
93
|
-
expect(Win32::Service).not_to receive(:start).with(
|
94
|
-
|
95
|
-
expect(
|
103
|
+
it "does nothing if the service does not exist" do
|
104
|
+
allow(Win32::Service).to receive(:exists?).with(new_resource.service_name).and_return(false)
|
105
|
+
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
|
106
|
+
provider.start_service
|
107
|
+
expect(new_resource.updated_by_last_action?).to be_falsey
|
96
108
|
end
|
97
109
|
|
98
|
-
it "
|
99
|
-
allow(Win32::Service).to receive(:status).with(
|
110
|
+
it "does nothing if the service is running" do
|
111
|
+
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
|
100
112
|
double("StatusStruct", :current_state => "running"))
|
101
|
-
|
102
|
-
expect(Win32::Service).not_to receive(:start).with(
|
103
|
-
|
104
|
-
expect(
|
113
|
+
provider.load_current_resource
|
114
|
+
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
|
115
|
+
provider.start_service
|
116
|
+
expect(new_resource.updated_by_last_action?).to be_falsey
|
105
117
|
end
|
106
118
|
|
107
|
-
it "
|
108
|
-
allow(Win32::Service).to receive(:status).with(
|
119
|
+
it "raises an error if the service is paused" do
|
120
|
+
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
|
109
121
|
double("StatusStruct", :current_state => "paused"))
|
110
|
-
|
111
|
-
expect(Win32::Service).not_to receive(:start).with(
|
112
|
-
expect {
|
113
|
-
expect(
|
122
|
+
provider.load_current_resource
|
123
|
+
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
|
124
|
+
expect { provider.start_service }.to raise_error( Chef::Exceptions::Service )
|
125
|
+
expect(new_resource.updated_by_last_action?).to be_falsey
|
114
126
|
end
|
115
127
|
|
116
|
-
it "
|
117
|
-
allow(Win32::Service).to receive(:status).with(
|
128
|
+
it "waits and continues if the service is in start_pending" do
|
129
|
+
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
|
118
130
|
double("StatusStruct", :current_state => "start pending"),
|
119
131
|
double("StatusStruct", :current_state => "start pending"),
|
120
132
|
double("StatusStruct", :current_state => "running"))
|
121
|
-
|
122
|
-
expect(Win32::Service).not_to receive(:start).with(
|
123
|
-
|
124
|
-
expect(
|
133
|
+
provider.load_current_resource
|
134
|
+
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
|
135
|
+
provider.start_service
|
136
|
+
expect(new_resource.updated_by_last_action?).to be_falsey
|
125
137
|
end
|
126
138
|
|
127
|
-
it "
|
128
|
-
allow(Win32::Service).to receive(:status).with(
|
139
|
+
it "fails if the service is in stop_pending" do
|
140
|
+
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
|
129
141
|
double("StatusStruct", :current_state => "stop pending"))
|
130
|
-
|
131
|
-
expect(Win32::Service).not_to receive(:start).with(
|
132
|
-
expect {
|
133
|
-
expect(
|
142
|
+
provider.load_current_resource
|
143
|
+
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
|
144
|
+
expect { provider.start_service }.to raise_error( Chef::Exceptions::Service )
|
145
|
+
expect(new_resource.updated_by_last_action?).to be_falsey
|
134
146
|
end
|
135
147
|
|
136
148
|
describe "running as a different account" do
|
137
|
-
let(:old_run_as_user) {
|
138
|
-
let(:old_run_as_password) {
|
149
|
+
let(:old_run_as_user) { new_resource.run_as_user }
|
150
|
+
let(:old_run_as_password) { new_resource.run_as_password }
|
139
151
|
|
140
152
|
before {
|
141
|
-
|
142
|
-
|
153
|
+
new_resource.run_as_user(".\\wallace")
|
154
|
+
new_resource.run_as_password("Wensleydale")
|
143
155
|
}
|
144
156
|
|
145
157
|
after {
|
146
|
-
|
147
|
-
|
158
|
+
new_resource.run_as_user(old_run_as_user)
|
159
|
+
new_resource.run_as_password(old_run_as_password)
|
148
160
|
}
|
149
161
|
|
150
|
-
it "
|
162
|
+
it "calls #grant_service_logon if the :run_as_user and :run_as_password attributes are present" do
|
151
163
|
expect(Win32::Service).to receive(:start)
|
152
|
-
expect(
|
153
|
-
|
164
|
+
expect(provider).to receive(:grant_service_logon).and_return(true)
|
165
|
+
provider.start_service
|
154
166
|
end
|
155
167
|
end
|
156
168
|
end
|
157
169
|
|
158
|
-
|
159
170
|
describe Chef::Provider::Service::Windows, "stop_service" do
|
160
171
|
|
161
172
|
before(:each) do
|
162
|
-
allow(Win32::Service).to receive(:status).with(
|
173
|
+
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
|
163
174
|
double("StatusStruct", :current_state => "running"),
|
164
175
|
double("StatusStruct", :current_state => "stopped"))
|
165
176
|
end
|
166
177
|
|
167
|
-
it "
|
168
|
-
|
169
|
-
expect(
|
170
|
-
|
171
|
-
expect(
|
178
|
+
it "calls the stop command if one is specified" do
|
179
|
+
new_resource.stop_command "sc stop chef"
|
180
|
+
expect(provider).to receive(:shell_out!).with("#{new_resource.stop_command}").and_return("Stopping custom service")
|
181
|
+
provider.stop_service
|
182
|
+
expect(new_resource.updated_by_last_action?).to be_truthy
|
172
183
|
end
|
173
184
|
|
174
|
-
it "
|
175
|
-
expect(Win32::Service).to receive(:stop).with(
|
176
|
-
|
177
|
-
expect(
|
185
|
+
it "uses the built-in command if no stop command is specified" do
|
186
|
+
expect(Win32::Service).to receive(:stop).with(new_resource.service_name)
|
187
|
+
provider.stop_service
|
188
|
+
expect(new_resource.updated_by_last_action?).to be_truthy
|
178
189
|
end
|
179
190
|
|
180
|
-
it "
|
181
|
-
allow(Win32::Service).to receive(:exists?).with(
|
182
|
-
expect(Win32::Service).not_to receive(:stop).with(
|
183
|
-
|
184
|
-
expect(
|
191
|
+
it "does nothing if the service does not exist" do
|
192
|
+
allow(Win32::Service).to receive(:exists?).with(new_resource.service_name).and_return(false)
|
193
|
+
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
|
194
|
+
provider.stop_service
|
195
|
+
expect(new_resource.updated_by_last_action?).to be_falsey
|
185
196
|
end
|
186
197
|
|
187
|
-
it "
|
188
|
-
allow(Win32::Service).to receive(:status).with(
|
198
|
+
it "does nothing if the service is stopped" do
|
199
|
+
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
|
189
200
|
double("StatusStruct", :current_state => "stopped"))
|
190
|
-
|
191
|
-
expect(Win32::Service).not_to receive(:stop).with(
|
192
|
-
|
193
|
-
expect(
|
201
|
+
provider.load_current_resource
|
202
|
+
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
|
203
|
+
provider.stop_service
|
204
|
+
expect(new_resource.updated_by_last_action?).to be_falsey
|
194
205
|
end
|
195
206
|
|
196
|
-
it "
|
197
|
-
allow(Win32::Service).to receive(:status).with(
|
207
|
+
it "raises an error if the service is paused" do
|
208
|
+
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
|
198
209
|
double("StatusStruct", :current_state => "paused"))
|
199
|
-
|
200
|
-
expect(Win32::Service).not_to receive(:start).with(
|
201
|
-
expect {
|
202
|
-
expect(
|
210
|
+
provider.load_current_resource
|
211
|
+
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
|
212
|
+
expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service )
|
213
|
+
expect(new_resource.updated_by_last_action?).to be_falsey
|
203
214
|
end
|
204
215
|
|
205
|
-
it "
|
206
|
-
allow(Win32::Service).to receive(:status).with(
|
216
|
+
it "waits and continue if the service is in stop_pending" do
|
217
|
+
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
|
207
218
|
double("StatusStruct", :current_state => "stop pending"),
|
208
219
|
double("StatusStruct", :current_state => "stop pending"),
|
209
220
|
double("StatusStruct", :current_state => "stopped"))
|
210
|
-
|
211
|
-
expect(Win32::Service).not_to receive(:stop).with(
|
212
|
-
|
213
|
-
expect(
|
221
|
+
provider.load_current_resource
|
222
|
+
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
|
223
|
+
provider.stop_service
|
224
|
+
expect(new_resource.updated_by_last_action?).to be_falsey
|
214
225
|
end
|
215
226
|
|
216
|
-
it "
|
217
|
-
allow(Win32::Service).to receive(:status).with(
|
227
|
+
it "fails if the service is in start_pending" do
|
228
|
+
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
|
218
229
|
double("StatusStruct", :current_state => "start pending"))
|
219
|
-
|
220
|
-
expect(Win32::Service).not_to receive(:stop).with(
|
221
|
-
expect {
|
222
|
-
expect(
|
230
|
+
provider.load_current_resource
|
231
|
+
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
|
232
|
+
expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service )
|
233
|
+
expect(new_resource.updated_by_last_action?).to be_falsey
|
223
234
|
end
|
224
235
|
|
225
|
-
it "
|
226
|
-
allow(Win32::Service).to receive(:status).with(
|
236
|
+
it "passes custom timeout to the stop command if provided" do
|
237
|
+
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
|
227
238
|
double("StatusStruct", :current_state => "running"))
|
228
|
-
|
229
|
-
expect(Win32::Service).to receive(:stop).with(
|
239
|
+
new_resource.timeout 1
|
240
|
+
expect(Win32::Service).to receive(:stop).with(new_resource.service_name)
|
230
241
|
Timeout.timeout(2) do
|
231
|
-
expect {
|
242
|
+
expect { provider.stop_service }.to raise_error(Timeout::Error)
|
232
243
|
end
|
233
|
-
expect(
|
244
|
+
expect(new_resource.updated_by_last_action?).to be_falsey
|
234
245
|
end
|
235
246
|
|
236
247
|
end
|
237
248
|
|
238
249
|
describe Chef::Provider::Service::Windows, "restart_service" do
|
239
250
|
|
240
|
-
it "
|
241
|
-
|
242
|
-
expect(
|
243
|
-
|
244
|
-
expect(
|
251
|
+
it "calls the restart command if one is specified" do
|
252
|
+
new_resource.restart_command "sc restart"
|
253
|
+
expect(provider).to receive(:shell_out!).with("#{new_resource.restart_command}")
|
254
|
+
provider.restart_service
|
255
|
+
expect(new_resource.updated_by_last_action?).to be_truthy
|
245
256
|
end
|
246
257
|
|
247
|
-
it "
|
248
|
-
allow(Win32::Service).to receive(:status).with(
|
258
|
+
it "stops then starts the service if it is running" do
|
259
|
+
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
|
249
260
|
double("StatusStruct", :current_state => "running"),
|
250
261
|
double("StatusStruct", :current_state => "stopped"),
|
251
262
|
double("StatusStruct", :current_state => "stopped"),
|
252
263
|
double("StatusStruct", :current_state => "running"))
|
253
|
-
expect(Win32::Service).to receive(:stop).with(
|
254
|
-
expect(Win32::Service).to receive(:start).with(
|
255
|
-
|
256
|
-
expect(
|
264
|
+
expect(Win32::Service).to receive(:stop).with(new_resource.service_name)
|
265
|
+
expect(Win32::Service).to receive(:start).with(new_resource.service_name)
|
266
|
+
provider.restart_service
|
267
|
+
expect(new_resource.updated_by_last_action?).to be_truthy
|
257
268
|
end
|
258
269
|
|
259
|
-
it "
|
260
|
-
allow(Win32::Service).to receive(:status).with(
|
270
|
+
it "just starts the service if it is stopped" do
|
271
|
+
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
|
261
272
|
double("StatusStruct", :current_state => "stopped"),
|
262
273
|
double("StatusStruct", :current_state => "stopped"),
|
263
274
|
double("StatusStruct", :current_state => "running"))
|
264
|
-
expect(Win32::Service).to receive(:start).with(
|
265
|
-
|
266
|
-
expect(
|
275
|
+
expect(Win32::Service).to receive(:start).with(new_resource.service_name)
|
276
|
+
provider.restart_service
|
277
|
+
expect(new_resource.updated_by_last_action?).to be_truthy
|
267
278
|
end
|
268
279
|
|
269
|
-
it "
|
270
|
-
allow(Win32::Service).to receive(:exists?).with(
|
271
|
-
expect(Win32::Service).not_to receive(:stop).with(
|
272
|
-
expect(Win32::Service).not_to receive(:start).with(
|
273
|
-
|
274
|
-
expect(
|
280
|
+
it "does nothing if the service does not exist" do
|
281
|
+
allow(Win32::Service).to receive(:exists?).with(new_resource.service_name).and_return(false)
|
282
|
+
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
|
283
|
+
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
|
284
|
+
provider.restart_service
|
285
|
+
expect(new_resource.updated_by_last_action?).to be_falsey
|
275
286
|
end
|
276
287
|
|
277
288
|
end
|
278
289
|
|
279
290
|
describe Chef::Provider::Service::Windows, "enable_service" do
|
280
291
|
before(:each) do
|
281
|
-
allow(Win32::Service).to receive(:config_info).with(
|
292
|
+
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
|
282
293
|
double("ConfigStruct", :start_type => "disabled"))
|
283
294
|
end
|
284
295
|
|
285
|
-
it "
|
286
|
-
expect(Win32::Service).to receive(:configure).with(:service_name =>
|
287
|
-
|
288
|
-
expect(
|
296
|
+
it "enables service" do
|
297
|
+
expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::AUTO_START)
|
298
|
+
provider.enable_service
|
299
|
+
expect(new_resource.updated_by_last_action?).to be_truthy
|
289
300
|
end
|
290
301
|
|
291
|
-
it "
|
292
|
-
allow(Win32::Service).to receive(:exists?).with(
|
302
|
+
it "does nothing if the service does not exist" do
|
303
|
+
allow(Win32::Service).to receive(:exists?).with(new_resource.service_name).and_return(false)
|
293
304
|
expect(Win32::Service).not_to receive(:configure)
|
294
|
-
|
295
|
-
expect(
|
305
|
+
provider.enable_service
|
306
|
+
expect(new_resource.updated_by_last_action?).to be_falsey
|
296
307
|
end
|
297
308
|
end
|
298
309
|
|
299
310
|
describe Chef::Provider::Service::Windows, "action_enable" do
|
300
311
|
it "does nothing if the service is enabled" do
|
301
|
-
allow(Win32::Service).to receive(:config_info).with(
|
312
|
+
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
|
302
313
|
double("ConfigStruct", :start_type => "auto start"))
|
303
|
-
expect(
|
304
|
-
|
314
|
+
expect(provider).not_to receive(:enable_service)
|
315
|
+
provider.action_enable
|
305
316
|
end
|
306
317
|
|
307
318
|
it "enables the service if it is not set to automatic start" do
|
308
|
-
allow(Win32::Service).to receive(:config_info).with(
|
319
|
+
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
|
309
320
|
double("ConfigStruct", :start_type => "disabled"))
|
310
|
-
expect(
|
311
|
-
|
321
|
+
expect(provider).to receive(:enable_service)
|
322
|
+
provider.action_enable
|
312
323
|
end
|
313
324
|
end
|
314
325
|
|
315
326
|
describe Chef::Provider::Service::Windows, "action_disable" do
|
316
327
|
it "does nothing if the service is disabled" do
|
317
|
-
allow(Win32::Service).to receive(:config_info).with(
|
328
|
+
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
|
318
329
|
double("ConfigStruct", :start_type => "disabled"))
|
319
|
-
expect(
|
320
|
-
|
330
|
+
expect(provider).not_to receive(:disable_service)
|
331
|
+
provider.action_disable
|
321
332
|
end
|
322
333
|
|
323
334
|
it "disables the service if it is not set to disabled" do
|
324
|
-
allow(Win32::Service).to receive(:config_info).with(
|
335
|
+
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
|
325
336
|
double("ConfigStruct", :start_type => "auto start"))
|
326
|
-
expect(
|
327
|
-
|
337
|
+
expect(provider).to receive(:disable_service)
|
338
|
+
provider.action_disable
|
328
339
|
end
|
329
340
|
end
|
330
341
|
|
331
342
|
describe Chef::Provider::Service::Windows, "disable_service" do
|
332
343
|
before(:each) do
|
333
|
-
allow(Win32::Service).to receive(:config_info).with(
|
344
|
+
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
|
334
345
|
double("ConfigStruct", :start_type => "auto start"))
|
335
346
|
end
|
336
347
|
|
337
|
-
it "
|
348
|
+
it "disables service" do
|
338
349
|
expect(Win32::Service).to receive(:configure)
|
339
|
-
|
340
|
-
expect(
|
350
|
+
provider.disable_service
|
351
|
+
expect(new_resource.updated_by_last_action?).to be_truthy
|
341
352
|
end
|
342
353
|
|
343
|
-
it "
|
344
|
-
allow(Win32::Service).to receive(:exists?).with(
|
354
|
+
it "does nothing if the service does not exist" do
|
355
|
+
allow(Win32::Service).to receive(:exists?).with(new_resource.service_name).and_return(false)
|
345
356
|
expect(Win32::Service).not_to receive(:configure)
|
346
|
-
|
347
|
-
expect(
|
357
|
+
provider.disable_service
|
358
|
+
expect(new_resource.updated_by_last_action?).to be_falsey
|
348
359
|
end
|
349
360
|
end
|
350
361
|
|
351
362
|
describe Chef::Provider::Service::Windows, "action_configure_startup" do
|
352
363
|
{ :automatic => "auto start", :manual => "demand start", :disabled => "disabled" }.each do |type,win32|
|
353
364
|
it "sets the startup type to #{type} if it is something else" do
|
354
|
-
|
355
|
-
allow(
|
356
|
-
expect(
|
357
|
-
|
365
|
+
new_resource.startup_type(type)
|
366
|
+
allow(provider).to receive(:current_start_type).and_return("fire")
|
367
|
+
expect(provider).to receive(:set_startup_type).with(type)
|
368
|
+
provider.action_configure_startup
|
358
369
|
end
|
359
370
|
|
360
371
|
it "leaves the startup type as #{type} if it is already set" do
|
361
|
-
|
362
|
-
allow(
|
363
|
-
expect(
|
364
|
-
|
372
|
+
new_resource.startup_type(type)
|
373
|
+
allow(provider).to receive(:current_start_type).and_return(win32)
|
374
|
+
expect(provider).not_to receive(:set_startup_type).with(type)
|
375
|
+
provider.action_configure_startup
|
365
376
|
end
|
366
377
|
end
|
367
378
|
end
|
368
379
|
|
369
380
|
describe Chef::Provider::Service::Windows, "set_start_type" do
|
370
381
|
it "when called with :automatic it calls Win32::Service#configure with Win32::Service::AUTO_START" do
|
371
|
-
expect(Win32::Service).to receive(:configure).with(:service_name =>
|
372
|
-
|
382
|
+
expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::AUTO_START)
|
383
|
+
provider.send(:set_startup_type, :automatic)
|
373
384
|
end
|
374
385
|
|
375
386
|
it "when called with :manual it calls Win32::Service#configure with Win32::Service::DEMAND_START" do
|
376
|
-
expect(Win32::Service).to receive(:configure).with(:service_name =>
|
377
|
-
|
387
|
+
expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::DEMAND_START)
|
388
|
+
provider.send(:set_startup_type, :manual)
|
378
389
|
end
|
379
390
|
|
380
391
|
it "when called with :disabled it calls Win32::Service#configure with Win32::Service::DISABLED" do
|
381
|
-
expect(Win32::Service).to receive(:configure).with(:service_name =>
|
382
|
-
|
392
|
+
expect(Win32::Service).to receive(:configure).with(:service_name => new_resource.service_name, :start_type => Win32::Service::DISABLED)
|
393
|
+
provider.send(:set_startup_type, :disabled)
|
383
394
|
end
|
384
395
|
|
385
396
|
it "raises an exception when given an unknown start type" do
|
386
|
-
expect {
|
397
|
+
expect { provider.send(:set_startup_type, :fire_truck) }.to raise_error(Chef::Exceptions::ConfigurationError)
|
387
398
|
end
|
388
399
|
end
|
389
400
|
|
@@ -409,9 +420,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
|
|
409
420
|
let(:success_string) { "The task has completed successfully.\r\nSee logfile etc." }
|
410
421
|
let(:failure_string) { "Look on my works, ye Mighty, and despair!" }
|
411
422
|
let(:command) {
|
412
|
-
dbfile =
|
413
|
-
policyfile =
|
414
|
-
logfile =
|
423
|
+
dbfile = provider.grant_dbfile_name(username)
|
424
|
+
policyfile = provider.grant_policyfile_name(username)
|
425
|
+
logfile = provider.grant_logfile_name(username)
|
415
426
|
|
416
427
|
%Q{secedit.exe /configure /db "#{dbfile}" /cfg "#{policyfile}" /areas USER_RIGHTS SECURITYPOLICY SERVICES /log "#{logfile}"}
|
417
428
|
}
|
@@ -424,20 +435,20 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
|
|
424
435
|
|
425
436
|
after {
|
426
437
|
# only needed for the second test.
|
427
|
-
::File.delete(
|
428
|
-
::File.delete(
|
429
|
-
::File.delete(
|
438
|
+
::File.delete(provider.grant_policyfile_name(username)) rescue nil
|
439
|
+
::File.delete(provider.grant_logfile_name(username)) rescue nil
|
440
|
+
::File.delete(provider.grant_dbfile_name(username)) rescue nil
|
430
441
|
}
|
431
442
|
|
432
443
|
it "calls Mixlib::Shellout with the correct command string" do
|
433
444
|
expect_any_instance_of(Mixlib::ShellOut).to receive(:exitstatus).and_return(0)
|
434
|
-
expect(
|
445
|
+
expect(provider.grant_service_logon(username)).to equal true
|
435
446
|
end
|
436
447
|
|
437
448
|
it "raises an exception when the grant command fails" do
|
438
449
|
expect_any_instance_of(Mixlib::ShellOut).to receive(:exitstatus).and_return(1)
|
439
450
|
expect_any_instance_of(Mixlib::ShellOut).to receive(:stdout).and_return(failure_string)
|
440
|
-
expect {
|
451
|
+
expect { provider.grant_service_logon(username) }.to raise_error(Chef::Exceptions::Service)
|
441
452
|
end
|
442
453
|
end
|
443
454
|
|
@@ -445,17 +456,17 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
|
|
445
456
|
include_context "testing private methods"
|
446
457
|
|
447
458
|
it "correctly reformats usernames to create valid filenames" do
|
448
|
-
expect(
|
449
|
-
expect(
|
459
|
+
expect(provider.clean_username_for_path("\\\\problem username/oink.txt")).to eq("_problem_username_oink_txt")
|
460
|
+
expect(provider.clean_username_for_path("boring_username")).to eq("boring_username")
|
450
461
|
end
|
451
462
|
|
452
463
|
it "correctly reformats usernames for the policy file" do
|
453
|
-
expect(
|
454
|
-
expect(
|
464
|
+
expect(provider.canonicalize_username(".\\maryann")).to eq("maryann")
|
465
|
+
expect(provider.canonicalize_username("maryann")).to eq("maryann")
|
455
466
|
|
456
|
-
expect(
|
457
|
-
expect(
|
458
|
-
expect(
|
467
|
+
expect(provider.canonicalize_username("\\\\maryann")).to eq("maryann")
|
468
|
+
expect(provider.canonicalize_username("mydomain\\\\maryann")).to eq("mydomain\\\\maryann")
|
469
|
+
expect(provider.canonicalize_username("\\\\mydomain\\\\maryann")).to eq("mydomain\\\\maryann")
|
459
470
|
end
|
460
471
|
end
|
461
472
|
end
|