Skip to content

Commit e4ea0a8

Browse files
committed
(MODULES-7460) - Updating grant table to include INSERT privileges
1 parent c25e1c3 commit e4ea0a8

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

manifests/server/grant.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@
248248
/^ALL$/,
249249
/^ALL PRIVILEGES$/,
250250
/^DELETE$/,
251+
/^INSERT$/,
251252
/^REFERENCES$/,
252253
/^SELECT$/,
253254
/^TRIGGER$/,

spec/acceptance/server/grant_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,32 @@ class { 'postgresql::server': }
434434
end
435435
end
436436

437+
it 'grant insert on single table test' do
438+
begin
439+
# postgres version
440+
result = shell('psql --version')
441+
version = result.stdout.match(%r{\s(\d\.\d)})[1]
442+
443+
if version >= '9.0'
444+
pp = pp_create_table + <<-EOS.unindent
445+
postgresql::server::table_grant { 'INSERT priviledge to table':
446+
privilege => 'INSERT',
447+
table => 'test_tbl',
448+
db => $db,
449+
role => $user,
450+
}
451+
EOS
452+
result = apply_manifest(pp, catch_failures: true)
453+
expect(result.stdout).to match(%r{GRANT INSERT ON TABLE \"test_tbl\" TO \"psql_grant_priv_tester\"})
454+
455+
## Check that the privilege was granted to the user
456+
psql("-d #{db} --tuples-only --command=\"SELECT * FROM has_table_privilege('#{user}', 'test_tbl', 'INSERT')\"", user) do |r|
457+
expect(r.stdout).to match(%r{t})
458+
end
459+
end
460+
end
461+
end
462+
437463
it 'grant all on all tables to a user' do
438464
begin
439465
pp = pp_create_table + <<-EOS.unindent

0 commit comments

Comments
 (0)