use curl client for create/drop/alter queries to make test run faster

This commit is contained in:
Arthur Passos 2024-08-28 12:54:22 -03:00
parent b29e00b838
commit 9f7f6c6f93

View File

@ -33,14 +33,14 @@ function test
{
user="u01_03174"
${CLICKHOUSE_CLIENT} --query "DROP USER IF EXISTS ${user} $1"
${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}" -d "DROP USER IF EXISTS ${user} $1"
${CLICKHOUSE_CLIENT} --query "CREATE USER ${user} $1 IDENTIFIED WITH plaintext_password BY '1'"
${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}" -d "CREATE USER ${user} $1 IDENTIFIED WITH plaintext_password BY '1'"
echo "Basic authentication after user creation"
test_login_pwd ${user} '1'
${CLICKHOUSE_CLIENT} --query "ALTER USER ${user} $1 IDENTIFIED WITH plaintext_password BY '2'"
${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}" -d "ALTER USER ${user} $1 IDENTIFIED WITH plaintext_password BY '2'"
echo "Changed password, old password should not work"
test_login_pwd_expect_error ${user} '1'
@ -48,7 +48,7 @@ function test
echo "New password should work"
test_login_pwd ${user} '2'
${CLICKHOUSE_CLIENT} --query "ALTER USER ${user} $1 ADD IDENTIFIED WITH plaintext_password BY '3', plaintext_password BY '4'"
${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}" -d "ALTER USER ${user} $1 ADD IDENTIFIED WITH plaintext_password BY '3', plaintext_password BY '4'"
echo "Two new passwords were added, should both work"
test_login_pwd ${user} '3'
@ -57,7 +57,7 @@ function test
ssh_pub_key="AAAAC3NzaC1lZDI1NTE5AAAAIBzqa3duS0ce6QYkzUgko9W0Ux7i7d3xPoseFrwnhY4Y"
${CLICKHOUSE_CLIENT} --query "ALTER USER ${user} $1 ADD IDENTIFIED WITH ssh_key BY KEY '${ssh_pub_key}' TYPE 'ssh-ed25519'"
${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}" -d "ALTER USER ${user} $1 ADD IDENTIFIED WITH ssh_key BY KEY '${ssh_pub_key}' TYPE 'ssh-ed25519'"
echo ${ssh_key} > ssh_key
@ -65,7 +65,7 @@ function test
${CLICKHOUSE_CLIENT} --user ${user} --ssh-key-file 'ssh_key' --ssh-key-passphrase "" --query "SELECT 1"
echo "Altering credentials and keeping only bcrypt_password"
${CLICKHOUSE_CLIENT} --query "ALTER USER ${user} $1 IDENTIFIED WITH bcrypt_password BY '5'"
${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}" -d "ALTER USER ${user} $1 IDENTIFIED WITH bcrypt_password BY '5'"
echo "Asserting SSH does not work anymore"
${CLICKHOUSE_CLIENT} --user ${user} --ssh-key-file 'ssh_key' --ssh-key-passphrase "" --query "SELECT 1" 2>&1 | grep -m1 -o 'AUTHENTICATION_FAILED'
@ -74,14 +74,14 @@ function test
test_login_pwd ${user} '5'
echo "Adding new bcrypt_password"
${CLICKHOUSE_CLIENT} --query "ALTER USER ${user} $1 ADD IDENTIFIED WITH bcrypt_password BY '6'"
${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}" -d "ALTER USER ${user} $1 ADD IDENTIFIED WITH bcrypt_password BY '6'"
echo "Both current authentication methods should work"
test_login_pwd ${user} '5'
test_login_pwd ${user} '6'
echo "Reset authentication methods to new"
${CLICKHOUSE_CLIENT} --query "ALTER USER ${user} $1 RESET AUTHENTICATION METHODS TO NEW"
${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}" -d "ALTER USER ${user} $1 RESET AUTHENTICATION METHODS TO NEW"
echo "Only the latest should work, below should fail"
test_login_pwd_expect_error ${user} '5'
@ -90,13 +90,13 @@ function test
test_login_pwd ${user} '6'
echo "Replacing existing authentication methods in favor of no_password, should succeed"
${CLICKHOUSE_CLIENT} --query "ALTER USER ${user} $1 IDENTIFIED WITH no_password"
${CLICKHOUSE_CLIENT} --query "SHOW CREATE USER ${user}"
${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}" -d "ALTER USER ${user} $1 IDENTIFIED WITH no_password"
${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}" -d "SHOW CREATE USER ${user}"
echo "Trying to auth with no pwd, should succeed"
test_login_no_pwd ${user}
${CLICKHOUSE_CLIENT} --query "DROP USER IF EXISTS ${user}"
${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}" -d "DROP USER IF EXISTS ${user}"
}
test ""