mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-07-22 04:40:23 -07:00
Get rid of privs comparison (#243)
* Remove all code related to VALID_PRIVS and get_valid_privs() * Add tests to update user with invalid privs * Re-raise InvalidPrivsError when granting privileges * Fix: compatibility with python2 * More explicit assertions as commented by Andersson007 * Add changelog fragment
This commit is contained in:
parent
e4de13aabe
commit
727b638d13
6 changed files with 45 additions and 66 deletions
|
@ -96,6 +96,25 @@
|
|||
- "'GRANT SELECT, DELETE ON `data2`.*' in result.stdout"
|
||||
when: enable_check_mode == 'yes'
|
||||
|
||||
- name: Try to append invalid privileges
|
||||
mysql_user:
|
||||
<<: *mysql_params
|
||||
name: '{{ user_name_4 }}'
|
||||
password: '{{ user_password_4 }}'
|
||||
priv: 'data1.*:INVALID/data2.*:SELECT'
|
||||
append_privs: yes
|
||||
state: present
|
||||
check_mode: '{{ enable_check_mode }}'
|
||||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- name: Assert that there wasn't a change in privileges if check_mode is set to 'no'
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- "'Error granting privileges' in result.msg"
|
||||
when: enable_check_mode == 'no'
|
||||
|
||||
##########
|
||||
# Clean up
|
||||
- name: Drop test databases
|
||||
|
|
|
@ -178,6 +178,23 @@
|
|||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
# ============================================================
|
||||
- name: update user with invalid privileges
|
||||
mysql_user:
|
||||
<<: *mysql_params
|
||||
name: '{{ user_name_2 }}'
|
||||
password: '{{ user_password_2 }}'
|
||||
priv: '*.*:INVALID'
|
||||
state: present
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Assert that priv did not change
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- "'Error granting privileges' in result.msg"
|
||||
|
||||
- name: remove username
|
||||
mysql_user:
|
||||
<<: *mysql_params
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue