1 require 'spec_helper_acceptance'
3 describe 'postgresql::server::schema:', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
6 if fact('osfamily') == 'RedHat' and fact('operatingsystemrelease') =~ /5/
11 it 'should create a schema for a user' do
15 $user = 'psql_schema_tester'
16 $password = 'psql_schema_pw'
17 $version = '#{version}'
19 class { 'postgresql::server': }
21 # Since we are not testing pg_hba or any of that, make a local user for ident auth
26 postgresql::server::role { $user:
27 password_hash => postgresql_password($user, $password),
30 postgresql::server::database { $db:
32 require => Postgresql::Server::Role[$user],
35 # Lets setup the base rules
36 $local_auth_option = $version ? {
41 # Create a rule for the user
42 postgresql::server::pg_hba_rule { "allow ${user}":
46 auth_method => 'ident',
47 auth_option => $local_auth_option,
51 postgresql::server::schema { $user:
54 require => Postgresql::Server::Database[$db],
58 apply_manifest(pp, :catch_failures => true)
59 apply_manifest(pp, :catch_changes => true)
61 ## Check that the user can create a table in the database
62 psql('--command="create table psql_schema_tester.foo (foo int)" schema_test', 'psql_schema_tester') do |r|
63 expect(r.stdout).to match(/CREATE TABLE/)
64 expect(r.stderr).to eq('')
67 psql('--command="drop table psql_schema_tester.foo" schema_test', 'psql_schema_tester')