[fix] Fix style check

This commit is contained in:
unashi 2024-08-27 10:25:07 +08:00
parent a7d693573b
commit 26cab169aa
2 changed files with 11 additions and 14 deletions

View File

@ -16,7 +16,6 @@ namespace DB
namespace ErrorCodes
{
extern const int INVALID_GRANT;
extern const int SYNTAX_ERROR;
}
namespace

View File

@ -4,22 +4,18 @@ import logging
import pytest
from helpers.cluster import ClickHouseCluster
@pytest.fixture(scope="module")
def cluster():
try:
cluster = ClickHouseCluster(__file__)
cluster.add_instance(
"node1",
user_configs=[
"configs/users.xml"
]
)
cluster.add_instance("node1", user_configs=["configs/users.xml"])
cluster.add_instance(
"node2",
user_configs=[
"configs/users.xml",
]
],
)
logging.info("Starting cluster...")
cluster.start()
@ -37,24 +33,26 @@ def test_check_grant(cluster):
node1.query("CREATE USER tuser")
node1.query("GRANT SELECT ON tb TO tuser")
# Has been granted but not table not exists
res, _ = node1.query("CHECK GRANT SELECT ON tb", user = "tuser")
res, _ = node1.query("CHECK GRANT SELECT ON tb", user="tuser")
assert res == "0"
node1.query("CREATE TABLE tb (`content` UInt64) ENGINE = MergeTree ORDER BY content")
node1.query(
"CREATE TABLE tb (`content` UInt64) ENGINE = MergeTree ORDER BY content"
)
node1.query("INSERT INTO tb VALUES (1)")
# Has been granted and table exists
res, _ = node1.query("CHECK GRANT SELECT ON tb", user = "tuser")
res, _ = node1.query("CHECK GRANT SELECT ON tb", user="tuser")
assert res == "1"
node1.query("REVOKE SELECT ON tb FROM tuser")
# Has not been granted but table exists
res, _ = node1.query("CHECK GRANT SELECT ON tb", user = "tuser")
res, _ = node1.query("CHECK GRANT SELECT ON tb", user="tuser")
assert res == "0"
# Role
node1.query("CREATE ROLE trole")
node1.query("GRANT SELECT ON tb TO trole")
node1.query("GRANT trole TO tuser")
node1.query("SET ROLE trole", user = "tuser")
res, _ = node1.query("CHECK GRANT SELECT ON tb", user = "tuser")
node1.query("SET ROLE trole", user="tuser")
res, _ = node1.query("CHECK GRANT SELECT ON tb", user="tuser")
assert res == "1"