Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(maint) Fix to grant_spec.rb regarding database test on earlier machines #966

Merged
merged 1 commit into from
Mar 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ Manages grant-based access privileges for users, wrapping the `postgresql::serve

##### `ensure`

Specifies whether to grant or revoke the privilege. Default is to grant the privilege.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may require more information that stating it will create problems. Jean will give you some help writing this section or ensure to get it reviewed by Jean.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great update. We will get it reviewed by Jean to ensure its ok. I would add that revoke works on tables, the limit is only on revoke permissions on the database or something along them lines.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change this to:

Specifies whether to grant or revoke the privilege. The value 'present' grants the privilege, and 'absent' revokes the privilege. Revoke or 'absent' works only in PostgreSQL version 9.1.24 or later.

Specifies whether to grant or revoke the privilege. Revoke or 'absent' works only in PostgreSQL version 9.1.24 or later.

Valid values: 'present', 'absent'.
* 'present' to grant the privilege
Expand Down
31 changes: 19 additions & 12 deletions spec/acceptance/server/grant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -500,18 +500,25 @@ class { 'postgresql::server': }
describe 'REVOKE ... ON DATABASE...' do
it 'do not fail on revoke connect from non-existant user' do
begin
apply_manifest(pp_setup, catch_failures: true)
pp = pp_setup + <<-EOS.unindent
postgresql::server::grant { 'revoke connect on db from norole':
ensure => absent,
privilege => 'CONNECT',
object_type => 'DATABASE',
db => '#{db}',
role => '#{user}_does_not_exist',
}
EOS
apply_manifest(pp, catch_changes: true)
apply_manifest(pp, catch_failures: true)
# Test fail's on postgresql versions earlier than 9.1.24
# postgres version
result = shell('psql --version')
version = result.stdout.match(%r{\s(\d\.\d)})[1]

if version >= '9.1.24'
apply_manifest(pp_setup, catch_failures: true)
pp = pp_setup + <<-EOS.unindent
postgresql::server::grant { 'revoke connect on db from norole':
ensure => absent,
privilege => 'CONNECT',
object_type => 'DATABASE',
db => '#{db}',
role => '#{user}_does_not_exist',
}
EOS
apply_manifest(pp, catch_changes: true)
apply_manifest(pp, catch_failures: true)
end
end
end
end
Expand Down