diff options
author | Bryan McLellan <btm@loftninjas.org> | 2014-08-22 15:13:26 -0400 |
---|---|---|
committer | Bryan McLellan <btm@loftninjas.org> | 2014-08-22 19:07:23 -0400 |
commit | b82a5272ec6798cf26bcf9feaf39faae451b574d (patch) | |
tree | 830d619648a14650f67c681da588ab431e8595ed | |
parent | 8620abd3ea4bb3a717d24a5da2954d4843f4dcac (diff) | |
download | chef-b82a5272ec6798cf26bcf9feaf39faae451b574d.tar.gz |
Look up username instead of resource name
The username isn't always the same as the resource name, and we incorrectly
use the latter when determining if the user exists in #load_current_resource.
Fixes #1705.
-rw-r--r-- | lib/chef/provider/user/windows.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/user/windows_spec.rb | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/chef/provider/user/windows.rb b/lib/chef/provider/user/windows.rb index 350f3ff4c0..918c598774 100644 --- a/lib/chef/provider/user/windows.rb +++ b/lib/chef/provider/user/windows.rb @@ -28,7 +28,7 @@ class Chef def initialize(new_resource,run_context) super - @net_user = Chef::Util::Windows::NetUser.new(@new_resource.name) + @net_user = Chef::Util::Windows::NetUser.new(@new_resource.username) end def load_current_resource diff --git a/spec/unit/provider/user/windows_spec.rb b/spec/unit/provider/user/windows_spec.rb index 70adb8025a..45a1c61c41 100644 --- a/spec/unit/provider/user/windows_spec.rb +++ b/spec/unit/provider/user/windows_spec.rb @@ -42,6 +42,12 @@ describe Chef::Provider::User::Windows do @provider.current_resource = @current_resource end + it "creates a net_user object with the provided username" do + @new_resource.username "not-monkey" + expect(Chef::Util::Windows::NetUser).to receive(:new).with("not-monkey") + @provider = Chef::Provider::User::Windows.new(@new_resource, @run_context) + end + describe "when comparing the user's current attributes to the desired attributes" do before do @new_resource.comment "Adam Jacob" @@ -53,6 +59,7 @@ describe Chef::Provider::User::Windows do @provider.current_resource = @new_resource.clone end + describe "and the attributes match" do it "doesn't set the comment field to be updated" do @provider.set_options.should_not have_key(:full_name) |