diff options
author | Matt Wrock <matt@mattwrock.com> | 2015-10-08 16:00:01 -0700 |
---|---|---|
committer | Matt Wrock <matt@mattwrock.com> | 2015-10-08 16:00:01 -0700 |
commit | 56b3c90bbd7c4657533b99d04dcdc3419dcd472b (patch) | |
tree | 9c4085647413fe80d2e96974badef33203bcc1c6 | |
parent | cdbd244f7d1de53c7228f6758866c083ae71a3c3 (diff) | |
parent | 694b46930976f3cb35c166da12f3413dc4dfbdef (diff) | |
download | chef-56b3c90bbd7c4657533b99d04dcdc3419dcd472b.tar.gz |
Merge pull request #4046 from chef/mwrock/no_win_group
ignore gid in the user resource on windows
-rw-r--r-- | lib/chef/provider/user/windows.rb | 8 | ||||
-rw-r--r-- | spec/functional/resource/user/windows_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/provider/user/windows_spec.rb | 4 |
3 files changed, 15 insertions, 5 deletions
diff --git a/lib/chef/provider/user/windows.rb b/lib/chef/provider/user/windows.rb index e282a11d45..76519bb498 100644 --- a/lib/chef/provider/user/windows.rb +++ b/lib/chef/provider/user/windows.rb @@ -35,6 +35,10 @@ class Chef end def load_current_resource + if @new_resource.gid + Chef::Log.warn("The 'gid' attribute is not implemented by the Windows platform. Please use the 'group' resource to assign a user to a group.") + end + @current_resource = Chef::Resource::User.new(@new_resource.name) @current_resource.username(@new_resource.username) user_info = nil @@ -42,7 +46,6 @@ class Chef user_info = @net_user.get_info @current_resource.uid(user_info[:user_id]) - @current_resource.gid(user_info[:primary_group_id]) @current_resource.comment(user_info[:full_name]) @current_resource.home(user_info[:home_dir]) @current_resource.shell(user_info[:script_path]) @@ -65,7 +68,7 @@ class Chef Chef::Log.debug("#{@new_resource} password has changed") return true end - [ :uid, :gid, :comment, :home, :shell ].any? do |user_attrib| + [ :uid, :comment, :home, :shell ].any? do |user_attrib| !@new_resource.send(user_attrib).nil? && @new_resource.send(user_attrib) != @current_resource.send(user_attrib) end end @@ -100,7 +103,6 @@ class Chef field_list = { 'comment' => 'full_name', 'home' => 'home_dir', - 'gid' => 'primary_group_id', 'uid' => 'user_id', 'shell' => 'script_path', 'password' => 'password' diff --git a/spec/functional/resource/user/windows_spec.rb b/spec/functional/resource/user/windows_spec.rb index 5e68478b34..5e3a9090d4 100644 --- a/spec/functional/resource/user/windows_spec.rb +++ b/spec/functional/resource/user/windows_spec.rb @@ -66,6 +66,14 @@ describe Chef::Provider::User::Windows, :windows_only do new_resource.run_action(:create) expect(new_resource).to be_updated_by_last_action end + + context 'with a gid specified' do + it 'warns unsupported' do + expect(Chef::Log).to receive(:warn).with(/not implemented/) + new_resource.gid('agroup') + new_resource.run_action(:create) + end + end end describe 'action :remove' do diff --git a/spec/unit/provider/user/windows_spec.rb b/spec/unit/provider/user/windows_spec.rb index e51e20a68f..7e08f971a9 100644 --- a/spec/unit/provider/user/windows_spec.rb +++ b/spec/unit/provider/user/windows_spec.rb @@ -107,8 +107,8 @@ describe Chef::Provider::User::Windows do expect(@provider.set_options[:home_dir]).to eq('/home/adam') end - it "marks the primary_group_id attribute to be updated" do - expect(@provider.set_options[:primary_group_id]).to eq(1000) + it "ignores the primary_group_id attribute" do + expect(@provider.set_options[:primary_group_id]).to eq(nil) end it "marks the user_id attribute to be updated" do |