Skip to content

Commit

Permalink
validate policykit::localauthority params + simple rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed Aug 30, 2013
1 parent e829341 commit 8b01bd9
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
6 changes: 6 additions & 0 deletions manifests/localauthority.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
$result_active,
$ensure = present
) {
validate_string($identity)
validate_string($action)
validate_string($result_any)
validate_string($result_inactive)
validate_string($result_active)
validate_re($ensure, ['^present$', '^absent'])

File { owner => 'root', group => 'root' }

Expand Down
69 changes: 69 additions & 0 deletions spec/defines/localauthority_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
require 'spec_helper'

describe 'policykit::localauthority', :type => :define do

describe 'simple case' do
let(:title) { 'foo' }
let :params do
{
:identity => 'bar',
:action => 'baz',
:result_any => 'no',
:result_inactive => 'no',
:result_active => 'no',
}
end

it do
should contain_file('/etc/polkit-1/localauthority/50-local.d/foo.pkla').
with({
:ensure => 'present',
:mode => '0644',
})
end
end

describe 'title space to underscore conversion in file path' do
# example from https://wiki.archlinux.org/index.php/PolicyKit
let(:title) { 'Ban users jack and jill from using gparted' }
let :params do
{
:identity => 'unix-user:jack;unix-user:jill',
:action => 'org.archlinux.pkexec.gparted',
:result_any => 'no',
:result_inactive => 'no',
:result_active => 'no',
}
end

it do
should contain_file('/etc/polkit-1/localauthority/50-local.d/Ban_users_jack_and_jill_from_using_gparted.pkla').
with({
:ensure => 'present',
:mode => '0644',
})
end
end

describe 'ensure => absent' do
let(:title) { 'foo' }
let :params do
{
:identity => 'bar',
:action => 'baz',
:result_any => 'no',
:result_inactive => 'no',
:result_active => 'no',
:ensure => 'absent',
}
end

it do
should contain_file('/etc/polkit-1/localauthority/50-local.d/foo.pkla').
with({
:ensure => 'absent',
})
end
end

end

0 comments on commit 8b01bd9

Please sign in to comment.