|
29 | 29 | "class {'postgresql::server':}"
|
30 | 30 | end
|
31 | 31 |
|
| 32 | + it { is_expected.to compile.with_all_deps } |
32 | 33 | it { is_expected.to contain_postgresql__server__grant('test') }
|
33 | 34 | end
|
34 | 35 |
|
|
46 | 47 | "class {'postgresql::server':}"
|
47 | 48 | end
|
48 | 49 |
|
| 50 | + it { is_expected.to compile.with_all_deps } |
49 | 51 | it { is_expected.to contain_postgresql__server__grant('test') }
|
50 |
| - it { |
51 |
| - is_expected.to contain_postgresql_psql('grant:test').with( |
52 |
| - 'command' => %r{GRANT USAGE ON SEQUENCE "test" TO\s* "test"}m, |
53 |
| - 'unless' => %r{SELECT 1 WHERE has_sequence_privilege\('test',\s* 'test', 'USAGE'\)}m, |
54 |
| - ) |
55 |
| - } |
| 52 | + it do |
| 53 | + is_expected.to contain_postgresql_psql('grant:test') |
| 54 | + .with_command(%r{GRANT USAGE ON SEQUENCE "test" TO\s* "test"}m) |
| 55 | + .with_unless(%r{SELECT 1 WHERE has_sequence_privilege\('test',\s* 'test', 'USAGE'\)}m) |
| 56 | + end |
56 | 57 | end
|
57 | 58 |
|
58 | 59 | context 'SeQuEnCe case insensitive object_type match' do
|
|
69 | 70 | "class {'postgresql::server':}"
|
70 | 71 | end
|
71 | 72 |
|
| 73 | + it { is_expected.to compile.with_all_deps } |
72 | 74 | it { is_expected.to contain_postgresql__server__grant('test') }
|
73 |
| - it { |
74 |
| - is_expected.to contain_postgresql_psql('grant:test').with( |
75 |
| - 'command' => %r{GRANT USAGE ON SEQUENCE "test" TO\s* "test"}m, |
76 |
| - 'unless' => %r{SELECT 1 WHERE has_sequence_privilege\('test',\s* 'test', 'USAGE'\)}m, |
77 |
| - ) |
78 |
| - } |
| 75 | + it do |
| 76 | + is_expected.to contain_postgresql_psql('grant:test') |
| 77 | + .with_command(%r{GRANT USAGE ON SEQUENCE "test" TO\s* "test"}m) |
| 78 | + .with_unless(%r{SELECT 1 WHERE has_sequence_privilege\('test',\s* 'test', 'USAGE'\)}m) |
| 79 | + end |
79 | 80 | end
|
80 | 81 |
|
81 | 82 | context 'all sequences' do
|
|
93 | 94 | "class {'postgresql::server':}"
|
94 | 95 | end
|
95 | 96 |
|
| 97 | + it { is_expected.to compile.with_all_deps } |
96 | 98 | it { is_expected.to contain_postgresql__server__grant('test') }
|
97 |
| - it { |
98 |
| - is_expected.to contain_postgresql_psql('grant:test').with( |
99 |
| - 'command' => %r{GRANT USAGE ON ALL SEQUENCES IN SCHEMA "public" TO\s* "test"}m, |
100 |
| - 'unless' => %r{SELECT 1 WHERE NOT EXISTS \(\s*SELECT sequence_name\s* FROM information_schema\.sequences\s* WHERE sequence_schema='public'\s* EXCEPT DISTINCT\s* SELECT object_name as sequence_name\s* FROM .* WHERE .*grantee='test'\s* AND object_schema='public'\s* AND privilege_type='USAGE'\s*\)}m, # rubocop:disable Metrics/LineLength |
101 |
| - ) |
102 |
| - } |
| 99 | + it do |
| 100 | + is_expected.to contain_postgresql_psql('grant:test') |
| 101 | + .with_command(%r{GRANT USAGE ON ALL SEQUENCES IN SCHEMA "public" TO\s* "test"}m) |
| 102 | + .with_unless(%r{SELECT 1 WHERE NOT EXISTS \(\s*SELECT sequence_name\s* FROM information_schema\.sequences\s* WHERE sequence_schema='public'\s* EXCEPT DISTINCT\s* SELECT object_name as sequence_name\s* FROM .* WHERE .*grantee='test'\s* AND object_schema='public'\s* AND privilege_type='USAGE'\s*\)}m) # rubocop:disable Metrics/LineLength |
| 103 | + end |
103 | 104 | end
|
104 | 105 |
|
105 | 106 | context 'with specific db connection settings - default port' do
|
|
116 | 117 | "class {'postgresql::server':}"
|
117 | 118 | end
|
118 | 119 |
|
| 120 | + it { is_expected.to compile.with_all_deps } |
119 | 121 | it { is_expected.to contain_postgresql__server__grant('test') }
|
120 | 122 | it { is_expected.to contain_postgresql_psql('grant:test').with_connect_settings('PGHOST' => 'postgres-db-server', 'DBVERSION' => '9.1').with_port(5432) }
|
121 | 123 | end
|
|
135 | 137 | "class {'postgresql::server':}"
|
136 | 138 | end
|
137 | 139 |
|
| 140 | + it { is_expected.to compile.with_all_deps } |
138 | 141 | it { is_expected.to contain_postgresql__server__grant('test') }
|
139 | 142 | it { is_expected.to contain_postgresql_psql('grant:test').with_connect_settings('PGHOST' => 'postgres-db-server', 'DBVERSION' => '9.1', 'PGPORT' => '1234') }
|
140 | 143 | end
|
|
155 | 158 | "class {'postgresql::server':}"
|
156 | 159 | end
|
157 | 160 |
|
| 161 | + it { is_expected.to compile.with_all_deps } |
158 | 162 | it { is_expected.to contain_postgresql__server__grant('test') }
|
159 | 163 | it { is_expected.to contain_postgresql_psql('grant:test').with_connect_settings('PGHOST' => 'postgres-db-server', 'DBVERSION' => '9.1', 'PGPORT' => '1234').with_port('5678') }
|
160 | 164 | end
|
|
174 | 178 | "class {'postgresql::server':}"
|
175 | 179 | end
|
176 | 180 |
|
| 181 | + it { is_expected.to compile.with_all_deps } |
177 | 182 | it { is_expected.to contain_postgresql__server__grant('test') }
|
178 |
| - it { |
179 |
| - is_expected.to contain_postgresql_psql('grant:test').with( |
180 |
| - 'command' => %r{GRANT ALL ON TABLE "myschema"."mytable" TO\s* "test"}m, |
181 |
| - 'unless' => %r{SELECT 1 WHERE has_table_privilege\('test',\s*'myschema.mytable', 'INSERT'\)}m, |
182 |
| - ) |
183 |
| - } |
| 183 | + it do |
| 184 | + is_expected.to contain_postgresql_psql('grant:test') |
| 185 | + .with_command(%r{GRANT ALL ON TABLE "myschema"."mytable" TO\s* "test"}m) |
| 186 | + .with_unless(%r{SELECT 1 WHERE has_table_privilege\('test',\s*'myschema.mytable', 'INSERT'\)}m) |
| 187 | + end |
| 188 | + end |
| 189 | + |
| 190 | + context 'with a role defined' do |
| 191 | + let :params do |
| 192 | + { |
| 193 | + db: 'test', |
| 194 | + role: 'test', |
| 195 | + privilege: 'all', |
| 196 | + object_name: %w[myschema mytable], |
| 197 | + object_type: 'table', |
| 198 | + } |
| 199 | + end |
| 200 | + |
| 201 | + let :pre_condition do |
| 202 | + <<-EOS |
| 203 | + class {'postgresql::server':} |
| 204 | + postgresql::server::role { 'test': } |
| 205 | + EOS |
| 206 | + end |
| 207 | + |
| 208 | + it { is_expected.to compile.with_all_deps } |
| 209 | + it { is_expected.to contain_postgresql__server__grant('test') } |
| 210 | + it { is_expected.to contain_postgresql__server__role('test') } |
| 211 | + it do |
| 212 | + is_expected.to contain_postgresql_psql('grant:test') \ |
| 213 | + .that_requires('Postgresql::Server::Role[test]') |
| 214 | + end |
184 | 215 | end
|
185 | 216 |
|
186 | 217 | context 'invalid object_type' do
|
|
0 commit comments