Revert "Update 3rdparty rabbitmq module"
[mirror/dsa-puppet.git] / 3rdparty / modules / postgresql / spec / acceptance / server / schema_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'postgresql::server::schema:', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
4
5   let(:version) do
6     if fact('osfamily') == 'RedHat' and fact('operatingsystemrelease') =~ /5/
7       '8.1'
8     end
9   end
10
11   it 'should create a schema for a user' do
12     begin
13       pp = <<-EOS.unindent
14         $db = 'schema_test'
15         $user = 'psql_schema_tester'
16         $password = 'psql_schema_pw'
17         $version = '#{version}'
18
19         class { 'postgresql::server': }
20
21         # Since we are not testing pg_hba or any of that, make a local user for ident auth
22         user { $user:
23           ensure => present,
24         }
25
26         postgresql::server::role { $user:
27           password_hash => postgresql_password($user, $password),
28         }
29
30         postgresql::server::database { $db:
31           owner   => $user,
32           require => Postgresql::Server::Role[$user],
33         }
34
35         # Lets setup the base rules
36         $local_auth_option = $version ? {
37           '8.1'   => 'sameuser',
38           default => undef,
39         }
40
41         # Create a rule for the user
42         postgresql::server::pg_hba_rule { "allow ${user}":
43           type        => 'local',
44           database    => $db,
45           user        => $user,
46           auth_method => 'ident',
47           auth_option => $local_auth_option,
48           order       => 1,
49         }
50
51         postgresql::server::schema { $user:
52           db      => $db,
53           owner   => $user,
54           require => Postgresql::Server::Database[$db],
55         }
56       EOS
57
58       apply_manifest(pp, :catch_failures => true)
59       apply_manifest(pp, :catch_changes => true)
60
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('')
65       end
66     ensure
67       psql('--command="drop table psql_schema_tester.foo" schema_test', 'psql_schema_tester')
68     end
69   end
70
71 end