Display a more informative error when InvalidPrivsError is raised (#465) - fix and add integration test

This commit is contained in:
bizmate 2022-11-29 17:43:01 +04:00
commit 222eb60371
6 changed files with 30 additions and 15 deletions

View file

@ -4,3 +4,5 @@
src: installed_file.j2 src: installed_file.j2
dest: "{{ dbdeployer_installed_file }}" dest: "{{ dbdeployer_installed_file }}"
listen: create zookeeper installed file listen: create zookeeper installed file
tags:
- setup_mysql

View file

@ -5,7 +5,17 @@
#################################################################### ####################################################################
- import_tasks: setvars.yml - import_tasks: setvars.yml
tags:
- setup_mysql
- import_tasks: dir.yml - import_tasks: dir.yml
tags:
- setup_mysql
- import_tasks: install.yml - import_tasks: install.yml
tags:
- setup_mysql
- import_tasks: config.yml - import_tasks: config.yml
tags:
- setup_mysql
- import_tasks: verify.yml - import_tasks: verify.yml
tags:
- setup_mysql

View file

@ -1,5 +1,9 @@
- name: delete temporary directory - name: delete temporary directory
include_tasks: default-cleanup.yml include_tasks: default-cleanup.yml
tags:
- setup_remote_tmp_dir
- name: delete temporary directory (windows) - name: delete temporary directory (windows)
include_tasks: windows-cleanup.yml include_tasks: windows-cleanup.yml
tags:
- setup_remote_tmp_dir

View file

@ -7,9 +7,13 @@
setup: setup:
gather_subset: distribution gather_subset: distribution
when: ansible_facts == {} when: ansible_facts == {}
tags:
- setup_remote_tmp_dir
- include_tasks: "{{ lookup('first_found', files)}}" - include_tasks: "{{ lookup('first_found', files)}}"
vars: vars:
files: files:
- "{{ ansible_os_family | lower }}.yml" - "{{ ansible_os_family | lower }}.yml"
- "default.yml" - "default.yml"
tags:
- setup_remote_tmp_dir

View file

@ -281,6 +281,10 @@
- include: test_priv_subtract.yml enable_check_mode=no - include: test_priv_subtract.yml enable_check_mode=no
- include: test_priv_subtract.yml enable_check_mode=yes - include: test_priv_subtract.yml enable_check_mode=yes
- include: test_privs_issue_465.yml
tags:
- issue_465
# Tests for the TLS requires dictionary # Tests for the TLS requires dictionary
- include: tls_requirements.yml - include: tls_requirements.yml

View file

@ -26,28 +26,19 @@
block: block:
# ============================================================ # ============================================================
- name: create admin user with ALL privs, without GRANT OPTIONS - name: create a user with parameters that will always cause an exception
mysql_user:
<<: *mysql_params
name: '{{ user_name_1 }}'
password: '{{ user_password_1 }}'
priv: '*.{{ db_name }}:ALL'
state: present
- include: assert_user.yml user_name={{user_name_2}} priv='ALL'
- name: create consumer user with all privileges using admin user
mysql_user: mysql_user:
<<: *mysql_params <<: *mysql_params
name: '{{ user_name_2 }}' name: '{{ user_name_2 }}'
password: '{{ user_password_2 }}' password: '{{ user_password_2 }}'
login_user: '{{ user_name_1 }}' priv: '*.{{ db_name }}:SELECT'
login_password: '{{ user_password_1 }}'
priv: '*.{{ db_name }}:ALL'
state: present state: present
ignore_errors: yes
register: result register: result
- name: assert output message for current privileges - name: assert output message for current privileges
assert: assert:
that: that:
- result is changed - result is failed
- result.msg.find('exception') != -1
fail_msg: "Error granting privileges, invalid priv string: SELECT , query: GRANT SELECT ON *.`data` TO %s@%s , exception: (1064, \"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`data` TO 'db_user2'@'localhost'' at line 1\")."