Added modules
This commit is contained in:
parent
c53c931217
commit
59ec520742
646 changed files with 35182 additions and 0 deletions
|
@ -0,0 +1,23 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'postgresql::server::config_entry', :type => :define do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'RedHat',
|
||||
:operatingsystem => 'RedHat',
|
||||
:operatingsystemrelease => '6.4',
|
||||
}
|
||||
end
|
||||
|
||||
let(:title) { 'config_entry'}
|
||||
|
||||
let :target do
|
||||
tmpfilename('postgresql_conf')
|
||||
end
|
||||
|
||||
context "syntax check" do
|
||||
let(:params) { { :ensure => 'present'} }
|
||||
it { should contain_postgresql__server__config_entry('config_entry') }
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'postgresql::server::database_grant', :type => :define do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
}
|
||||
end
|
||||
|
||||
let :title do
|
||||
'test'
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:privilege => 'ALL',
|
||||
:db => 'test',
|
||||
:role => 'test',
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_postgresql__server__database_grant('test') }
|
||||
it { should contain_postgresql__server__grant('database:test') }
|
||||
end
|
16
modules/postgresql/spec/unit/defines/server/database_spec.rb
Normal file
16
modules/postgresql/spec/unit/defines/server/database_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'postgresql::server::database', :type => :define do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
}
|
||||
end
|
||||
let :title do
|
||||
'test'
|
||||
end
|
||||
it { should contain_postgresql__server__database('test') }
|
||||
it { should contain_postgresql_psql("Check for existence of db 'test'") }
|
||||
end
|
28
modules/postgresql/spec/unit/defines/server/db_spec.rb
Normal file
28
modules/postgresql/spec/unit/defines/server/db_spec.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'postgresql::server::db', :type => :define do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
}
|
||||
end
|
||||
|
||||
let :title do
|
||||
'test'
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:user => 'test',
|
||||
:password => 'test',
|
||||
:owner => 'tester',
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_postgresql__server__db('test') }
|
||||
it { should contain_postgresql__server__database('test').with_owner('tester') }
|
||||
it { should contain_postgresql__server__role('test') }
|
||||
it { should contain_postgresql__server__database_grant('GRANT test - ALL - test') }
|
||||
end
|
24
modules/postgresql/spec/unit/defines/server/grant_spec.rb
Normal file
24
modules/postgresql/spec/unit/defines/server/grant_spec.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'postgresql::server::grant', :type => :define do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
}
|
||||
end
|
||||
|
||||
let :title do
|
||||
'test'
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:db => 'test',
|
||||
:role => 'test',
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_postgresql__server__grant('test') }
|
||||
end
|
161
modules/postgresql/spec/unit/defines/server/pg_hba_rule_spec.rb
Normal file
161
modules/postgresql/spec/unit/defines/server/pg_hba_rule_spec.rb
Normal file
|
@ -0,0 +1,161 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'postgresql::server::pg_hba_rule', :type => :define do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:concat_basedir => tmpfilename('pg_hba'),
|
||||
}
|
||||
end
|
||||
let :title do
|
||||
'test'
|
||||
end
|
||||
let :target do
|
||||
tmpfilename('pg_hba_rule')
|
||||
end
|
||||
|
||||
context 'test template 1' do
|
||||
let :params do
|
||||
{
|
||||
:type => 'host',
|
||||
:database => 'all',
|
||||
:user => 'all',
|
||||
:address => '1.1.1.1/24',
|
||||
:auth_method => 'md5',
|
||||
:target => target,
|
||||
}
|
||||
end
|
||||
it do
|
||||
content = param('concat::fragment', 'pg_hba_rule_test', 'content')
|
||||
content.should =~ /host\s+all\s+all\s+1\.1\.1\.1\/24\s+md5/
|
||||
end
|
||||
end
|
||||
|
||||
context 'test template 2' do
|
||||
let :params do
|
||||
{
|
||||
:type => 'local',
|
||||
:database => 'all',
|
||||
:user => 'all',
|
||||
:auth_method => 'ident',
|
||||
:target => target,
|
||||
}
|
||||
end
|
||||
it do
|
||||
content = param('concat::fragment', 'pg_hba_rule_test', 'content')
|
||||
content.should =~ /local\s+all\s+all\s+ident/
|
||||
end
|
||||
end
|
||||
|
||||
context 'test template 3' do
|
||||
let :params do
|
||||
{
|
||||
:type => 'host',
|
||||
:database => 'all',
|
||||
:user => 'all',
|
||||
:address => '0.0.0.0/0',
|
||||
:auth_method => 'ldap',
|
||||
:auth_option => 'foo=bar',
|
||||
:target => target,
|
||||
}
|
||||
end
|
||||
it do
|
||||
content = param('concat::fragment', 'pg_hba_rule_test', 'content')
|
||||
content.should =~ /host\s+all\s+all\s+0\.0\.0\.0\/0\s+ldap\s+foo=bar/
|
||||
end
|
||||
end
|
||||
|
||||
context 'validation' do
|
||||
context 'validate type test 1' do
|
||||
let :params do
|
||||
{
|
||||
:type => 'invalid',
|
||||
:database => 'all',
|
||||
:user => 'all',
|
||||
:address => '0.0.0.0/0',
|
||||
:auth_method => 'ldap',
|
||||
:target => target,
|
||||
}
|
||||
end
|
||||
it 'should fail parsing when type is not valid' do
|
||||
expect {subject}.to raise_error(Puppet::Error,
|
||||
/The type you specified \[invalid\] must be one of/)
|
||||
end
|
||||
end
|
||||
|
||||
context 'validate auth_method' do
|
||||
let :params do
|
||||
{
|
||||
:type => 'local',
|
||||
:database => 'all',
|
||||
:user => 'all',
|
||||
:address => '0.0.0.0/0',
|
||||
:auth_method => 'invalid',
|
||||
:target => target,
|
||||
}
|
||||
end
|
||||
|
||||
it 'should fail parsing when auth_method is not valid' do
|
||||
expect {subject}.to raise_error(Puppet::Error,
|
||||
/The auth_method you specified \[invalid\] must be one of/)
|
||||
end
|
||||
end
|
||||
|
||||
context 'validate unsupported auth_method' do
|
||||
let :pre_condition do
|
||||
<<-EOS
|
||||
class { 'postgresql::globals':
|
||||
version => '9.0',
|
||||
}
|
||||
class { 'postgresql::server': }
|
||||
EOS
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:type => 'local',
|
||||
:database => 'all',
|
||||
:user => 'all',
|
||||
:address => '0.0.0.0/0',
|
||||
:auth_method => 'peer',
|
||||
:target => target,
|
||||
}
|
||||
end
|
||||
|
||||
it 'should fail parsing when auth_method is not valid' do
|
||||
expect {subject}.to raise_error(Puppet::Error,
|
||||
/The auth_method you specified \[peer\] must be one of: trust, reject, md5, sha1, password, gss, sspi, krb5, ident, ldap, radius, cert, pam/)
|
||||
end
|
||||
end
|
||||
|
||||
context 'validate supported auth_method' do
|
||||
let :pre_condition do
|
||||
<<-EOS
|
||||
class { 'postgresql::globals':
|
||||
version => '9.2',
|
||||
}
|
||||
class { 'postgresql::server': }
|
||||
EOS
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:type => 'local',
|
||||
:database => 'all',
|
||||
:user => 'all',
|
||||
:address => '0.0.0.0/0',
|
||||
:auth_method => 'peer',
|
||||
:target => target,
|
||||
}
|
||||
end
|
||||
|
||||
it do
|
||||
content = param('concat::fragment', 'pg_hba_rule_test', 'content')
|
||||
content.should =~ /local\s+all\s+all\s+0\.0\.0\.0\/0\s+peer/
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
23
modules/postgresql/spec/unit/defines/server/role_spec.rb
Normal file
23
modules/postgresql/spec/unit/defines/server/role_spec.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'postgresql::server::role', :type => :define do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
}
|
||||
end
|
||||
|
||||
let :title do
|
||||
'test'
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:password_hash => 'test',
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_postgresql__server__role('test') }
|
||||
end
|
|
@ -0,0 +1,27 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'postgresql::server::table_grant', :type => :define do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
}
|
||||
end
|
||||
|
||||
let :title do
|
||||
'test'
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:privilege => 'ALL',
|
||||
:db => 'test',
|
||||
:role => 'test',
|
||||
:table => 'foo',
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_postgresql__server__table_grant('test') }
|
||||
it { should contain_postgresql__server__grant('table:test') }
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'postgresql::server::tablespace', :type => :define do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
}
|
||||
end
|
||||
|
||||
let :title do
|
||||
'test'
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:location => '/srv/data/foo',
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_postgresql__server__tablespace('test') }
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'postgresql::validate_db_connection', :type => :define do
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
}
|
||||
end
|
||||
|
||||
let :title do
|
||||
'test'
|
||||
end
|
||||
|
||||
describe 'should work with only default parameters' do
|
||||
it { should contain_postgresql__validate_db_connection('test') }
|
||||
end
|
||||
|
||||
describe 'should work with all parameters' do
|
||||
let :params do
|
||||
{
|
||||
:database_host => 'test',
|
||||
:database_name => 'test',
|
||||
:database_password => 'test',
|
||||
:database_username => 'test',
|
||||
:database_port => 5432,
|
||||
:run_as => 'postgresq',
|
||||
:sleep => 4,
|
||||
:tries => 30,
|
||||
}
|
||||
end
|
||||
it { should contain_postgresql__validate_db_connection('test') }
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue