mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* modules: fix names with hyphens (#656) * modules: fix names with hyphens (#656) * Fix param name for postgresql_schema * Add double quotes for schema name * Add delete created DB objects * Fix module code * Set correct test tasks order Co-authored-by: Maxim Voskresenskiy <maxim.voskresenskiy@uptick.com>
This commit is contained in:
parent
4c4a6ab27c
commit
a0c8a3034a
4 changed files with 128 additions and 0 deletions
3
changelogs/fragments/656-name-with-hyphen.yml
Normal file
3
changelogs/fragments/656-name-with-hyphen.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
bugfixes:
|
||||
- postgresql_privs - fix crash when set privileges on schema with hyphen in the name (https://github.com/ansible-collections/community.general/issues/656).
|
|
@ -766,6 +766,9 @@ class Connection(object):
|
|||
if target_roles:
|
||||
as_who = ','.join('"%s"' % r for r in target_roles)
|
||||
|
||||
if schema_qualifier:
|
||||
schema_qualifier = '"%s"' % schema_qualifier
|
||||
|
||||
status_before = get_status(objs)
|
||||
|
||||
query = QueryBuilder(state) \
|
||||
|
|
|
@ -4,6 +4,9 @@ db_user2: ansible_db_user2
|
|||
db_user3: ansible_db_user3
|
||||
db_user_with_dots1: role.with.dots1
|
||||
db_user_with_dots2: role.with.dots2
|
||||
db_name_with_hyphens: ansible-db
|
||||
db_user_with_hyphens: ansible-db-user
|
||||
db_schema_with_hyphens: ansible-db-schema
|
||||
db_session_role1: session_role1
|
||||
db_session_role2: session_role2
|
||||
dangerous_name: 'curious.anonymous"; SELECT * FROM information_schema.tables; --'
|
||||
|
|
|
@ -27,6 +27,125 @@
|
|||
db: "{{ db_name }}"
|
||||
login_user: "{{ pg_user }}"
|
||||
|
||||
#############################
|
||||
# Test of solving bug 656 #
|
||||
#############################
|
||||
- name: Create DB with hyphen in the name
|
||||
become_user: "{{ pg_user }}"
|
||||
become: yes
|
||||
postgresql_db:
|
||||
state: present
|
||||
name: "{{ db_name_with_hyphens }}"
|
||||
login_user: "{{ pg_user }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Create a user with hyphen in the name
|
||||
postgresql_user:
|
||||
name: "{{ db_user_with_hyphens }}"
|
||||
state: present
|
||||
encrypted: yes
|
||||
password: password
|
||||
role_attr_flags: CREATEDB,LOGIN
|
||||
db: "{{ db_name_with_hyphens }}"
|
||||
login_user: "{{ pg_user }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Create schema with hyphen in the name
|
||||
postgresql_schema:
|
||||
login_user: "{{ pg_user }}"
|
||||
login_password: password
|
||||
db: "{{ db_name_with_hyphens }}"
|
||||
name: "{{ db_schema_with_hyphens }}"
|
||||
state: present
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Set table default privs on the schema with hyphen in the name
|
||||
postgresql_privs:
|
||||
login_user: "{{ pg_user }}"
|
||||
password: password
|
||||
db: "{{ db_name_with_hyphens }}"
|
||||
schema: "{{ db_schema_with_hyphens }}"
|
||||
role: "{{ db_user_with_hyphens }}"
|
||||
type: default_privs
|
||||
obj: TABLES
|
||||
privs: all
|
||||
state: present
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Delete table default privs on the schema with hyphen in the name
|
||||
postgresql_privs:
|
||||
login_user: "{{ pg_user }}"
|
||||
password: password
|
||||
db: "{{ db_name_with_hyphens }}"
|
||||
schema: "{{ db_schema_with_hyphens }}"
|
||||
role: "{{ db_user_with_hyphens }}"
|
||||
type: default_privs
|
||||
obj: TABLES
|
||||
privs: all
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Delete schema with hyphen in the name
|
||||
postgresql_schema:
|
||||
login_user: "{{ pg_user }}"
|
||||
login_password: password
|
||||
db: "{{ db_name_with_hyphens }}"
|
||||
name: "{{ db_schema_with_hyphens }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Delete a user with hyphen in the name
|
||||
postgresql_user:
|
||||
name: "{{ db_user_with_hyphens }}"
|
||||
state: absent
|
||||
encrypted: yes
|
||||
password: password
|
||||
role_attr_flags: CREATEDB,LOGIN
|
||||
db: "{{ db_name_with_hyphens }}"
|
||||
login_user: "{{ pg_user }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Delete DB with hyphen in the name
|
||||
become_user: "{{ pg_user }}"
|
||||
become: yes
|
||||
postgresql_db:
|
||||
state: absent
|
||||
name: "{{ db_name_with_hyphens }}"
|
||||
login_user: "{{ pg_user }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
#############################
|
||||
# Test of solving bug 27327 #
|
||||
#############################
|
||||
|
|
Loading…
Reference in a new issue