mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
|
import pytest
|
||
|
|
||
|
from helpers.cluster import ClickHouseCluster
|
||
|
|
||
|
cluster = ClickHouseCluster(__file__)
|
||
|
|
||
|
node = cluster.add_instance("node", main_configs=["configs/complexity_rules.xml"])
|
||
|
|
||
|
|
||
|
@pytest.fixture(scope="module")
|
||
|
def start_cluster():
|
||
|
try:
|
||
|
cluster.start()
|
||
|
yield cluster
|
||
|
finally:
|
||
|
cluster.shutdown()
|
||
|
|
||
|
|
||
|
def test_complexity_rules(start_cluster):
|
||
|
|
||
|
error_message = "DB::Exception: Invalid password. The password should: be at least 12 characters long, contain at least 1 numeric character, contain at least 1 lowercase character, contain at least 1 uppercase character, contain at least 1 special character"
|
||
|
assert error_message in node.query_and_get_error(
|
||
|
"CREATE USER u_1 IDENTIFIED WITH plaintext_password BY ''"
|
||
|
)
|
||
|
|
||
|
error_message = "DB::Exception: Invalid password. The password should: contain at least 1 lowercase character, contain at least 1 uppercase character, contain at least 1 special character"
|
||
|
assert error_message in node.query_and_get_error(
|
||
|
"CREATE USER u_2 IDENTIFIED WITH sha256_password BY '000000000000'"
|
||
|
)
|
||
|
|
||
|
error_message = "DB::Exception: Invalid password. The password should: contain at least 1 uppercase character, contain at least 1 special character"
|
||
|
assert error_message in node.query_and_get_error(
|
||
|
"CREATE USER u_3 IDENTIFIED WITH double_sha1_password BY 'a00000000000'"
|
||
|
)
|
||
|
|
||
|
error_message = "DB::Exception: Invalid password. The password should: contain at least 1 special character"
|
||
|
assert error_message in node.query_and_get_error(
|
||
|
"CREATE USER u_4 IDENTIFIED WITH plaintext_password BY 'aA0000000000'"
|
||
|
)
|
||
|
|
||
|
node.query("CREATE USER u_5 IDENTIFIED WITH plaintext_password BY 'aA!000000000'")
|
||
|
node.query("DROP USER u_5")
|