diff options
author | Jason Barnett <jason.w.barnett@gmail.com> | 2019-10-10 11:41:58 -0400 |
---|---|---|
committer | Jason Barnett <jason.w.barnett@gmail.com> | 2019-10-10 11:56:37 -0400 |
commit | 1d4cb3b4ec01f77c96b2915a0507d7b65905785a (patch) | |
tree | cb65edccefd471bce9f46bbd29daabc5e1b23a0a /spec | |
parent | ed72682f01ef7dddcf694b89201ec23d2e1a9cab (diff) | |
download | chef-1d4cb3b4ec01f77c96b2915a0507d7b65905785a.tar.gz |
Update windows_service to ignore run_as_user case
Signed-off-by: Jason Barnett <jason.w.barnett@gmail.com>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/provider/service/windows_spec.rb | 26 | ||||
-rw-r--r-- | spec/unit/resource/windows_service_spec.rb | 5 |
2 files changed, 28 insertions, 3 deletions
diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb index 860c0b1d6a..4209624057 100644 --- a/spec/unit/provider/service/windows_spec.rb +++ b/spec/unit/provider/service/windows_spec.rb @@ -19,9 +19,17 @@ require "spec_helper" -describe Chef::Provider::Service::Windows, "load_current_resource", :windows_only do +describe Chef::Provider::Service::Windows, "load_current_resource" do include_context "Win32" + before(:all) do + Chef::ReservedNames::Win32::Security = Class.new unless windows? + end + + after(:all) do + Chef::ReservedNames::Win32.send(:remove_const, :Security) unless windows? + end + let(:logger) { double("Mixlib::Log::Child").as_null_object } let(:chef_service_name) { "chef-client" } @@ -105,7 +113,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl allow(Win32::Service).to receive(:exists?).and_return(true) allow(Win32::Service).to receive(:configure).and_return(Win32::Service) allow(Chef::ReservedNames::Win32::Security).to receive(:get_account_right).and_return([]) - allow(Chef::ReservedNames::Win32::Security).to receive(:add_account_right).with("LocalSystem", "SeServiceLogonRight").and_return(0) + allow(Chef::ReservedNames::Win32::Security).to receive(:add_account_right).with("localsystem", "SeServiceLogonRight").and_return(0) end after(:each) do @@ -293,7 +301,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl start_type: 2, error_control: 1, binary_path_name: chef_service_binary_path_name, - service_start_name: "LocalSystem", + service_start_name: "localsystem", desired_access: 983551 ) provider.action_create @@ -384,6 +392,18 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl provider.action_configure end + it "does not configure service when run_as_user case is different" do + provider.current_resource.run_as_user = "JohnDoe" + provider.new_resource.run_as_user = "johndoe" + expect(Win32::Service).not_to receive(:configure) + provider.action_configure + + provider.current_resource.run_as_user = "johndoe" + provider.new_resource.run_as_user = "JohnDoe" + expect(Win32::Service).not_to receive(:configure) + provider.action_configure + end + it "calls converge_delayed_start" do expect(provider).to receive(:converge_delayed_start) provider.action_configure diff --git a/spec/unit/resource/windows_service_spec.rb b/spec/unit/resource/windows_service_spec.rb index a416ca0a05..2c73161913 100644 --- a/spec/unit/resource/windows_service_spec.rb +++ b/spec/unit/resource/windows_service_spec.rb @@ -105,4 +105,9 @@ describe Chef::Resource::WindowsService, "initialize" do expect(resource.send(prop)).to eq(true) end end + + it "lowercases run_as_user" do + resource.run_as_user = "JohnDoe" + expect(resource.run_as_user).to eq("johndoe") + end end |