forked from pdrakeweb/puppet-acl
-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e59b8b6
commit b84c8ae
Showing
2 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'spec_helper' | ||
|
||
provider_class = Puppet::Type.type(:acl).provider(:posixacl) | ||
|
||
describe provider_class do | ||
|
||
it 'declares a getfacl command' do | ||
expect{ | ||
provider_class.command :getfacl | ||
}.not_to raise_error | ||
end | ||
it 'declares a setfacl command' do | ||
expect{ | ||
provider_class.command :setfacl | ||
}.not_to raise_error | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
require 'spec_helper' | ||
|
||
acl_type = Puppet::Type.type(:acl) | ||
|
||
|
||
describe acl_type do | ||
context 'when not setting parameters' do | ||
it 'should fail without permissions' do | ||
expect{ | ||
acl_type.new :name => '/tmp/foo' | ||
}.to raise_error | ||
end | ||
end | ||
context 'when setting parameters' do | ||
it 'should work with a correct permission parameter' do | ||
resource = acl_type.new :name => '/tmp/foo', :permission => ['user:root:rwx'] | ||
expect(resource[:name]).to eq('/tmp/foo') | ||
expect(resource[:permission]).to eq(['user:root:rwx']) | ||
end | ||
it 'should convert a permission string to an array' do | ||
resource = acl_type.new :name => '/tmp/foo', :permission => 'user:root:rwx' | ||
expect(resource[:name]).to eq('/tmp/foo') | ||
expect(resource[:permission]).to eq(['user:root:rwx']) | ||
end | ||
it 'should convert the u: shorcut to user:' do | ||
resource = acl_type.new :name => '/tmp/foo', :permission => ['u:root:rwx'] | ||
expect(resource[:name]).to eq('/tmp/foo') | ||
expect(resource[:permission]).to eq(['user:root:rwx']) | ||
end | ||
it 'should convert the g: shorcut to group:' do | ||
resource = acl_type.new :name => '/tmp/foo', :permission => ['g:root:rwx'] | ||
expect(resource[:name]).to eq('/tmp/foo') | ||
expect(resource[:permission]).to eq(['group:root:rwx']) | ||
end | ||
it 'should convert the m: shorcut to mask:' do | ||
resource = acl_type.new :name => '/tmp/foo', :permission => ['m::rwx'] | ||
expect(resource[:name]).to eq('/tmp/foo') | ||
expect(resource[:permission]).to eq(['mask::rwx']) | ||
end | ||
it 'should convert the o: shorcut to other:' do | ||
resource = acl_type.new :name => '/tmp/foo', :permission => ['o::rwx'] | ||
expect(resource[:name]).to eq('/tmp/foo') | ||
expect(resource[:permission]).to eq(['other::rwx']) | ||
end | ||
it 'should have the "set" action by default' do | ||
resource = acl_type.new :name => '/tmp/foo', :permission => ['o::rwx'] | ||
expect(resource[:name]).to eq('/tmp/foo') | ||
expect(resource[:action]).to eq(:set) | ||
end | ||
it 'should accept an action "set"' do | ||
resource = acl_type.new :name => '/tmp/foo', :permission => ['o::rwx'], :action => :set | ||
expect(resource[:name]).to eq('/tmp/foo') | ||
expect(resource[:action]).to eq(:set) | ||
end | ||
it 'should accept an action "purge"' do | ||
resource = acl_type.new :name => '/tmp/foo', :permission => ['o::rwx'], :action => :purge | ||
expect(resource[:name]).to eq('/tmp/foo') | ||
expect(resource[:action]).to eq(:purge) | ||
end | ||
it 'should accept an action "unset"' do | ||
resource = acl_type.new :name => '/tmp/foo', :permission => ['o::rwx'], :action => :unset | ||
expect(resource[:name]).to eq('/tmp/foo') | ||
expect(resource[:action]).to eq(:unset) | ||
end | ||
it 'should accept an action "exact"' do | ||
resource = acl_type.new :name => '/tmp/foo', :permission => ['o::rwx'], :action => :exact | ||
expect(resource[:name]).to eq('/tmp/foo') | ||
expect(resource[:action]).to eq(:exact) | ||
end | ||
it 'should have path as namevar' do | ||
resource = acl_type.new :name => '/tmp/foo', :permission => ['o::rwx'] | ||
expect(resource[:name]).to eq('/tmp/foo') | ||
expect(resource[:path]).to eq(resource[:name]) | ||
end | ||
it 'should accept a path parameter' do | ||
resource = acl_type.new :path => '/tmp/foo', :permission => ['o::rwx'], :action => :exact | ||
expect(resource[:path]).to eq('/tmp/foo') | ||
expect(resource[:name]).to eq(resource[:path]) | ||
end | ||
it 'should not be recursive by default' do | ||
resource = acl_type.new :name => '/tmp/foo', :permission => ['o::rwx'] | ||
expect(resource[:name]).to eq('/tmp/foo') | ||
expect(resource[:recursive]).to eq(:false) | ||
end | ||
it 'should accept a recursive "true"' do | ||
resource = acl_type.new :name => '/tmp/foo', :permission => ['o::rwx'], :recursive => true | ||
expect(resource[:name]).to eq('/tmp/foo') | ||
expect(resource[:recursive]).to eq(:true) | ||
end | ||
it 'should accept a recurse "false"' do | ||
resource = acl_type.new :name => '/tmp/foo', :permission => ['o::rwx'], :recursive => false | ||
expect(resource[:name]).to eq('/tmp/foo') | ||
expect(resource[:recursive]).to eq(:false) | ||
end | ||
it 'should fail with a wrong action' do | ||
expect{ | ||
acl_type.new :name => '/tmp/foo', :permission => ['o::rwx'], :action => :xset | ||
}.to raise_error | ||
end | ||
it 'should fail with a wrong first argument' do | ||
expect{ | ||
acl_type.new :name => '/tmp/foo', :permission => ['wrong::rwx'] | ||
}.to raise_error | ||
end | ||
it 'should fail with a wrong last argument' do | ||
expect{ | ||
acl_type.new :name => '/tmp/foo', :permission => ['user::-_-'] | ||
}.to raise_error | ||
end | ||
end | ||
|
||
end |