From 5477603583c0e7bb4e0c96956686ba547b3b9057 Mon Sep 17 00:00:00 2001 From: Laurent Indermuehle Date: Tue, 10 Oct 2023 11:01:59 +0200 Subject: [PATCH] Revert "sync fork with upstream main" This reverts commit 77593b7a91e8d417eead0d3d5366ba991c767565. I imported PR569 to be able to test on my fork, but to avoid polluting this patch I now revert those commit. --- .github/workflows/ansible-test-plugins.yml | 46 +++--- .github/workflows/ansible-test-roles.yml | 19 ++- CONTRIBUTORS | 1 - README.md | 8 +- TESTING.md | 2 - changelogs/569_fix_column_uppercasing.yml | 21 --- .../drop_ansible_core_2_12_and_2_13.yml | 11 -- plugins/module_utils/user.py | 13 +- plugins/modules/mysql_role.py | 25 +-- plugins/modules/mysql_user.py | 25 +-- .../targets/test_mysql_role/tasks/main.yml | 4 - .../tasks/test_column_case_sensitive.yml | 149 ------------------ .../targets/test_mysql_user/tasks/main.yml | 4 - .../tasks/test_column_case_sensitive.yml | 134 ---------------- .../{ignore-2.17.txt => ignore-2.12.txt} | 2 - tests/sanity/ignore-2.13.txt | 8 + .../plugins/module_utils/test_mysql_user.py | 21 +-- 17 files changed, 56 insertions(+), 437 deletions(-) delete mode 100644 changelogs/569_fix_column_uppercasing.yml delete mode 100644 changelogs/fragments/drop_ansible_core_2_12_and_2_13.yml delete mode 100644 tests/integration/targets/test_mysql_role/tasks/test_column_case_sensitive.yml delete mode 100644 tests/integration/targets/test_mysql_user/tasks/test_column_case_sensitive.yml rename tests/sanity/{ignore-2.17.txt => ignore-2.12.txt} (84%) create mode 100644 tests/sanity/ignore-2.13.txt diff --git a/.github/workflows/ansible-test-plugins.yml b/.github/workflows/ansible-test-plugins.yml index 78644bb..6533f94 100644 --- a/.github/workflows/ansible-test-plugins.yml +++ b/.github/workflows/ansible-test-plugins.yml @@ -22,9 +22,9 @@ jobs: strategy: matrix: ansible: + - stable-2.12 + - stable-2.13 - stable-2.14 - - stable-2.15 - - stable-2.16 - devel steps: - name: Perform sanity testing @@ -41,9 +41,9 @@ jobs: fail-fast: false matrix: ansible: + - stable-2.12 + - stable-2.13 - stable-2.14 - - stable-2.15 - - stable-2.16 - devel db_engine_name: - mysql @@ -111,15 +111,12 @@ jobs: - db_engine_version: 5.7.40 python: '3.10' + - db_engine_version: 5.7.40 + ansible: stable-2.13 + - db_engine_version: 5.7.40 ansible: stable-2.14 - - db_engine_version: 5.7.40 - ansible: stable-2.15 - - - db_engine_version: 5.7.40 - ansible: stable-2.16 - - db_engine_version: 5.7.40 ansible: devel @@ -174,27 +171,24 @@ jobs: - python: '3.10' connector_version: 2.0.3 + - python: '3.8' + ansible: stable-2.13 + - python: '3.8' ansible: stable-2.14 - - python: '3.8' - ansible: stable-2.15 - - - python: '3.8' - ansible: stable-2.16 - - python: '3.8' ansible: devel - python: '3.9' - ansible: stable-2.15 - - - python: '3.9' - ansible: stable-2.16 + ansible: stable-2.12 - python: '3.9' ansible: devel + - python: '3.10' + ansible: stable-2.12 + services: db_primary: image: docker.io/library/${{ matrix.db_engine_name }}:${{ matrix.db_engine_version }} @@ -340,22 +334,22 @@ jobs: fail-fast: true matrix: ansible: + - stable-2.12 + - stable-2.13 - stable-2.14 - - stable-2.15 - - stable-2.16 - devel python: - 3.8 - 3.9 exclude: + - python: '3.8' + ansible: stable-2.13 - python: '3.8' ansible: stable-2.14 - - python: '3.8' - ansible: stable-2.15 - - python: '3.8' - ansible: stable-2.16 - python: '3.8' ansible: devel + - python: '3.9' + ansible: stable-2.12 steps: - name: >- diff --git a/.github/workflows/ansible-test-roles.yml b/.github/workflows/ansible-test-roles.yml index da8a805..13e7d41 100644 --- a/.github/workflows/ansible-test-roles.yml +++ b/.github/workflows/ansible-test-roles.yml @@ -24,16 +24,31 @@ jobs: mysql: - 2.0.12 ansible: + - stable-2.11 + - stable-2.12 - stable-2.13 - - stable-2.14 - - stable-2.15 - devel python: + - 3.6 - 3.8 - 3.9 exclude: + - python: 3.6 + ansible: stable-2.12 + - python: 3.6 + ansible: stable-2.13 + - python: 3.6 + ansible: devel + - python: 3.8 + ansible: stable-2.11 + - python: 3.8 + ansible: stable-2.13 - python: 3.8 ansible: devel + - python: 3.9 + ansible: stable-2.11 + - python: 3.9 + ansible: stable-2.12 steps: diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 36e8a08..3acc8f3 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -141,7 +141,6 @@ kalaisubbiah kenichi-ogawa-1988 kkeane klingac -kmarse koleo kotso kuntalFreshBooks diff --git a/README.md b/README.md index f7e062c..b024453 100644 --- a/README.md +++ b/README.md @@ -82,11 +82,9 @@ Here is the table for the support timeline: ### ansible-core -- stable-2.12 -- stable-2.13 -- stable-2.14 -- stable-2.15 -- stable-2.16 +- 2.12 +- 2.13 +- 2.14 - current development version ### Databases diff --git a/TESTING.md b/TESTING.md index 7025391..7bbafc3 100644 --- a/TESTING.md +++ b/TESTING.md @@ -52,8 +52,6 @@ The Makefile accept the following options - "stable-2.12" - "stable-2.13" - "stable-2.14" - - "stable-2.15" - - "stable-2.16" - "devel" - Description: Version of ansible to install in a venv to run ansible-test diff --git a/changelogs/569_fix_column_uppercasing.yml b/changelogs/569_fix_column_uppercasing.yml deleted file mode 100644 index 781304e..0000000 --- a/changelogs/569_fix_column_uppercasing.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -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). diff --git a/changelogs/fragments/drop_ansible_core_2_12_and_2_13.yml b/changelogs/fragments/drop_ansible_core_2_12_and_2_13.yml deleted file mode 100644 index 29a363e..0000000 --- a/changelogs/fragments/drop_ansible_core_2_12_and_2_13.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- - -major_changes: - - - The community.mysql collection no longer supports ``ansible-core 2.12`` and - ``ansible-core 2.13``. While we take no active measures to prevent usage - and there are no plans to introduce incompatible code to the modules, we - will stop testing those versions. Both are or will soon be End of Life and - if you are still using them, you should consider upgrading to the - ``latest Ansible / ansible-core 2.15 or later`` as soon as possible - (https://github.com/ansible-collections/community.mysql/pull/574). diff --git a/plugins/module_utils/user.py b/plugins/module_utils/user.py index 4777b16..089963f 100644 --- a/plugins/module_utils/user.py +++ b/plugins/module_utils/user.py @@ -677,7 +677,7 @@ def sort_column_order(statement): return '%s(%s)' % (priv_name, ', '.join(columns)) -def privileges_unpack(priv, mode, column_case_sensitive, ensure_usage=True): +def privileges_unpack(priv, mode, ensure_usage=True): """ Take a privileges string, typically passed as a parameter, and unserialize it into a dictionary, the same format as privileges_get() above. We have this custom format to avoid using YAML/JSON strings inside YAML playbooks. Example @@ -713,14 +713,9 @@ def privileges_unpack(priv, mode, column_case_sensitive, ensure_usage=True): pieces[0] = object_type + '.'.join(dbpriv) if '(' in pieces[1]: - if column_case_sensitive is True: - output[pieces[0]] = re.split(r',\s*(?=[^)]*(?:\(|$))', pieces[1]) - for i in output[pieces[0]]: - privs.append(re.sub(r'\s*\(.*\)', '', i)) - else: - output[pieces[0]] = re.split(r',\s*(?=[^)]*(?:\(|$))', pieces[1].upper()) - for i in output[pieces[0]]: - privs.append(re.sub(r'\s*\(.*\)', '', i)) + output[pieces[0]] = re.split(r',\s*(?=[^)]*(?:\(|$))', pieces[1].upper()) + for i in output[pieces[0]]: + privs.append(re.sub(r'\s*\(.*\)', '', i)) else: output[pieces[0]] = pieces[1].upper().split(',') privs = output[pieces[0]] diff --git a/plugins/modules/mysql_role.py b/plugins/modules/mysql_role.py index 6e70549..4d1d620 100644 --- a/plugins/modules/mysql_role.py +++ b/plugins/modules/mysql_role.py @@ -121,16 +121,6 @@ options: type: bool default: true - column_case_sensitive: - description: - - The default is C(false). - - When C(true), the module will not uppercase the field in the privileges. - - When C(false), the field names will be upper-cased. This was the default before this - feature was introduced but since MySQL/MariaDB is case sensitive you should set this - to C(true) in most cases. - type: bool - version_added: '3.8.0' - notes: - Pay attention that the module runs C(SET DEFAULT ROLE ALL TO) all the I(members) passed by default when the state has changed. @@ -149,8 +139,6 @@ seealso: author: - Andrew Klychkov (@Andersson007) - Felix Hamme (@betanummeric) - - kmarse (@kmarse) - - Laurent Indermühle (@laurent-indermuehle) extends_documentation_fragment: - community.mysql.mysql @@ -968,8 +956,7 @@ def main(): detach_members=dict(type='bool', default=False), check_implicit_admin=dict(type='bool', default=False), set_default_role_all=dict(type='bool', default=True), - members_must_exist=dict(type='bool', default=True), - column_case_sensitive=dict(type='bool', default=None), # TODO 4.0.0 add default=True + members_must_exist=dict(type='bool', default=True) ) module = AnsibleModule( argument_spec=argument_spec, @@ -1004,7 +991,6 @@ def main(): db = '' set_default_role_all = module.params['set_default_role_all'] members_must_exist = module.params['members_must_exist'] - column_case_sensitive = module.params['column_case_sensitive'] if priv and not isinstance(priv, (str, dict)): msg = ('The "priv" parameter must be str or dict ' @@ -1017,13 +1003,6 @@ def main(): if mysql_driver is None: module.fail_json(msg=mysql_driver_fail_msg) - # TODO Release 4.0.0 : Remove this test and variable assignation - if column_case_sensitive is None: - column_case_sensitive = False - module.warn("Option column_case_sensitive is not provided. " - "The default is now false, so the column's name will be uppercased. " - "The default will be changed to true in community.mysql 4.0.0.") - cursor = None try: if check_implicit_admin: @@ -1061,7 +1040,7 @@ def main(): module.fail_json(msg=to_native(e)) try: - priv = privileges_unpack(priv, mode, column_case_sensitive, ensure_usage=not subtract_privs) + priv = privileges_unpack(priv, mode, ensure_usage=not subtract_privs) except Exception as e: module.fail_json(msg='Invalid privileges string: %s' % to_native(e)) diff --git a/plugins/modules/mysql_user.py b/plugins/modules/mysql_user.py index 3e914e6..38e5124 100644 --- a/plugins/modules/mysql_user.py +++ b/plugins/modules/mysql_user.py @@ -156,16 +156,6 @@ options: type: dict version_added: '3.6.0' - column_case_sensitive: - description: - - The default is C(false). - - When C(true), the module will not uppercase the field names in the privileges. - - When C(false), the field names will be upper-cased. This is the default - - This feature was introduced because MySQL 8 and above uses case sensitive - fields names in privileges. - type: bool - version_added: '3.8.0' - notes: - "MySQL server installs with default I(login_user) of C(root) and no password. To secure this user as part of an idempotent playbook, you must create at least two tasks: @@ -191,9 +181,6 @@ author: - Jonathan Mainguy (@Jmainguy) - Benjamin Malynovytch (@bmalynovytch) - Lukasz Tomaszkiewicz (@tomaszkiewicz) -- kmarse (@kmarse) -- Laurent Indermühle (@laurent-indermuehle) - extends_documentation_fragment: - community.mysql.mysql ''' @@ -414,7 +401,6 @@ def main(): resource_limits=dict(type='dict'), force_context=dict(type='bool', default=False), session_vars=dict(type='dict'), - column_case_sensitive=dict(type='bool', default=None), # TODO 4.0.0 add default=True ) module = AnsibleModule( argument_spec=argument_spec, @@ -450,7 +436,6 @@ def main(): plugin_auth_string = module.params["plugin_auth_string"] resource_limits = module.params["resource_limits"] session_vars = module.params["session_vars"] - column_case_sensitive = module.params["column_case_sensitive"] if priv and not isinstance(priv, (str, dict)): module.fail_json(msg="priv parameter must be str or dict but %s was passed" % type(priv)) @@ -477,13 +462,6 @@ def main(): module.fail_json(msg="unable to connect to database, check login_user and login_password are correct or %s has the credentials. " "Exception message: %s" % (config_file, to_native(e))) - # TODO Release 4.0.0 : Remove this test and variable assignation - if column_case_sensitive is None: - column_case_sensitive = False - module.warn("Option column_case_sensitive is not provided. " - "The default is now false, so the column's name will be uppercased. " - "The default will be changed to true in community.mysql 4.0.0.") - if not sql_log_bin: cursor.execute("SET SQL_LOG_BIN=0;") @@ -497,8 +475,7 @@ def main(): mode = get_mode(cursor) except Exception as e: module.fail_json(msg=to_native(e)) - - priv = privileges_unpack(priv, mode, column_case_sensitive, ensure_usage=not subtract_privs) + priv = privileges_unpack(priv, mode, ensure_usage=not subtract_privs) password_changed = False if state == "present": if user_exists(cursor, user, host, host_all): diff --git a/tests/integration/targets/test_mysql_role/tasks/main.yml b/tests/integration/targets/test_mysql_role/tasks/main.yml index 44e3308..b517fc0 100644 --- a/tests/integration/targets/test_mysql_role/tasks/main.yml +++ b/tests/integration/targets/test_mysql_role/tasks/main.yml @@ -18,7 +18,3 @@ - include_tasks: test_priv_subtract.yml vars: enable_check_mode: yes - -- name: Test column case sensitive - ansible.builtin.import_tasks: - file: test_column_case_sensitive.yml diff --git a/tests/integration/targets/test_mysql_role/tasks/test_column_case_sensitive.yml b/tests/integration/targets/test_mysql_role/tasks/test_column_case_sensitive.yml deleted file mode 100644 index 74849e0..0000000 --- a/tests/integration/targets/test_mysql_role/tasks/test_column_case_sensitive.yml +++ /dev/null @@ -1,149 +0,0 @@ ---- - -- 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 diff --git a/tests/integration/targets/test_mysql_user/tasks/main.yml b/tests/integration/targets/test_mysql_user/tasks/main.yml index 4816805..dc5c9d3 100644 --- a/tests/integration/targets/test_mysql_user/tasks/main.yml +++ b/tests/integration/targets/test_mysql_user/tasks/main.yml @@ -286,7 +286,3 @@ - include_tasks: test_user_grants_with_roles_applied.yml - include_tasks: test_revoke_only_grant.yml - - - name: Mysql_user - test column case sensitive - ansible.builtin.import_tasks: - file: test_column_case_sensitive.yml diff --git a/tests/integration/targets/test_mysql_user/tasks/test_column_case_sensitive.yml b/tests/integration/targets/test_mysql_user/tasks/test_column_case_sensitive.yml deleted file mode 100644 index 68e95aa..0000000 --- a/tests/integration/targets/test_mysql_user/tasks/test_column_case_sensitive.yml +++ /dev/null @@ -1,134 +0,0 @@ ---- - -- 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_user Column case sensitive | Create a test table - community.mysql.mysql_query: - <<: *mysql_params - query: - - CREATE DATABASE mysql_user_column_case - - >- - CREATE TABLE mysql_user_column_case.t1 - (a int, B int, cC int, Dd int) - - >- - INSERT INTO mysql_user_column_case.t1 - (a, B, cC, Dd) VALUES (1,2,3,4) - - # ================= Reproduce failure ===================================== - - - name: Mysql_user Column case sensitive | Create test user - community.mysql.mysql_user: - <<: *mysql_params - name: column_case_sensitive - host: '%' - password: 'msandbox' - priv: - 'mysql_user_column_case.t1': 'SELECT(a, B, cC, Dd)' - - - name: Mysql_user Column case sensitive | Assert user privileges are all caps - community.mysql.mysql_query: - <<: *mysql_params - query: - - SHOW GRANTS FOR 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_user Column case sensitive | Assert 1 column is accessible on MySQL 5.7 - community.mysql.mysql_query: - <<: *mysql_params - login_user: column_case_sensitive - query: - - DESC mysql_user_column_case.t1 - register: assert_1_col_accessible - failed_when: - - assert_1_col_accessible.rowcount[0] | int != 1 - when: - - db_engine == 'mysql' and db_version is version('5.7', '<=') - - - name: Mysql_user Column case sensitive | Assert 4 column are accessible on MariaDB and MySQL 8+ - community.mysql.mysql_query: - <<: *mysql_params - login_user: column_case_sensitive - query: - - DESC mysql_user_column_case.t1 - register: assert_4_col_accessible - failed_when: - - assert_4_col_accessible.rowcount[0] | int != 4 - when: - - >- - db_engine == 'mariadb' - or (db_engine == 'mysql' and db_version is version('8.0', '>=')) - - # ======================== Test fix ====================================== - - - name: Mysql_user Column case sensitive | Create users with case sensitive - community.mysql.mysql_user: - <<: *mysql_params - name: column_case_sensitive - host: '%' - password: 'msandbox' - priv: - 'mysql_user_column_case.t1': 'SELECT(a, B, cC, Dd)' - column_case_sensitive: true - - - name: Mysql_user Column case sensitive | Assert user privileges are case sensitive - community.mysql.mysql_query: - <<: *mysql_params - query: - - SHOW GRANTS FOR 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_user Column case sensitive | Assert 4 columns are accessible - community.mysql.mysql_query: - <<: *mysql_params - login_user: column_case_sensitive - query: - - DESC mysql_user_column_case.t1 - register: assert_4_col_accessible - failed_when: - - assert_4_col_accessible.rowcount[0] | int != 4 - - # ========================= Teardown ====================================== - - - name: Mysql_user Column case sensitive | Delete test users - community.mysql.mysql_user: - <<: *mysql_params - name: column_case_sensitive - host_all: true - state: absent - - - name: Mysql_user Column case sensitive | Delete test database - community.mysql.mysql_db: - <<: *mysql_params - name: mysql_user_column_case - state: absent diff --git a/tests/sanity/ignore-2.17.txt b/tests/sanity/ignore-2.12.txt similarity index 84% rename from tests/sanity/ignore-2.17.txt rename to tests/sanity/ignore-2.12.txt index da0354c..c0323af 100644 --- a/tests/sanity/ignore-2.17.txt +++ b/tests/sanity/ignore-2.12.txt @@ -6,5 +6,3 @@ plugins/modules/mysql_info.py validate-modules:parameter-list-no-elements plugins/modules/mysql_query.py validate-modules:parameter-list-no-elements plugins/modules/mysql_user.py validate-modules:undocumented-parameter plugins/modules/mysql_variables.py validate-modules:doc-required-mismatch -plugins/module_utils/mysql.py pylint:unused-import -plugins/module_utils/version.py pylint:unused-import diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt new file mode 100644 index 0000000..c0323af --- /dev/null +++ b/tests/sanity/ignore-2.13.txt @@ -0,0 +1,8 @@ +plugins/modules/mysql_db.py validate-modules:doc-elements-mismatch +plugins/modules/mysql_db.py validate-modules:parameter-list-no-elements +plugins/modules/mysql_db.py validate-modules:use-run-command-not-popen +plugins/modules/mysql_info.py validate-modules:doc-elements-mismatch +plugins/modules/mysql_info.py validate-modules:parameter-list-no-elements +plugins/modules/mysql_query.py validate-modules:parameter-list-no-elements +plugins/modules/mysql_user.py validate-modules:undocumented-parameter +plugins/modules/mysql_variables.py validate-modules:doc-required-mismatch diff --git a/tests/unit/plugins/module_utils/test_mysql_user.py b/tests/unit/plugins/module_utils/test_mysql_user.py index bb1ec24..46b3b8e 100644 --- a/tests/unit/plugins/module_utils/test_mysql_user.py +++ b/tests/unit/plugins/module_utils/test_mysql_user.py @@ -9,8 +9,7 @@ from ansible_collections.community.mysql.plugins.module_utils.user import ( handle_grant_on_col, has_grant_on_col, normalize_col_grants, - sort_column_order, - privileges_unpack, + sort_column_order ) @@ -93,21 +92,3 @@ def test_handle_grant_on_col(privileges, start, end, output): def test_normalize_col_grants(input_, expected): """Tests normalize_col_grants function.""" assert normalize_col_grants(input_) == expected - - -@pytest.mark.parametrize( - 'priv,expected,mode,column_case_sensitive,ensure_usage', - [ - ('mydb.*:SELECT', {'"mydb".*': ['SELECT']}, 'ANSI', False, False), - ('mydb.*:SELECT', {'`mydb`.*': ['SELECT']}, 'NOTANSI', False, False), - ('mydb.*:SELECT', {'"mydb".*': ['SELECT'], '*.*': ['USAGE']}, 'ANSI', False, True), - ('mydb.*:SELECT', {'`mydb`.*': ['SELECT'], '*.*': ['USAGE']}, 'NOTANSI', False, True), - ('mydb.*:SELECT (a)', {'`mydb`.*': ['SELECT (A)']}, 'NOTANSI', False, False), - ('mydb.*:UPDATE (b, a)', {'`mydb`.*': ['UPDATE (a, b)']}, 'NOTANSI', True, False), - ('mydb.*:SELECT (b, a, c)', {'`mydb`.*': ['SELECT (A, B, C)']}, 'NOTANSI', False, False), - ('mydb.*:SELECT (b, a, c)', {'`mydb`.*': ['SELECT (a, b, c)']}, 'NOTANSI', True, False), - ] -) -def test_privileges_unpack(priv, mode, column_case_sensitive, ensure_usage, expected): - """Tests privileges_unpack function.""" - assert privileges_unpack(priv, mode, column_case_sensitive, ensure_usage) == expected