generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add integrations tests for column case sensitive name * add a warning when column_case_sensitive in not set * add announce default will change in in 4.0.0 * fix tests for engine that don't wrap column in backticks * add filter because only MySQL 5.7 is case sensitive for users privs * add kmarse and myself to the authors * add kmarse to the contributors list --------- Co-authored-by: Laurent Indermühle <[email protected]> Co-authored-by: Andrew Klychkov <[email protected]>
- Loading branch information
1 parent
8c2b6b0
commit 033b4c7
Showing
10 changed files
with
389 additions
and
8 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 |
---|---|---|
|
@@ -141,6 +141,7 @@ kalaisubbiah | |
kenichi-ogawa-1988 | ||
kkeane | ||
klingac | ||
kmarse | ||
koleo | ||
kotso | ||
kuntalFreshBooks | ||
|
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,21 @@ | ||
--- | ||
minor_changes: | ||
|
||
- mysql_user - add ``column_case_sensitive`` option to prevent field names | ||
from being uppercased | ||
(https://github.com/ansible-collections/community.mysql/pull/569). | ||
- mysql_role - add ``column_case_sensitive`` option to prevent field names | ||
from being uppercased | ||
(https://github.com/ansible-collections/community.mysql/pull/569). | ||
|
||
major_changes: | ||
- mysql_user - the ``column_case_sensitive`` argument's default value will be | ||
changed to ``true`` in community.mysql 4.0.0. If your playbook expected the | ||
column to be automatically uppercased for your users privileges, you should | ||
set this to false explicitly | ||
(https://github.com/ansible-collections/community.mysql/issues/577). | ||
- mysql_role - the ``column_case_sensitive`` argument's default value will be | ||
changed to ``true`` in community.mysql 4.0.0. If your playbook expected the | ||
column to be automatically uppercased for your roles privileges, you should | ||
set this to false explicitly | ||
(https://github.com/ansible-collections/community.mysql/issues/578). |
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
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
149 changes: 149 additions & 0 deletions
149
tests/integration/targets/test_mysql_role/tasks/test_column_case_sensitive.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,149 @@ | ||
--- | ||
|
||
- vars: | ||
mysql_parameters: &mysql_params | ||
login_user: '{{ mysql_user }}' | ||
login_password: '{{ mysql_password }}' | ||
login_host: '{{ mysql_host }}' | ||
login_port: '{{ mysql_primary_port }}' | ||
|
||
block: | ||
|
||
# ========================= Prepare ======================================= | ||
# We use query to prevent our module of changing the case | ||
- name: Mysql_role Column case sensitive | Create a test table | ||
community.mysql.mysql_query: | ||
<<: *mysql_params | ||
query: | ||
- CREATE DATABASE mysql_role_column_case | ||
- >- | ||
CREATE TABLE mysql_role_column_case.t1 | ||
(a int, B int, cC int, Dd int) | ||
- >- | ||
INSERT INTO mysql_role_column_case.t1 | ||
(a, B, cC, Dd) VALUES (1,2,3,4) | ||
- name: Mysql_role Column case sensitive | Create users | ||
community.mysql.mysql_user: | ||
<<: *mysql_params | ||
name: column_case_sensitive | ||
host: '%' | ||
password: 'msandbox' | ||
|
||
# ================= Reproduce failure ===================================== | ||
|
||
- name: Mysql_role Column case sensitive | Create role | ||
community.mysql.mysql_role: | ||
<<: *mysql_params | ||
name: 'role_column_case_sensitive' | ||
state: present | ||
members: | ||
- 'column_case_sensitive@%' | ||
priv: | ||
'mysql_role_column_case.t1': 'SELECT(a, B, cC, Dd)' | ||
|
||
- name: Mysql_role Column case sensitive | Assert role privileges are all caps | ||
community.mysql.mysql_query: | ||
<<: *mysql_params | ||
query: | ||
- SHOW GRANTS FOR role_column_case_sensitive | ||
register: column_case_insensitive_grants | ||
failed_when: | ||
# Column order may vary, thus test each separately | ||
- >- | ||
column_case_insensitive_grants.query_result[0][1] | ||
is not search("A", ignorecase=false) | ||
or column_case_insensitive_grants.query_result[0][1] | ||
is not search("B", ignorecase=false) | ||
or column_case_insensitive_grants.query_result[0][1] | ||
is not search("CC", ignorecase=false) | ||
or column_case_insensitive_grants.query_result[0][1] | ||
is not search("DD", ignorecase=false) | ||
- name: Mysql_role Column case sensitive | Assert 1 column is accessible on MySQL | ||
community.mysql.mysql_query: | ||
<<: *mysql_params | ||
login_user: column_case_sensitive | ||
query: | ||
- DESC mysql_role_column_case.t1 | ||
register: assert_1_col_accessible | ||
failed_when: | ||
- assert_1_col_accessible.rowcount[0] | int != 1 | ||
when: | ||
- db_engine == 'mysql' | ||
|
||
- name: Mysql_role Column case sensitive | Assert 4 column are accessible on MariaDB | ||
community.mysql.mysql_query: | ||
<<: *mysql_params | ||
login_user: column_case_sensitive | ||
query: | ||
- SET ROLE role_column_case_sensitive | ||
- DESC mysql_role_column_case.t1 | ||
register: assert_4_col_accessible | ||
failed_when: | ||
- assert_4_col_accessible.rowcount[1] | int != 4 | ||
when: | ||
- db_engine == 'mariadb' | ||
|
||
# ====================== Test the fix ===================================== | ||
|
||
- name: Mysql_role Column case sensitive | Recreate role with case sensitive | ||
community.mysql.mysql_role: | ||
<<: *mysql_params | ||
name: 'role_column_case_sensitive' | ||
state: present | ||
members: | ||
- 'column_case_sensitive@%' | ||
priv: | ||
'mysql_role_column_case.t1': 'SELECT(a, B, cC, Dd)' | ||
column_case_sensitive: true | ||
|
||
- name: Mysql_role Column case sensitive | Assert role privileges are case sensitive | ||
community.mysql.mysql_query: | ||
<<: *mysql_params | ||
query: | ||
- SHOW GRANTS FOR role_column_case_sensitive | ||
register: column_case_sensitive_grants | ||
failed_when: | ||
# Column order may vary, thus test each separately | ||
- >- | ||
column_case_sensitive_grants.query_result[0][1] | ||
is not search("a", ignorecase=false) | ||
or column_case_sensitive_grants.query_result[0][1] | ||
is not search("B", ignorecase=false) | ||
or column_case_sensitive_grants.query_result[0][1] | ||
is not search("cC", ignorecase=false) | ||
or column_case_sensitive_grants.query_result[0][1] | ||
is not search("Dd", ignorecase=false) | ||
- name: Mysql_role Column case sensitive | Assert 4 columns are accessible | ||
community.mysql.mysql_query: | ||
<<: *mysql_params | ||
login_user: column_case_sensitive | ||
query: | ||
- SET ROLE role_column_case_sensitive | ||
- DESC mysql_role_column_case.t1 | ||
register: assert_4_col_accessible | ||
failed_when: | ||
- assert_4_col_accessible.rowcount[1] | int != 4 | ||
|
||
# ========================= Teardown ====================================== | ||
|
||
- name: Mysql_role Column case sensitive | Delete test users | ||
community.mysql.mysql_user: | ||
<<: *mysql_params | ||
name: column_case_sensitive | ||
host_all: true | ||
state: absent | ||
|
||
- name: Mysql_role Column case sensitive | Delete role | ||
community.mysql.mysql_role: | ||
<<: *mysql_params | ||
name: 'role_column_case_sensitive' | ||
state: absent | ||
|
||
- name: Mysql_role Column case sensitive | Delete test database | ||
community.mysql.mysql_db: | ||
<<: *mysql_params | ||
name: mysql_role_column_case | ||
state: absent |
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
Oops, something went wrong.