Fix mysql_user on_new_username IndexError (#642)

* fix tuple indexerror when no accounts are found

* Fix tests for update_password not executed

* Add test for case where existing user have different password

* lint to prevent warning about jinja templating in when clause

* Refactor get_existing_authentication to return a list of all row found

Previously we were returning only the first row found. We need to be
able to see if there is a difference in the existing passwords.

* Refactor host option to be optional

This make it possible to use the same method from mysql_user to help
update_password retrieve existing password for all account with the same
username independently of their hostname. And from mysql_info to get
the password of a specif user using WHERE user = '' AND host = ''

* Add change log fragment

* Add link to the PR in the change log

* lint for ansible devel

* Fix templating type error could not cconvert to bool with ansible devel

* Revert changes made for ansible-devel that broke tests for Ansible 2.15

* Revert changes made for ansible-devel that broke tests

* Cut unnecessary set, uniqueness is ensured by the group_by in the query

* Cut auth plugin from returned values when multiple existing auths exists

Discussed here:
https://github.com/ansible-collections/community.mysql/pull/642/files#r1649720519

* fix convertion of list(dict) to list(tuple)

* Fix test for empty password on MySQL 8+
This commit is contained in:
Laurent Indermühle 2024-06-27 22:12:01 +02:00 committed by GitHub
commit 33e8754c4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 141 additions and 74 deletions

View file

@ -47,8 +47,8 @@
# Verify mysql_variable successfully updates a variable (issue:4568)
#
- set_fact:
set_name: 'delay_key_write'
set_value: 'ON'
set_name: 'delay_key_write'
set_value: 'ON'
- name: set mysql variable
mysql_variables:
@ -74,8 +74,8 @@
# Verify mysql_variable successfully updates a variable using single quotes
#
- set_fact:
set_name: 'wait_timeout'
set_value: '300'
set_name: 'wait_timeout'
set_value: '300'
- name: set mysql variable to a temp value
mysql_variables:
@ -105,8 +105,8 @@
# Verify mysql_variable successfully updates a variable using double quotes
#
- set_fact:
set_name: "wait_timeout"
set_value: "400"
set_name: "wait_timeout"
set_value: "400"
- name: set mysql variable to a temp value
mysql_variables:
@ -132,8 +132,8 @@
# Verify mysql_variable successfully updates a variable using no quotes
#
- set_fact:
set_name: wait_timeout
set_value: 500
set_name: wait_timeout
set_value: 500
- name: set mysql variable to a temp value
mysql_variables:
@ -251,8 +251,8 @@
# Verify mysql_variable works with the login_user and login_password parameters
#
- set_fact:
set_name: wait_timeout
set_value: 77
set_name: wait_timeout
set_value: 77
- name: query mysql_variable using login_user and password_password
mysql_variables:
@ -291,8 +291,8 @@
# Verify mysql_variable fails with an incorrect login_password parameter
#
- set_fact:
set_name: connect_timeout
set_value: 10
set_name: connect_timeout
set_value: 10
- name: query mysql_variable using incorrect login_password
mysql_variables: