1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Adds functional tests for new mysql_user privs (#48403)

Adds tests for FUNCTION and PROCEDURE privs
This commit is contained in:
Tim Rupp 2018-11-09 08:59:19 -08:00 committed by GitHub
parent 9757d9d4c3
commit cdc5ab7737
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 87 additions and 0 deletions

View file

@ -0,0 +1,8 @@
USE foo;
DELIMITER ;;
CREATE FUNCTION `function` () RETURNS tinyint(4)
BEGIN
DECLARE NAME_FOUND tinyint DEFAULT 0;
RETURN NAME_FOUND;
END;;
DELIMITER ;

View file

@ -0,0 +1,5 @@
USE bar;
DELIMITER ;;
CREATE PROCEDURE `procedure` ()
SELECT * FROM bar;;
DELIMITER ;

View file

@ -0,0 +1,70 @@
---
- name: Issue test setup - drop database
mysql_db:
name: "{{ item }}"
state: absent
login_unix_socket: '{{ mysql_socket }}'
loop:
- foo
- bar
- name: Issue test setup - create database
mysql_db:
name: "{{ item }}"
state: present
login_unix_socket: '{{ mysql_socket }}'
loop:
- foo
- bar
- name: Create function for test
shell: "mysql < {{ role_path }}/files/create-function.sql"
- name: Create procedure for test
shell: "mysql < {{ role_path }}/files/create-procedure.sql"
- name: Create user with FUNCTION and PROCEDURE privileges
mysql_user:
name: '{{ user_name_2 }}'
password: '{{ user_password_2 }}'
state: present
priv: 'FUNCTION foo.function:EXECUTE/foo.*:SELECT/PROCEDURE bar.procedure:EXECUTE'
login_unix_socket: '{{ mysql_socket }}'
register: result
- name: Assert Create user with FUNCTION and PROCEDURE privileges
assert:
that:
- result is success
- result is changed
- name: Create user with FUNCTION and PROCEDURE privileges - Idempotent check
mysql_user:
name: '{{ user_name_2 }}'
password: '{{ user_password_2 }}'
state: present
priv: 'FUNCTION foo.function:EXECUTE/foo.*:SELECT/PROCEDURE bar.procedure:EXECUTE'
login_unix_socket: '{{ mysql_socket }}'
register: result
- name: Assert Create user with FUNCTION and PROCEDURE privileges
assert:
that:
- result is success
- result is not changed
- name: Remove user
mysql_user:
name: '{{ user_name_2 }}'
state: absent
login_unix_socket: '{{ mysql_socket }}'
- name: Issue test teardown - cleanup databases
mysql_db:
name: "{{ item }}"
state: absent
login_unix_socket: '{{ mysql_socket }}'
loop:
- foo
- bar

View file

@ -207,3 +207,7 @@
# Assert creating user with SELECT privileges, attempt to create database and append privileges to create database
#
- include: test_privs.yml current_privilege='INSERT,DELETE' current_append_privs=yes
- import_tasks: issue-29511.yaml
tags:
- issue-29511