Skip to content

Commit babe5e4

Browse files
authored
Merge pull request puppetlabs#966 from david22swan/ensure_fix
(maint) Fix to grant_spec.rb regarding database test on earlier machines
2 parents dcd7eb8 + fdbd89a commit babe5e4

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ Manages grant-based access privileges for users, wrapping the `postgresql::serve
11541154

11551155
##### `ensure`
11561156

1157-
Specifies whether to grant or revoke the privilege. Default is to grant the privilege.
1157+
Specifies whether to grant or revoke the privilege. Revoke or 'absent' works only in PostgreSQL version 9.1.24 or later.
11581158

11591159
Valid values: 'present', 'absent'.
11601160
* 'present' to grant the privilege

spec/acceptance/server/grant_spec.rb

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -500,18 +500,25 @@ class { 'postgresql::server': }
500500
describe 'REVOKE ... ON DATABASE...' do
501501
it 'do not fail on revoke connect from non-existant user' do
502502
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)
503+
# Test fail's on postgresql versions earlier than 9.1.24
504+
# postgres version
505+
result = shell('psql --version')
506+
version = result.stdout.match(%r{\s(\d\.\d)})[1]
507+
508+
if version >= '9.1.24'
509+
apply_manifest(pp_setup, catch_failures: true)
510+
pp = pp_setup + <<-EOS.unindent
511+
postgresql::server::grant { 'revoke connect on db from norole':
512+
ensure => absent,
513+
privilege => 'CONNECT',
514+
object_type => 'DATABASE',
515+
db => '#{db}',
516+
role => '#{user}_does_not_exist',
517+
}
518+
EOS
519+
apply_manifest(pp, catch_changes: true)
520+
apply_manifest(pp, catch_failures: true)
521+
end
515522
end
516523
end
517524
end

0 commit comments

Comments
 (0)