Skip to content

Support granting SELECT and UPDATE permission on sequences (MODULES-4158) #823

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

Merged
merged 5 commits into from
Dec 8, 2016

Conversation

chris-reeves
Copy link
Contributor

Add support for granting SELECT and UPDATE permissions on sequences (MODULES-4158).

This requires a significant change to the unless statement used to determine whether the permission has already been granted. The previous statement used the standard SQL information_schema tables, however these provide limited information on sequence permissions. In order to retrieve the current permission set with the necessary level of detail we must query the pg_class system catalog and parse out the permissions from there.

As part of this PR, I've added additional acceptance tests to verify both old and new functionality. All tests pass on my local system (using supplied Gemfile).

Make the spec tests for postgresql::server::grant on sequences less sensitive
to whitespace in the SQL.
Add additional acceptance tests for granting UPDATE permissions on sequences.
(MODULES-4158)
Add support for granting SELECT and UPDATE permissions on sequences
(MODULES-4158).

This requires a significant change to the unless statement used to
determine whether the permission has already been granted. The previous
statement used the standard SQL information_schema tables, however these
provide limited information on sequence permissions. In order to retrieve
the current permission set with the necessary level of detail we must query
the pg_class system catalog and parse out the permisions from there.
Remove unnecessary backslash escape in SQL regex for sequence grant unless
query (it was causing ruby validation to fail).
user = 'psql_grant_priv_tester'
password = 'psql_grant_role_pw'

pp_setup = <<-EOS.unindent
Copy link
Contributor

Choose a reason for hiding this comment

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

Variables should not be declared outside of tests. If it is needed by multiple tests then a let() should be used. Yes, our code does the same thing for db/owner/user/password and it's wrong and needs fixing :)

Copy link
Contributor

Choose a reason for hiding this comment

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

This probably doesn't matter much.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was done for consistency with other spec tests (as you spotted).

Happy to change to something more sane if you want though - just let me know.

@hunner
Copy link
Contributor

hunner commented Dec 1, 2016

This looks great! Could you add the additional values to https://github.com/puppetlabs/puppetlabs-postgresql#privilege-1 as well?

@chris-reeves
Copy link
Contributor Author

As for the docs, those additional values fall under "object_type dependent string". Unless we break out the privileges available for each object type.

@hunner hunner merged commit fa2a4a0 into puppetlabs:master Dec 8, 2016
cegeka-jenkins pushed a commit to cegeka/puppet-postgresql that referenced this pull request Feb 3, 2022
…ce-perms

Support granting SELECT and UPDATE permission on sequences (MODULES-4158)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants