Skip to content

Commit

Permalink
(voxpupuliGH-148) Add spec tests for class parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
vinzent committed Jan 17, 2017
1 parent 15319ef commit 19e1c7e
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions spec/classes/selinux_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
end
it { is_expected.to contain_class('selinux').without_mode }
it { is_expected.to contain_class('selinux').without_type }
it { is_expected.to contain_class('selinux').without_module }
it { is_expected.to contain_class('selinux').without_port }
it { is_expected.to contain_class('selinux').without_fcontext }
it { is_expected.to contain_class('selinux').without_permissive }
it { is_expected.to contain_class('selinux::package') }
it { is_expected.to contain_class('selinux::config') }
it { is_expected.to contain_class('selinux::params') }
Expand All @@ -16,6 +20,76 @@
it { is_expected.to contain_anchor('selinux::module pre').that_comes_before('Anchor[selinux::module post]') }
it { is_expected.to contain_anchor('selinux::module post').that_comes_before('Anchor[selinux::end]') }
it { is_expected.to contain_anchor('selinux::end').that_requires('Anchor[selinux::module post]') }

context 'with module resources defined' do
let(:params) do
{
module: {
'mymodule1' => { 'content' => 'dummy' },
'mymodule2' => { 'content' => 'dummy' }
}
}
end

it { is_expected.to contain_selinux__module('mymodule1') }
it { is_expected.to contain_selinux__module('mymodule2') }
end

context 'with boolean resources defined' do
let(:params) do
{
boolean: {
'mybool1' => {},
'mybool2' => {}
}
}
end

it { is_expected.to contain_selinux__boolean('mybool1') }
it { is_expected.to contain_selinux__boolean('mybool2') }
end

context 'with port resources defined' do
let(:params) do
{
port: {
'myport1' => { 'context' => 'dummy', 'port' => '444', 'protocol' => 'tcp' },
'myport2' => { 'context' => 'dummy', 'port' => '445', 'protocol' => 'tcp' }
}
}
end

it { is_expected.to contain_selinux__port('myport1') }
it { is_expected.to contain_selinux__port('myport2') }
end

context 'with permissive resources defined' do
let(:params) do
{
permissive: {
'domain1' => { 'context' => 'domain1' },
'domain2' => { 'context' => 'domain2' }
}
}
end

it { is_expected.to contain_selinux__permissive('domain1') }
it { is_expected.to contain_selinux__permissive('domain2') }
end

context 'with fcontext resources defined' do
let(:params) do
{
fcontext: {
'myfcontext1' => { 'context' => 'mysqld_log_t', 'pathname' => '/u01/log/mysql(/.*)?' },
'myfcontext2' => { 'context' => 'mysqld_log_t', 'pathname' => '/u02/log/mysql(/.*)?' }
}
}
end

it { is_expected.to contain_selinux__fcontext('myfcontext1') }
it { is_expected.to contain_selinux__fcontext('myfcontext2') }
end
end
end
end

0 comments on commit 19e1c7e

Please sign in to comment.