|
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 { is_expected.to contain_postgresql_psql('grant:test').with( |
51 |
| - { |
52 |
| - 'command' => /GRANT USAGE ON SEQUENCE "test" TO\s* "test"/m, |
53 |
| - 'unless' => /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(/GRANT USAGE ON SEQUENCE "test" TO\s* "test"/m). \ |
| 55 | + with_unless(/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 { is_expected.to contain_postgresql_psql('grant:test').with( |
74 |
| - { |
75 |
| - 'command' => /GRANT USAGE ON SEQUENCE "test" TO\s* "test"/m, |
76 |
| - 'unless' => /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(/GRANT USAGE ON SEQUENCE "test" TO\s* "test"/m). \ |
| 78 | + with_unless(/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 { is_expected.to contain_postgresql_psql('grant:test').with( |
98 |
| - { |
99 |
| - 'command' => /GRANT USAGE ON ALL SEQUENCES IN SCHEMA "public" TO\s* "test"/m, |
100 |
| - 'unless' => /SELECT 1 FROM \(\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*\) P\s* HAVING count\(P\.sequence_name\) = 0/m, |
101 |
| - } |
102 |
| - ) } |
| 99 | + it do |
| 100 | + is_expected.to contain_postgresql_psql('grant:test'). \ |
| 101 | + with_command(/GRANT USAGE ON ALL SEQUENCES IN SCHEMA "public" TO\s* "test"/m). \ |
| 102 | + with_unless(/SELECT 1 FROM \(\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*\) P\s* HAVING count\(P\.sequence_name\) = 0/m) |
| 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 |
| - it { is_expected.to contain_postgresql_psql("grant:test").with_connect_settings( { 'PGHOST' => 'postgres-db-server','DBVERSION' => '9.1' } ).with_port( 5432 ) } |
| 122 | + it do |
| 123 | + is_expected.to contain_postgresql_psql("grant:test"). \ |
| 124 | + with_connect_settings( { 'PGHOST' => 'postgres-db-server', 'DBVERSION' => '9.1' } ). \ |
| 125 | + with_port(5432) |
| 126 | + end |
121 | 127 | end
|
122 | 128 |
|
123 | 129 | context "with specific db connection settings - including port" do
|
|
135 | 141 | "class {'postgresql::server':}"
|
136 | 142 | end
|
137 | 143 |
|
| 144 | + it { is_expected.to compile.with_all_deps } |
138 | 145 | it { is_expected.to contain_postgresql__server__grant('test') }
|
139 |
| - it { is_expected.to contain_postgresql_psql("grant:test").with_connect_settings( { 'PGHOST' => 'postgres-db-server','DBVERSION' => '9.1','PGPORT' => '1234' } ) } |
| 146 | + it { is_expected.to contain_postgresql_psql("grant:test").with_connect_settings( { 'PGHOST' => 'postgres-db-server', 'DBVERSION' => '9.1', 'PGPORT' => '1234' } ) } |
140 | 147 | end
|
141 | 148 |
|
142 | 149 | context "with specific db connection settings - port overriden by explicit parameter" do
|
|
155 | 162 | "class {'postgresql::server':}"
|
156 | 163 | end
|
157 | 164 |
|
| 165 | + it { is_expected.to compile.with_all_deps } |
158 | 166 | it { is_expected.to contain_postgresql__server__grant('test') }
|
159 |
| - it { is_expected.to contain_postgresql_psql("grant:test").with_connect_settings( { 'PGHOST' => 'postgres-db-server','DBVERSION' => '9.1','PGPORT' => '1234' } ).with_port( '5678' ) } |
| 167 | + it do |
| 168 | + is_expected.to contain_postgresql_psql("grant:test"). \ |
| 169 | + with_connect_settings( { 'PGHOST' => 'postgres-db-server', 'DBVERSION' => '9.1', 'PGPORT' => '1234' } ). \ |
| 170 | + with_port( '5678' ) |
| 171 | + end |
160 | 172 | end
|
161 | 173 |
|
162 | 174 | context 'with specific schema name' do
|
|
174 | 186 | "class {'postgresql::server':}"
|
175 | 187 | end
|
176 | 188 |
|
| 189 | + it { is_expected.to compile.with_all_deps } |
177 | 190 | it { is_expected.to contain_postgresql__server__grant('test') }
|
178 |
| - it { is_expected.to contain_postgresql_psql('grant:test').with( |
179 |
| - { |
180 |
| - 'command' => /GRANT ALL ON TABLE "myschema"."mytable" TO\s* "test"/m, |
181 |
| - 'unless' => /SELECT 1 WHERE has_table_privilege\('test',\s*'myschema.mytable', 'INSERT'\)/m, |
182 |
| - } |
183 |
| - ) } |
| 191 | + it do |
| 192 | + is_expected.to contain_postgresql_psql('grant:test'). \ |
| 193 | + with_command(/GRANT ALL ON TABLE "myschema"."mytable" TO\s* "test"/m). \ |
| 194 | + with_unless(/SELECT 1 WHERE has_table_privilege\('test',\s*'myschema.mytable', 'INSERT'\)/m) |
| 195 | + end |
184 | 196 | end
|
185 | 197 |
|
186 | 198 | context 'invalid object_type' do
|
|
0 commit comments