generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:ansible-collections/community.mysql…
… into mysql-user-query-refact
- Loading branch information
Showing
13 changed files
with
779 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bugfixes: | ||
- mysql_user - fixed creating user with encrypted password in MySQL 8.0 (https://github.com/ansible-collections/community.mysql/pull/79). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bugfixes: | ||
- mysql_user - add ``SHOW_ROUTINE`` privilege support (https://github.com/ansible-collections/community.mysql/issues/86). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
269 changes: 269 additions & 0 deletions
269
tests/integration/targets/test_mysql_user/tasks/test_user_password.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,269 @@ | ||
# Tests scenarios for both plaintext and encrypted user passwords. | ||
|
||
- vars: | ||
mysql_parameters: &mysql_params | ||
login_user: '{{ mysql_user }}' | ||
login_password: '{{ mysql_password }}' | ||
login_host: 127.0.0.1 | ||
login_port: '{{ mysql_primary_port }}' | ||
test_user_name: 'test_user_password' | ||
initial_password: 'a5C8SN*DBa0%a75sGz' | ||
initial_password_encrypted: '*0A12D4DF68C2A50716111674E565CA3D7D68B048' | ||
new_password: 'NkN&qECv33vuQzf3bJg' | ||
new_password_encrypted: '*B6559186FAD0953589F54383AD8EE9E9172296DA' | ||
test_default_priv_type: 'SELECT' | ||
test_default_priv: '*.*:{{ test_default_priv_type }}' | ||
|
||
block: | ||
|
||
# ============================================================ | ||
# Test setting plaintext password and changing it. | ||
# | ||
|
||
- name: Create user with initial password | ||
mysql_user: | ||
<<: *mysql_params | ||
name: '{{ test_user_name }}' | ||
password: '{{ initial_password }}' | ||
priv: '{{ test_default_priv }}' | ||
state: present | ||
register: result | ||
|
||
- name: Assert that a change occurred because the user was added | ||
assert: | ||
that: | ||
- "result.changed == true" | ||
|
||
- include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }} | ||
|
||
- name: Get the MySQL version using the newly created used creds | ||
mysql_info: | ||
login_user: '{{ test_user_name }}' | ||
login_password: '{{ initial_password }}' | ||
login_host: '{{ mysql_host }}' | ||
login_port: '{{ mysql_primary_port }}' | ||
filter: version | ||
register: result | ||
ignore_errors: true | ||
|
||
- name: Assert that mysql_info was successful | ||
assert: | ||
that: | ||
- "result.failed == false" | ||
|
||
- name: Run mysql_user again without any changes | ||
mysql_user: | ||
<<: *mysql_params | ||
name: '{{ test_user_name }}' | ||
password: '{{ initial_password }}' | ||
priv: '{{ test_default_priv }}' | ||
state: present | ||
register: result | ||
|
||
- name: Assert that there weren't any changes because username/password didn't change | ||
assert: | ||
that: | ||
- "result.changed == false" | ||
|
||
- include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }} | ||
|
||
- name: Update the user password | ||
mysql_user: | ||
<<: *mysql_params | ||
name: '{{ test_user_name }}' | ||
password: '{{ new_password }}' | ||
state: present | ||
register: result | ||
|
||
- name: Assert that a change occurred because the password was updated | ||
assert: | ||
that: | ||
- "result.changed == true" | ||
|
||
- include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }} | ||
|
||
- name: Get the MySQL version data using the original password (should fail) | ||
mysql_info: | ||
login_user: '{{ test_user_name }}' | ||
login_password: '{{ initial_password }}' | ||
login_host: '{{ mysql_host }}' | ||
login_port: '{{ mysql_primary_port }}' | ||
filter: version | ||
register: result | ||
ignore_errors: true | ||
|
||
- name: Assert that the mysql_info module failed because we used the old password | ||
assert: | ||
that: | ||
- "result.failed == true" | ||
|
||
- name: Get the MySQL version data using the new password (should work) | ||
mysql_info: | ||
login_user: '{{ test_user_name }}' | ||
login_password: '{{ new_password }}' | ||
login_host: '{{ mysql_host }}' | ||
login_port: '{{ mysql_primary_port }}' | ||
filter: version | ||
register: result | ||
ignore_errors: true | ||
|
||
- name: Assert that the mysql_info module succeeded because we used the new password | ||
assert: | ||
that: | ||
- "result.failed == false" | ||
|
||
# Cleanup | ||
- include: remove_user.yml user_name={{ test_user_name }} user_password={{ new_password }} | ||
|
||
# ============================================================ | ||
# Test setting a plaintext password and then the same password encrypted to ensure there isn't a change detected. | ||
# | ||
|
||
- name: Create user with initial password | ||
mysql_user: | ||
<<: *mysql_params | ||
name: '{{ test_user_name }}' | ||
password: '{{ initial_password }}' | ||
priv: '{{ test_default_priv }}' | ||
state: present | ||
register: result | ||
|
||
- name: Assert that a change occurred because the user was added | ||
assert: | ||
that: | ||
- "result.changed == true" | ||
|
||
- include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }} | ||
|
||
- name: Pass in the same password as before, but in the encrypted form (no change expected) | ||
mysql_user: | ||
<<: *mysql_params | ||
name: '{{ test_user_name }}' | ||
password: '{{ initial_password_encrypted }}' | ||
encrypted: yes | ||
priv: '{{ test_default_priv }}' | ||
state: present | ||
register: result | ||
|
||
- name: Assert that there weren't any changes because username/password didn't change | ||
assert: | ||
that: | ||
- "result.changed == false" | ||
|
||
# Cleanup | ||
- include: remove_user.yml user_name={{ test_user_name }} user_password={{ new_password }} | ||
|
||
# ============================================================ | ||
# Test setting an encrypted password and then the same password in plaintext to ensure there isn't a change. | ||
# | ||
|
||
- name: Create user with initial password | ||
mysql_user: | ||
<<: *mysql_params | ||
name: '{{ test_user_name }}' | ||
password: '{{ initial_password_encrypted }}' | ||
encrypted: yes | ||
priv: '{{ test_default_priv }}' | ||
state: present | ||
register: result | ||
|
||
- name: Assert that a change occurred because the user was added | ||
assert: | ||
that: | ||
- "result.changed == true" | ||
|
||
- include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }} | ||
|
||
- name: Get the MySQL version data using the new creds | ||
mysql_info: | ||
login_user: '{{ test_user_name }}' | ||
login_password: '{{ initial_password }}' | ||
login_host: '{{ mysql_host }}' | ||
login_port: '{{ mysql_primary_port }}' | ||
filter: version | ||
register: result | ||
ignore_errors: true | ||
|
||
- name: Assert that the mysql_info module succeeded because we used the new password | ||
assert: | ||
that: | ||
- "result.failed == false" | ||
|
||
- name: Pass in the same password as before, but in the encrypted form (no change expected) | ||
mysql_user: | ||
<<: *mysql_params | ||
name: '{{ test_user_name }}' | ||
password: '{{ initial_password }}' | ||
state: present | ||
register: result | ||
|
||
- name: Assert that there weren't any changes because username/password didn't change | ||
assert: | ||
that: | ||
- "result.changed == false" | ||
|
||
# Cleanup | ||
- include: remove_user.yml user_name={{ test_user_name }} user_password={{ new_password }} | ||
|
||
# ============================================================ | ||
# Test setting an empty password. | ||
# | ||
|
||
- name: Create user with empty password | ||
mysql_user: | ||
<<: *mysql_params | ||
name: '{{ test_user_name }}' | ||
priv: '{{ test_default_priv }}' | ||
state: present | ||
register: result | ||
|
||
- name: Assert that a change occurred because the user was added | ||
assert: | ||
that: | ||
- "result.changed == true" | ||
|
||
- name: Get the MySQL version using an empty password for the newly created user | ||
mysql_info: | ||
login_user: '{{ test_user_name }}' | ||
login_password: '' | ||
login_host: '{{ mysql_host }}' | ||
login_port: '{{ mysql_primary_port }}' | ||
filter: version | ||
register: result | ||
ignore_errors: true | ||
|
||
- name: Assert that mysql_info was successful | ||
assert: | ||
that: | ||
- "result.failed == false" | ||
|
||
- name: Get the MySQL version using an non-empty password (should fail) | ||
mysql_info: | ||
login_user: '{{ test_user_name }}' | ||
login_password: 'some_password' | ||
login_host: '{{ mysql_host }}' | ||
login_port: '{{ mysql_primary_port }}' | ||
filter: version | ||
register: result | ||
ignore_errors: true | ||
|
||
- name: Assert that mysql_info failed | ||
assert: | ||
that: | ||
- "result.failed == true" | ||
|
||
- name: Update the user without changing the password | ||
mysql_user: | ||
<<: *mysql_params | ||
name: '{{ test_user_name }}' | ||
priv: '{{ test_default_priv }}' | ||
state: present | ||
register: result | ||
|
||
- name: Assert that the user wasn't changed because the password is still empty | ||
assert: | ||
that: | ||
- "result.changed == false" | ||
|
||
# Cleanup | ||
- include: remove_user.yml user_name={{ test_user_name }} user_password='' |
Oops, something went wrong.