diff options
author | vasu1105 <vasundhara.jagdale@msystechnologies.com> | 2018-09-24 11:18:05 +0530 |
---|---|---|
committer | vasu1105 <vasundhara.jagdale@msystechnologies.com> | 2018-09-24 14:32:09 +0530 |
commit | 367f896a6a2b55568844cd1a2bd276a13d4e0722 (patch) | |
tree | fd839cfa3bf837e49842ceb4db43c0a3bb367ff0 | |
parent | 859571775d28eb4f2922614abe1114db1a23094e (diff) | |
download | chef-367f896a6a2b55568844cd1a2bd276a13d4e0722.tar.gz |
MSYS-888 Adds full_name property to user resource for Windows.
Signed-off-by: vasu1105 <vasundhara.jagdale@msystechnologies.com>
-rw-r--r-- | lib/chef/provider/user/windows.rb | 7 | ||||
-rw-r--r-- | lib/chef/resource/user/windows_user.rb | 3 | ||||
-rw-r--r-- | spec/functional/resource/user/windows_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/user/windows_spec.rb | 15 |
4 files changed, 20 insertions, 7 deletions
diff --git a/lib/chef/provider/user/windows.rb b/lib/chef/provider/user/windows.rb index 849382b363..f393b81919 100644 --- a/lib/chef/provider/user/windows.rb +++ b/lib/chef/provider/user/windows.rb @@ -39,12 +39,12 @@ class Chef logger.warn("The 'gid' (or 'group') property is not implemented on the Windows platform. Please use the `members` property of the 'group' resource to assign a user to a group.") end - @current_resource = Chef::Resource::User.new(new_resource.name) + @current_resource = Chef::Resource::User::WindowsUser.new(new_resource.name) current_resource.username(new_resource.username) begin user_info = @net_user.get_info - current_resource.uid(user_info[:user_id]) + current_resource.full_name(user_info[:full_name]) current_resource.comment(user_info[:comment]) current_resource.home(user_info[:home_dir]) current_resource.shell(user_info[:script_path]) @@ -67,7 +67,7 @@ class Chef logger.trace("#{new_resource} password has changed") return true end - [ :uid, :comment, :home, :shell ].any? do |user_attrib| + [ :uid, :comment, :home, :shell, :full_name ].any? do |user_attrib| !new_resource.send(user_attrib).nil? && new_resource.send(user_attrib) != current_resource.send(user_attrib) end end @@ -100,6 +100,7 @@ class Chef opts = { name: new_resource.username } field_list = { + "full_name" => "full_name", "comment" => "comment", "home" => "home_dir", "uid" => "user_id", diff --git a/lib/chef/resource/user/windows_user.rb b/lib/chef/resource/user/windows_user.rb index baedc14f5e..da50467998 100644 --- a/lib/chef/resource/user/windows_user.rb +++ b/lib/chef/resource/user/windows_user.rb @@ -25,6 +25,9 @@ class Chef provides :windows_user provides :user, os: "windows" + + property :full_name, String, + description: "The full name of the user." end end end diff --git a/spec/functional/resource/user/windows_spec.rb b/spec/functional/resource/user/windows_spec.rb index c5792b1ea9..3a5535f194 100644 --- a/spec/functional/resource/user/windows_spec.rb +++ b/spec/functional/resource/user/windows_spec.rb @@ -36,7 +36,7 @@ describe Chef::Provider::User::Windows, :windows_only do let(:logger) { double("Mixlib::Log::Child").as_null_object } let(:run_context) { Chef::RunContext.new(node, {}, events) } let(:new_resource) do - Chef::Resource::User.new(username, run_context).tap do |r| + Chef::Resource::User::WindowsUser.new(username, run_context).tap do |r| r.provider(Chef::Provider::User::Windows) r.password(password) end diff --git a/spec/unit/provider/user/windows_spec.rb b/spec/unit/provider/user/windows_spec.rb index 76234def1a..b5c6954575 100644 --- a/spec/unit/provider/user/windows_spec.rb +++ b/spec/unit/provider/user/windows_spec.rb @@ -53,7 +53,8 @@ describe Chef::Provider::User::Windows do describe "when comparing the user's current properties to the desired properties" do before do - @new_resource.comment "Adam Jacob" + @new_resource.full_name "Adam Jacob" + @new_resource.comment "Some comments" @new_resource.uid 1000 @new_resource.gid 1000 @new_resource.home "/home/adam" @@ -88,12 +89,16 @@ describe Chef::Provider::User::Windows do expect(@provider.set_options).not_to have_key(:password) end + it "doesn't set the full_name to be updated" do + expect(@provider.set_options).not_to have_key(:full_name) + end end describe "and the properties do not match" do before do @current_resource = Chef::Resource::User::WindowsUser.new("adam") - @current_resource.comment "Adam Jacob-foo" + @current_resource.full_name "Adam Jacob-foo" + @current_resource.comment "some comments" @current_resource.uid 1111 @current_resource.gid 1111 @current_resource.home "/home/adam-foo" @@ -102,8 +107,12 @@ describe Chef::Provider::User::Windows do @provider.current_resource = @current_resource end + it "marks the full_name field to be updated" do + expect(@provider.set_options[:full_name]).to eq("Adam Jacob") + end + it "marks the comment field to be updated" do - expect(@provider.set_options[:comment]).to eq("Adam Jacob") + expect(@provider.set_options[:comment]).to eq("Some comments") end it "marks the home_dir property to be updated" do |