Skip to content

Commit 909122b

Browse files
committed
update jwt steps
1 parent f79a3b1 commit 909122b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

jwt_authentication/tests/steps.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,38 @@ def create_user_with_jwt_auth(
461461
node.query(f"DROP USER IF EXISTS {user_name}")
462462

463463

464+
@TestStep(Given)
465+
def create_user_with_password_auth(
466+
self,
467+
user_name: str,
468+
node: Node = None,
469+
password: str = None,
470+
cluster: str = None,
471+
if_not_exists: bool = False,
472+
):
473+
"""Create a user with JWT authentication."""
474+
if node is None:
475+
node = self.context.node
476+
477+
if_not_exists = "IF NOT EXISTS" if if_not_exists else ""
478+
479+
query = f"CREATE USER {if_not_exists} {user_name} "
480+
481+
if cluster is not None:
482+
query += f"ON CLUSTER {cluster} "
483+
484+
if password is not None:
485+
query += f"IDENTIFIED WITH PLAINTEXT_PASSWORD BY {password} "
486+
487+
try:
488+
node.query(query)
489+
yield
490+
491+
finally:
492+
with Finally("drop user"):
493+
node.query(f"DROP USER IF EXISTS {user_name}")
494+
495+
464496
@TestStep(Then)
465497
def check_clickhouse_client_jwt_login(
466498
self,

0 commit comments

Comments
 (0)