Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collab spec tests with marulkan #16

Merged
merged 4 commits into from
May 31, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions spec/classes/accesslogin_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
require 'spec_helper'
describe 'pam::accesslogin' do
describe 'access.conf' do
context 'with default values on supported platform' do
let(:facts) do
{
:osfamily => 'RedHat',
:lsbmajdistrelease => '5',
}
end
it do
should include_class('pam')
should contain_file('access_conf').with({
'ensure' => 'file',
'path' => '/etc/security/access.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
should contain_file('access_conf').with_content(
%{# This file is being maintained by Puppet.
# DO NOT EDIT
#

# allow only the groups listed
+ : root : ALL

# default deny
- : ALL : ALL
})
end
end

context 'with multiple users on supported platform' do
let(:facts) do
{
:osfamily => 'RedHat',
:lsbmajdistrelease => '5',
}
end
let(:pre_condition) do
'class {"pam": allowed_users => ["foo","bar"] }'
end
it do
should include_class('pam')
should contain_file('access_conf').with({
'ensure' => 'file',
'path' => '/etc/security/access.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
should contain_file('access_conf').with_content(
%{# This file is being maintained by Puppet.
# DO NOT EDIT
#

# allow only the groups listed
+ : foo : ALL
+ : bar : ALL

# default deny
- : ALL : ALL
})
end
end

context 'with custom values on supported platform' do
let(:facts) do
{
:osfamily => 'RedHat',
:lsbmajdistrelease => '5',
}
end

let(:params) do
{
:access_conf_path => '/custom/security/access.conf',
:access_conf_owner => 'guido',
:access_conf_group => 'guido',
:access_conf_mode => '0777',
}
end

it do
should include_class('pam')
should contain_file('access_conf').with({
'ensure' => 'file',
'path' => '/custom/security/access.conf',
'owner' => 'guido',
'group' => 'guido',
'mode' => '0777',
})
end
end
end
end
92 changes: 74 additions & 18 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
require 'spec_helper'

describe 'pam' do

describe 'packages' do

describe 'packages' do

context 'with class defaults on rhel 5' do
context 'with class defaults on osfamily redhat with lsbmajdistrelease 5' do
let :facts do
{
:osfamily => 'redhat',
:osfamily => 'RedHat',
:lsbmajdistrelease => '5',
}
end
Expand All @@ -21,31 +19,47 @@
end
end

context 'with class defaults on osfamily redhat with lsbmajdistrelease 6' do
let :facts do
{
:osfamily => 'RedHat',
:lsbmajdistrelease => '6',
}
end

it do
should contain_package('pam_package').with({
'ensure' => 'installed',
'name' => 'pam',
})
end
end

context 'with specifying package_name on valid platform' do
let :facts do
{
:osfamily => 'redhat',
:osfamily => 'RedHat',
:lsbmajdistrelease => '5',
}
end

let(:params) { {:package_name => 'foo'} }
let(:params) { {:package_name => 'foo'} }

it do
should contain_package('pam_package').with({
it do
should contain_package('pam_package').with({
'ensure' => 'installed',
'name' => 'foo',
})
end
end
end
'name' => 'foo',
})
end
end
end

describe 'config files' do
describe 'config files' do

context 'defaults for rhel 5' do
context 'defaults on osfamily redhat with lsbmajdistrelease 5' do
let :facts do
{
:osfamily => 'redhat',
:osfamily => 'RedHat',
:lsbmajdistrelease => '5',
}
end
Expand Down Expand Up @@ -83,5 +97,47 @@
})
end
end
end

context 'defaults on osfamily redhat with lsbmajdistrelease 6' do
let :facts do
{
:osfamily => 'RedHat',
:lsbmajdistrelease => '6',
}
end

it do
should contain_file('pam_system_auth_ac').with({
'ensure' => 'file',
'path' => '/etc/pam.d/system-auth-ac',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})

should contain_file('pam_system_auth').with({
'ensure' => 'symlink',
'path' => '/etc/pam.d/system-auth',
'owner' => 'root',
'group' => 'root',
})

should contain_file('pam_d_login').with({
'ensure' => 'file',
'path' => '/etc/pam.d/login',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})

should contain_file('pam_d_sshd').with({
'ensure' => 'file',
'path' => '/etc/pam.d/sshd',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
end
end
end
end
47 changes: 47 additions & 0 deletions spec/classes/limits_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
require 'spec_helper'
describe 'pam::limits' do
describe 'limits.conf' do
context 'ensure file exists with default values for params on a supported platform' do
let(:facts) do
{
:osfamily => 'RedHat',
:lsbmajdistrelease => '5',
}
end
it {
should include_class('pam')
should contain_file('limits_conf').with({
'ensure' => 'file',
'path' => '/etc/security/limits.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end

context 'ensure file exists with custom values for params on a supported platform' do
let(:facts) do
{
:osfamily => 'RedHat',
:lsbmajdistrelease => '5',
}
end

let(:params) do
{ :config_file => '/custom/security/limits.conf' }
end

it {
should include_class('pam')
should contain_file('limits_conf').with({
'ensure' => 'file',
'path' => '/custom/security/limits.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}
end
end
end