diff --git a/tests/integration/targets/test_mysql_user/tasks/test_user_plugin_auth.yml b/tests/integration/targets/test_mysql_user/tasks/test_user_plugin_auth.yml index b4e28d3..d85153d 100644 --- a/tests/integration/targets/test_mysql_user/tasks/test_user_plugin_auth.yml +++ b/tests/integration/targets/test_mysql_user/tasks/test_user_plugin_auth.yml @@ -310,62 +310,71 @@ - include: remove_user.yml user_name={{ test_user_name }} user_password={{ test_plugin_auth_string }} # ============================================================ - # Test plugin auth switching from one type of plugin to another. + # Test plugin auth switching from one type of plugin to another. The only other plugins that are loaded by default + # are sha2*, but these aren't compatible with pymysql < 0.9, so skip these tests for those versions. # + - name: Get pymysql version + shell: pip show pymysql | awk '/Version/ {print $2}' + register: pymysql_version - - name: Create user with plugin auth (empty auth string) - mysql_user: - <<: *mysql_params - name: '{{ test_user_name }}' - plugin: '{{ test_plugin_type }}' - priv: '{{ test_default_priv }}' - register: result + - name: Test plugin auth switching which doesn't work on pymysql < 0.9 + when: pymysql_version.stdout is version('0.9', '>=') + block: - - name: Check that the module made a change - assert: - that: - - "result.changed == true" + - name: Create user with plugin auth (empty auth string) + mysql_user: + <<: *mysql_params + name: '{{ test_user_name }}' + plugin: '{{ test_plugin_type }}' + priv: '{{ test_default_priv }}' + register: result - - include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }} - - 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: Check that the module made a change + assert: + that: + - "result.changed == true" - - name: Assert that mysql_info was successful - assert: - that: - - "result.failed == false" + - include: assert_user.yml user_name={{ test_user_name }} priv={{ test_default_priv_type }} - - name: Switch user to sha256_password auth plugin - mysql_user: - <<: *mysql_params - name: '{{ test_user_name }}' - plugin: sha256_password - plugin_auth_string: '{{ test_plugin_auth_string }}' - priv: '{{ test_default_priv }}' - register: result + - 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: Get the MySQL version using the new plugin auth string - mysql_info: - login_user: '{{ test_user_name }}' - login_password: '{{ test_plugin_auth_string }}' - 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: Assert that mysql_info was successful - assert: - that: - - "result.failed == false" + - name: Switch user to sha256_password auth plugin + mysql_user: + <<: *mysql_params + name: '{{ test_user_name }}' + plugin: sha256_password + plugin_auth_string: '{{ test_plugin_auth_string }}' + priv: '{{ test_default_priv }}' + register: result - # Cleanup - - include: remove_user.yml user_name={{ test_user_name }} user_password={{ test_plugin_auth_string }} + - name: Get the MySQL version using the new plugin auth string + mysql_info: + login_user: '{{ test_user_name }}' + login_password: '{{ test_plugin_auth_string }}' + 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" + + # Cleanup + - include: remove_user.yml user_name={{ test_user_name }} user_password={{ test_plugin_auth_string }}