File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 9090 ' ^ALL$' ,' ^ALL PRIVILEGES$' ])
9191 $unless_function = ' has_database_privilege'
9292 $on_db = $psql_db
93- $onlyif_function = undef
93+ $onlyif_function = $ensure ? {
94+ default => undef ,
95+ ' absent' => ' role_exists' ,
96+ }
9497 }
9598 ' SCHEMA' : {
9699 $unless_privilege = $_privilege ? {
339342 $_onlyif = $onlyif_function ? {
340343 ' table_exists' => " SELECT true FROM pg_tables WHERE tablename = '${_togrant_object}'" ,
341344 ' language_exists' => " SELECT true from pg_language WHERE lanname = '${_togrant_object}'" ,
345+ ' role_exists' => " SELECT 1 FROM pg_roles WHERE rolname = '${role} '" ,
342346 default => undef ,
343347 }
344348
Original file line number Diff line number Diff line change @@ -496,5 +496,26 @@ class { 'postgresql::server': }
496496 end
497497 end
498498 end
499+ context 'database' do
500+ describe 'REVOKE ... ON DATABASE...' do
501+ it 'should not fail on revoke connect from non-existant user' do
502+ begin
503+ apply_manifest ( pp_setup , :catch_failures => true )
504+ pp = pp_setup + <<-EOS . unindent
505+ postgresql::server::grant { 'revoke connect on db from norole':
506+ ensure => absent,
507+ privilege => 'CONNECT',
508+ object_type => 'DATABASE',
509+ db => '#{ db } ',
510+ role => '#{ user } _does_not_exist',
511+ }
512+ EOS
513+ apply_manifest ( pp , :catch_changes => true )
514+ apply_manifest ( pp , :catch_failures => true )
515+
516+ end
517+ end
518+ end
519+ end
499520 #####################
500521end
You can’t perform that action at this time.
0 commit comments