2021-09-14 22:42:28 +00:00
|
|
|
#!/usr/bin/env bash
|
2023-03-16 16:53:12 +00:00
|
|
|
# Tags: no-fasttest
|
2021-09-14 22:42:28 +00:00
|
|
|
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
|
|
# shellcheck source=../shell_config.sh
|
|
|
|
. "$CURDIR"/../shell_config.sh
|
|
|
|
|
2021-09-16 17:18:34 +00:00
|
|
|
url="${CLICKHOUSE_URL}&async_insert=1&wait_for_async_insert=1"
|
2021-09-14 22:42:28 +00:00
|
|
|
|
|
|
|
${CLICKHOUSE_CLIENT} -q "DROP USER IF EXISTS u_02015_allowed"
|
|
|
|
${CLICKHOUSE_CLIENT} -q "DROP USER IF EXISTS u_02015_denied"
|
|
|
|
${CLICKHOUSE_CLIENT} -q "DROP ROLE IF EXISTS role_02015"
|
|
|
|
|
|
|
|
${CLICKHOUSE_CLIENT} -q "CREATE ROLE role_02015"
|
|
|
|
${CLICKHOUSE_CLIENT} -q "CREATE USER u_02015_allowed";
|
|
|
|
${CLICKHOUSE_CLIENT} -q "CREATE USER u_02015_denied";
|
|
|
|
|
|
|
|
${CLICKHOUSE_CLIENT} -q "REVOKE ALL ON *.* FROM u_02015_allowed"
|
|
|
|
${CLICKHOUSE_CLIENT} -q "REVOKE ALL ON *.* FROM u_02015_denied"
|
|
|
|
|
|
|
|
${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS async_inserts"
|
|
|
|
${CLICKHOUSE_CLIENT} -q "CREATE TABLE async_inserts (id UInt32, s String) ENGINE = MergeTree ORDER BY id"
|
|
|
|
|
|
|
|
${CLICKHOUSE_CLIENT} -q "GRANT INSERT ON async_inserts TO role_02015"
|
|
|
|
${CLICKHOUSE_CLIENT} -q "GRANT role_02015 to u_02015_allowed"
|
|
|
|
|
|
|
|
${CLICKHOUSE_CURL} -sS "$url&user=u_02015_denied" \
|
|
|
|
-d 'INSERT INTO async_inserts FORMAT JSONEachRow {"id": 1, "s": "a"} {"id": 2, "s": "b"}' \
|
|
|
|
| grep -o "Not enough privileges"
|
|
|
|
|
|
|
|
${CLICKHOUSE_CURL} -sS "$url&user=u_02015_allowed" \
|
|
|
|
-d 'INSERT INTO async_inserts FORMAT JSONEachRow {"id": 1, "s": "a"} {"id": 2, "s": "b"}'
|
|
|
|
|
|
|
|
${CLICKHOUSE_CLIENT} -q "SELECT * FROM async_inserts ORDER BY id"
|
|
|
|
|
|
|
|
${CLICKHOUSE_CLIENT} -q "DROP TABLE async_inserts"
|
|
|
|
${CLICKHOUSE_CLIENT} -q "DROP USER u_02015_allowed"
|
|
|
|
${CLICKHOUSE_CLIENT} -q "DROP USER u_02015_denied"
|
|
|
|
${CLICKHOUSE_CLIENT} -q "DROP ROLE role_02015"
|