diff --git a/lib/puppet/type/acl.rb b/lib/puppet/type/acl.rb index 6770f28..fa1eaad 100644 --- a/lib/puppet/type/acl.rb +++ b/lib/puppet/type/acl.rb @@ -211,20 +211,8 @@ def insync?(is) defaultto :false end - def self.pick_default_perms(perms) - non_default = perms.reject { |perm| perm =~ /^d/ } - default = perms.reject { |perm| perm !~ /^d/ }.map { - |perm| perm.split(':')[1..-1].join(':') - } - Set.new((non_default + default).map { |perm| - key = perm.split(':')[0..1].join(':') - matching_default = default.reject { |tmp_perm| tmp_perm !~ /^#{key}:/ } - if (matching_default.length > 0) - matching_default - else - perm - end - }).to_a.flatten + def self.pick_default_perms(acl) + return acl.reject { |a| a.split(':', -1).length == 4 } end def newchild(path) diff --git a/spec/unit/puppet/type/acl_spec.rb b/spec/unit/puppet/type/acl_spec.rb index 2969827..7eac164 100644 --- a/spec/unit/puppet/type/acl_spec.rb +++ b/spec/unit/puppet/type/acl_spec.rb @@ -129,16 +129,28 @@ end end - context 'when converting default parameters' do + context 'when removing default parameters' do basic_perms = ['user:foo:rwx', 'group:foo:rwx'] advanced_perms = ['user:foo:rwx', 'group:foo:rwx', 'default:user:foo:---'] - advanced_perms_results = ['user:foo:---', 'group:foo:rwx'] + advanced_perms_results = ['user:foo:rwx', 'group:foo:rwx'] + mysql_perms = [ + "user:mysql:rwx", + "d:user:mysql:rw", + "mask::rwx", + ] + mysql_perms_results = [ + "user:mysql:rwx", + "mask::rwx", + ] it 'should not do anything with no defaults' do expect(acl_type.pick_default_perms(basic_perms)).to match_array(basic_perms) end - it 'should override defaults' do + it 'should remove defaults' do expect(acl_type.pick_default_perms(advanced_perms)).to match_array(advanced_perms_results) end + it 'should remove defaults with d:' do + expect(acl_type.pick_default_perms(mysql_perms)).to match_array(mysql_perms_results) + end end end