module-puppetdb/spec/unit/classes/server/read_database_ini_spec.rb
Ken Barber 59100fd6bc (PDB-2571) Ensure all managed ini files have correct permissions
Much like read-database.ini, we need to ensure the permissions for puppetdb.ini and others are set explicitly
to ensure permissions are still correct after configuration. Without this users with different umask
settings may find their files are no longer accessible after the module runs.

This patch fixes the globally for all the ini files we currently manage (repl.ini is not managed fwiw).

This also fixes a bug whereby we were missing puppetdb::server::global from the main server class, it adds this
back and fixes the tests to ensure we don't lose it.

Signed-off-by: Ken Barber <ken@bob.sh>
2016-05-12 18:31:50 +01:00

107 lines
4 KiB
Ruby

require 'spec_helper'
describe 'puppetdb::server::read_database', :type => :class do
context 'on a supported platform' do
let(:facts) do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '7.0',
:fqdn => 'test.domain.local',
}
end
it { should contain_class('puppetdb::server::read_database') }
describe 'when using default values' do
it { should contain_file('/etc/puppetlabs/puppetdb/conf.d/read_database.ini').with('ensure' => 'absent') }
end
describe 'when using minimum working values' do
let(:params) do
{
'database_host' => 'puppetdb'
}
end
it { should contain_file('/etc/puppetlabs/puppetdb/conf.d/read_database.ini').
with(
'ensure' => 'file',
'owner' => 'puppetdb',
'group' => 'puppetdb',
'mode' => '0600'
)}
it { should contain_ini_setting('puppetdb_read_database_username').
with(
'ensure' => 'present',
'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
'section' => 'read-database',
'setting' => 'username',
'value' => 'puppetdb'
)}
it { should contain_ini_setting('puppetdb_read_database_password').
with(
'ensure' => 'present',
'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
'section' => 'read-database',
'setting' => 'password',
'value' => 'puppetdb'
)}
it { should contain_ini_setting('puppetdb_read_classname').
with(
'ensure' => 'present',
'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
'section' => 'read-database',
'setting' => 'classname',
'value' => 'org.postgresql.Driver'
)}
it { should contain_ini_setting('puppetdb_read_subprotocol').
with(
'ensure' => 'present',
'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
'section' => 'read-database',
'setting' => 'subprotocol',
'value' => 'postgresql'
)}
it { should contain_ini_setting('puppetdb_read_subname').
with(
'ensure' => 'present',
'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
'section' => 'read-database',
'setting' => 'subname',
'value' => '//puppetdb:5432/puppetdb'
)}
it { should contain_ini_setting('puppetdb_read_log_slow_statements').
with(
'ensure' => 'present',
'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
'section' => 'read-database',
'setting' => 'log-slow-statements',
'value' => 10
)}
it { should contain_ini_setting('puppetdb_read_conn_max_age').
with(
'ensure' => 'present',
'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
'section' => 'read-database',
'setting' => 'conn-max-age',
'value' => '60'
)}
it { should contain_ini_setting('puppetdb_read_conn_keep_alive').
with(
'ensure' => 'present',
'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
'section' => 'read-database',
'setting' => 'conn-keep-alive',
'value' => '45'
)}
it { should contain_ini_setting('puppetdb_read_conn_lifetime').
with(
'ensure' => 'present',
'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
'section' => 'read-database',
'setting' => 'conn-lifetime',
'value' => '0'
)}
end
end
end