Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersson007 committed Jan 29, 2025
1 parent aa11293 commit 9af4ce6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
57 changes: 51 additions & 6 deletions tests/integration/targets/clickhouse_grants/tasks/initial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
register: result
community.clickhouse.clickhouse_client:
login_host: localhost
client_kwargs:
connect_timeout: 20
execute: >
CREATE TABLE IF NOT EXISTS foo.test_table1
(x String) ENGINE = Memory
Expand All @@ -29,6 +27,25 @@
b: two
c: three

- name: Create a test table 2
register: result
community.clickhouse.clickhouse_client:
login_host: localhost
execute: >
CREATE TABLE IF NOT EXISTS foo.test_table2
(y String, z String) ENGINE = Memory
execute_kwargs:
types_check: false

- name: Insert into test table using named args
register: result
community.clickhouse.clickhouse_client:
execute: "INSERT INTO foo.test_table2 (y, z) VALUES (%(a)s, %(b)s)"
execute_kwargs:
params:
a: one
b: two

- name: Create a test user
community.clickhouse.clickhouse_user:
state: present
Expand All @@ -39,10 +56,38 @@
register: result
community.clickhouse.clickhouse_info:
login_host: localhost
client_kwargs:
connect_timeout: 20

- name: Check user's attributes
- name: Check user's grants, they are empty
ansible.builtin.assert:
that:
- result["users"]["alice"]["grants"] == []

- name: Grant SELECT on a column WITH GRANT OPTION
register: result
community.clickhouse.clickhouse_client:
execute: GRANT SELECT(x) ON foo.test_table1 TO alice WITH GRANT OPTION

- name: Grant SELECT on a table
register: result
community.clickhouse.clickhouse_client:
execute: GRANT SELECT ON foo.test_table2 TO alice

- name: Grant SELECT on a column in the same table
register: result
community.clickhouse.clickhouse_client:
execute: GRANT SELECT(y) ON foo.test_table2 TO alice

- name: Grant UPDATE on another column in the same table
register: result
community.clickhouse.clickhouse_client:
execute: GRANT UPDATE(z) ON foo.test_table2 TO alice

- name: Get user info
register: result
community.clickhouse.clickhouse_info:
login_host: localhost

- name: Check user's grants again, not empty
ansible.builtin.assert:
that:
- result["users"]["alice"] != {}
- result["users"]["alice"]["grants"] != []
3 changes: 2 additions & 1 deletion tests/integration/targets/setup_clickhouse/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
clickhouse_version: 24.8.6.70
#clickhouse_version: 24.8.6.70
clickhouse_version: 23.8.9.54

0 comments on commit 9af4ce6

Please sign in to comment.