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 90
90
' ^ALL$' ,' ^ALL PRIVILEGES$' ])
91
91
$unless_function = ' has_database_privilege'
92
92
$on_db = $psql_db
93
- $onlyif_function = undef
93
+ $onlyif_function = $ensure ? {
94
+ default => undef ,
95
+ ' absent' => ' role_exists' ,
96
+ }
94
97
}
95
98
' SCHEMA' : {
96
99
$unless_privilege = $_privilege ? {
339
342
$_onlyif = $onlyif_function ? {
340
343
' table_exists' => " SELECT true FROM pg_tables WHERE tablename = '${_togrant_object}'" ,
341
344
' language_exists' => " SELECT true from pg_language WHERE lanname = '${_togrant_object}'" ,
345
+ ' role_exists' => " SELECT 1 FROM pg_roles WHERE rolname = '${role} '" ,
342
346
default => undef ,
343
347
}
344
348
Original file line number Diff line number Diff line change @@ -496,5 +496,26 @@ class { 'postgresql::server': }
496
496
end
497
497
end
498
498
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
499
520
#####################
500
521
end
You can’t perform that action at this time.
0 commit comments