Skip to content

Commit 70b915a

Browse files
authored
postgresql_privs: raise an error when ALL_IN_SCHEMA is used with a value of the type parameter not in table, sequence, function or procedure (#380)
* postgresql_privs: raise an error when ALL_IN_SCHEMA is used with a value of the type parameter not in table, sequence, function or procedure * Add fragment
1 parent f621dd4 commit 70b915a

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- "postgresql_privs - raise an error when the ``objs: ALL_IN_SCHEMA`` is used with a value of ``type`` that is not ``table``, ``sequence``, ``function`` or ``procedure`` (https://github.com/ansible-collections/community.postgresql/issues/379)."

plugins/modules/postgresql_privs.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,13 @@ def main():
11011101
module.fail_json(msg='Argument "schema" is not allowed '
11021102
'for type "%s".' % p.type)
11031103

1104+
# param "objs": ALL_IN_SCHEMA can be used only
1105+
# when param "type" is table, sequence, function or procedure
1106+
if p.objs == 'ALL_IN_SCHEMA' and p.type not in ('table', 'sequence', 'function', 'procedure'):
1107+
module.fail_json(msg='Argument "objs": ALL_IN_SCHEMA can be used only for '
1108+
'type: table, sequence, function or procedure, '
1109+
'%s was passed.' % p.type)
1110+
11041111
# param "objs": default, required depends on param "type"
11051112
if p.type == 'database':
11061113
p.objs = p.objs or p.database

tests/integration/targets/postgresql_privs/tasks/postgresql_privs_general.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,25 @@
15601560
that:
15611561
- result is changed
15621562

1563+
- name: Test community.postgresql issue 379
1564+
become: yes
1565+
become_user: "{{ pg_user }}"
1566+
postgresql_privs:
1567+
login_user: "{{ pg_user }}"
1568+
login_db: "{{ db_name }}"
1569+
roles: "{{ db_user3 }}"
1570+
objs: ALL_IN_SCHEMA
1571+
type: default_privs
1572+
privs: SELECT,INSERT,UPDATE,DELETE,EXECUTE
1573+
schema: public
1574+
register: result
1575+
ignore_errors: yes
1576+
1577+
- assert:
1578+
that:
1579+
- result is failed
1580+
- result.msg is search('ALL_IN_SCHEMA can be used only for type')
1581+
15631582
# Cleanup
15641583
- name: Remove privs
15651584
become: true

0 commit comments

Comments
 (0)