Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[regression-test](fix) fix case with invalid grammer #45211

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions regression-test/suites/account_p0/test_alter_user.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ suite("test_alter_user", "account,nonConcurrent") {
sql """alter user test_auth_user2 password_history 0"""
sql """set password for 'test_auth_user2' = password('12345')"""

def result1 = connect(user = 'test_auth_user2', password = '12345', url = context.config.jdbcUrl) {
def result1 = connect('test_auth_user2', '12345', context.config.jdbcUrl) {
sql 'select 1'
}

Expand All @@ -48,7 +48,7 @@ suite("test_alter_user", "account,nonConcurrent") {
sql """alter user test_auth_user2 identified by 'abc12345'"""
exception "Cannot use these credentials for 'test_auth_user2'@'%' because they contradict the password history policy"
}
result1 = connect(user = 'test_auth_user2', password = 'abc123456', url = context.config.jdbcUrl) {
result1 = connect('test_auth_user2', 'abc123456', context.config.jdbcUrl) {
sql 'select 1'
}
sql """set global password_history=0""" // set to disabled
Expand All @@ -58,67 +58,67 @@ suite("test_alter_user", "account,nonConcurrent") {
sql """grant all on *.* to test_auth_user3"""

// login success in multi times
result1 = connect(user = 'test_auth_user3', password = '12345', url = context.config.jdbcUrl) {
result1 = connect('test_auth_user3', '12345', context.config.jdbcUrl) {
sql 'select 1'
}
result1 = connect(user = 'test_auth_user3', password = '12345', url = context.config.jdbcUrl) {
result1 = connect('test_auth_user3', '12345', context.config.jdbcUrl) {
sql 'select 1'
}
result1 = connect(user = 'test_auth_user3', password = '12345', url = context.config.jdbcUrl) {
result1 = connect('test_auth_user3', '12345', context.config.jdbcUrl) {
sql 'select 1'
}
// login failed in 2 times
try {
connect(user = 'test_auth_user3', password = 'wrong', url = context.config.jdbcUrl) {}
connect('test_auth_user3', 'wrong',context.config.jdbcUrl) {}
assertTrue(false. "should not be able to login")
} catch (Exception e) {
assertTrue(e.getMessage().contains("Access denied for user 'test_auth_user3"), e.getMessage())
}
try {
connect(user = 'test_auth_user3', password = 'wrong', url = context.config.jdbcUrl) {}
connect('test_auth_user3', 'wrong', context.config.jdbcUrl) {}
assertTrue(false. "should not be able to login")
} catch (Exception e) {
assertTrue(e.getMessage().contains("Access denied for user 'test_auth_user3"), e.getMessage())
}
// login with correct password but also failed
try {
connect(user = 'test_auth_user3', password = '12345', url = context.config.jdbcUrl) {}
connect('test_auth_user3', '12345', context.config.jdbcUrl) {}
assertTrue(false. "should not be able to login")
} catch (Exception e) {
assertTrue(e.getMessage().contains("Access denied for user 'test_auth_user3'@'%'. Account is blocked for 86400 second(s) (86400 second(s) remaining) due to 2 consecutive failed logins."), e.getMessage())
}

// unlock user and login again
sql """alter user test_auth_user3 account_unlock"""
result1 = connect(user = 'test_auth_user3', password = '12345', url = context.config.jdbcUrl) {
result1 = connect('test_auth_user3', '12345', context.config.jdbcUrl) {
sql 'select 1'
}

// alter PASSWORD_LOCK_TIME
sql """alter user test_auth_user3 PASSWORD_LOCK_TIME 5 SECOND"""
// login failed in 2 times to lock the accout again
try {
connect(user = 'test_auth_user3', password = 'wrong', url = context.config.jdbcUrl) {}
connect('test_auth_user3', 'wrong', context.config.jdbcUrl) {}
assertTrue(false. "should not be able to login")
} catch (Exception e) {
assertTrue(e.getMessage().contains("Access denied for user 'test_auth_user3"), e.getMessage())
}
try {
connect(user = 'test_auth_user3', password = 'wrong', url = context.config.jdbcUrl) {}
connect('test_auth_user3', 'wrong', context.config.jdbcUrl) {}
assertTrue(false. "should not be able to login")
} catch (Exception e) {
assertTrue(e.getMessage().contains("Access denied for user 'test_auth_user3"), e.getMessage())
}
// login with correct password but also failed
try {
connect(user = 'test_auth_user3', password = '12345', url = context.config.jdbcUrl) {}
connect('test_auth_user3', '12345', context.config.jdbcUrl) {}
assertTrue(false. "should not be able to login")
} catch (Exception e) {
assertTrue(e.getMessage().contains("Access denied for user 'test_auth_user3'@'%'. Account is blocked for 5 second(s) (5 second(s) remaining) due to 2 consecutive failed logins."), e.getMessage())
}
// sleep 5 second to unlock account
sleep(5000)
result1 = connect(user = 'test_auth_user3', password = '12345', url = context.config.jdbcUrl) {
result1 = connect('test_auth_user3', '12345', context.config.jdbcUrl) {
sql 'select 1'
}

Expand All @@ -134,20 +134,20 @@ suite("test_alter_user", "account,nonConcurrent") {
}

sql """set password for 'test_auth_user3' = password('Ab1234567^')"""
result1 = connect(user = 'test_auth_user3', password = 'Ab1234567^', url = context.config.jdbcUrl) {
result1 = connect('test_auth_user3', 'Ab1234567^', context.config.jdbcUrl) {
sql 'select 1'
}
sql """set global validate_password_policy=NONE"""

// 5. test expire
sql """create user test_auth_user4 identified by '12345' PASSWORD_EXPIRE INTERVAL 5 SECOND"""
sql """grant all on *.* to test_auth_user4"""
result1 = connect(user = 'test_auth_user4', password = '12345', url = context.config.jdbcUrl) {
result1 = connect('test_auth_user4', '12345', context.config.jdbcUrl) {
sql 'select 1'
}
sleep(6000)
try {
connect(user = 'test_auth_user4', password = '12345', url = context.config.jdbcUrl) {}
connect('test_auth_user4', '12345', context.config.jdbcUrl) {}
assertTrue(false. "should not be able to login")
} catch (Exception e) {
assertTrue(e.getMessage().contains("Your password has expired. To log in you must change it using a client that supports expired passwords."), e.getMessage())
Expand All @@ -157,25 +157,25 @@ suite("test_alter_user", "account,nonConcurrent") {
sql """drop user test_auth_user4"""
sql """create user test_auth_user4 identified by '12345'"""
sql """grant all on *.* to test_auth_user4"""
result1 = connect(user = 'test_auth_user4', password = '12345', url = context.config.jdbcUrl) {
result1 = connect('test_auth_user4', '12345', context.config.jdbcUrl) {
sql 'select 1'
}

// 7. test after expire, reset password
sql """drop user test_auth_user4"""
sql """create user test_auth_user4 identified by '12345' PASSWORD_EXPIRE INTERVAL 5 SECOND"""
sql """grant all on *.* to test_auth_user4"""
result1 = connect(user = 'test_auth_user4', password = '12345', url = context.config.jdbcUrl) {
result1 = connect('test_auth_user4', '12345', context.config.jdbcUrl) {
sql 'select 1'
}
sleep(6000)
sql """set password for 'test_auth_user4' = password('123')"""
result2 = connect(user = 'test_auth_user4', password = '123', url = context.config.jdbcUrl) {
result2 = connect('test_auth_user4', '123', context.config.jdbcUrl) {
sql 'select 1'
}
sleep(6000)
try {
connect(user = 'test_auth_user4', password = '123', url = context.config.jdbcUrl) {}
connect('test_auth_user4', '123', context.config.jdbcUrl) {}
assertTrue(false. "should not be able to login")
} catch (Exception e) {
assertTrue(e.getMessage().contains("Your password has expired. To log in you must change it using a client that supports expired passwords."), e.getMessage())
Expand All @@ -185,19 +185,19 @@ suite("test_alter_user", "account,nonConcurrent") {
sql """drop user test_auth_user4"""
sql """create user test_auth_user4 identified by '12345'"""
sql """grant all on *.* to test_auth_user4"""
result1 = connect(user = 'test_auth_user4', password = '12345', url = context.config.jdbcUrl) {
result1 = connect('test_auth_user4', '12345', context.config.jdbcUrl) {
sql 'select 1'
}
sleep(1000)
result2 = connect(user = 'test_auth_user4', password = '12345', url = context.config.jdbcUrl) {
result2 = connect('test_auth_user4', '12345', context.config.jdbcUrl) {
sql 'select 1'
}

// 9. test user default database privileges
sql """drop user if exists test_auth_user4"""
sql """create user test_auth_user4 identified by '12345'"""
sql """grant SELECT_PRIV on regression_test.* to test_auth_user4"""
result1 = connect(user = 'test_auth_user4', password = '12345', url = context.config.jdbcUrl) {
result1 = connect('test_auth_user4', '12345', context.config.jdbcUrl) {
sql 'select 1'
sql 'use information_schema'
sql 'use mysql'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ suite("test_auth_compatibility", "account") {
GRANT SHOW_VIEW_PRIV on ${dbName}.${viewName} TO ${user}
"""

connect(user = user, password = pwd, url = context.config.jdbcUrl) {
connect(user, pwd, context.config.jdbcUrl) {
sql """USE ${dbName}"""
// auth ok, no exception
sql """SHOW CREATE TABLE ${viewName}"""
Expand Down
4 changes: 2 additions & 2 deletions regression-test/suites/account_p0/test_auth_show.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ suite("test_auth_show", "account") {

// With select priv for table, should be able to see db
sql """GRANT SELECT_PRIV ON ${dbName}.${tableName} TO ${user}"""
def result1 = connect(user=user, password="${pwd}", url=url) {
def result1 = connect(user, "${pwd}", url) {
sql """show databases like '${dbName}'"""
}
assertEquals(result1.size(), 1)
sql """REVOKE SELECT_PRIV ON ${dbName}.${tableName} FROM ${user}"""

// With show_view priv for table, should be able to see db
sql """GRANT SHOW_VIEW_PRIV ON ${dbName}.${tableName} TO ${user}"""
def result2 = connect(user=user, password="${pwd}", url=url) {
def result2 = connect(user, "${pwd}", url) {
sql """show databases like '${dbName}'"""
}
assertEquals(result2.size(), 1)
Expand Down
4 changes: 2 additions & 2 deletions regression-test/suites/account_p0/test_grant_priv.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ suite("test_grant_priv") {

// test only have select_priv, can not grant to other user
sql """grant select_priv on ${dbName}.* to ${user1}"""
connect(user=user1, password="${pwd}", url=url) {
connect(user1, "${pwd}", url) {
try {
sql """grant select_priv on ${dbName}.* to ${user2}"""
Assert.fail("can not grant to other user");
Expand All @@ -49,7 +49,7 @@ suite("test_grant_priv") {

// test both have select_priv and grant_priv , can grant to other user
sql """grant grant_priv on ${dbName}.* to ${user1}"""
connect(user=user1, password="${pwd}", url=url) {
connect(user1, "${pwd}", url) {
try {
sql """grant select_priv on ${dbName}.* to ${user2}"""
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ suite("test_grant_priv_resource") {

// test only have USAGE_PRIV, can not grant to other user
sql """grant USAGE_PRIV on RESOURCE ${resource1} to ${user1}"""
connect(user=user1, password="${pwd}", url=url) {
connect(user1, "${pwd}", url) {
try {
sql """grant USAGE_PRIV on RESOURCE ${resource1} to ${user2}"""
Assert.fail("can not grant to other user");
Expand All @@ -44,7 +44,7 @@ suite("test_grant_priv_resource") {

// test both have USAGE_PRIV and grant_priv , can grant to other user
sql """grant grant_priv on RESOURCE * to ${user1}"""
connect(user=user1, password="${pwd}", url=url) {
connect(user1, "${pwd}", url) {
try {
sql """grant USAGE_PRIV on RESOURCE ${resource1} to ${user2}"""
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ suite("test_grant_priv_workload") {

// test only have USAGE_PRIV, can not grant to other user
sql """grant USAGE_PRIV on WORKLOAD GROUP ${workload1} to ${user1}"""
connect(user=user1, password="${pwd}", url=url) {
connect(user1, "${pwd}", url) {
try {
sql """grant USAGE_PRIV on WORKLOAD GROUP ${workload1} to ${user2}"""
Assert.fail("can not grant to other user");
Expand All @@ -44,7 +44,7 @@ suite("test_grant_priv_workload") {

// test both have USAGE_PRIV and grant_priv , can grant to other user
sql """grant grant_priv on WORKLOAD GROUP ${workload1} to ${user1}"""
connect(user=user1, password="${pwd}", url=url) {
connect(user1, "${pwd}", url) {
try {
sql """grant USAGE_PRIV on WORKLOAD GROUP ${workload1} to ${user2}"""
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,41 +54,41 @@ suite("test_nereids_authentication", "query") {

def tokens = context.config.jdbcUrl.split('/')
def url=tokens[0] + "//" + tokens[2] + "/" + dbName + "?"
def result = connect(user=user, password='Doris_123456', url=url) {
def result = connect(user, 'Doris_123456', url) {
sql "SELECT * FROM ${tableName1}"
}
assertEquals(result.size(), 0)

connect(user=user, password='Doris_123456', url=url) {
connect(user, 'Doris_123456', url) {
test {
sql "SELECT * FROM ${tableName2}"
exception "denied"
}
}

connect(user=user, password='Doris_123456', url=url) {
connect(user, 'Doris_123456', url) {
test {
sql "SELECT count(*) FROM ${tableName2}"
exception "denied"
}
}

connect(user=user, password='Doris_123456', url=url) {
connect(user, 'Doris_123456', url) {
test {
sql "SELECT * FROM ${tableName1}, ${tableName2} WHERE ${tableName1}.`key` = ${tableName2}.`key`"
exception "denied"
}
}

sql "GRANT SELECT_PRIV ON internal.${dbName}.${tableName2} TO ${user}"
connect(user=user, password='Doris_123456', url=url) {
connect(user, 'Doris_123456', url) {
sql "SELECT * FROM ${tableName2}"
}
assertEquals(result.size(), 0)
connect(user=user, password='Doris_123456', url=url) {
connect(user, 'Doris_123456', url) {
sql "SELECT count(*) FROM ${tableName2}"
}
connect(user=user, password='Doris_123456', url=url) {
connect(user, 'Doris_123456', url) {
sql "SELECT * FROM ${tableName1}, ${tableName2} WHERE ${tableName1}.`key` = ${tableName2}.`key`"
}
assertEquals(result.size(), 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ suite("test_nereids_row_policy") {
}

def assertQueryResult = { size ->
def result = connect(user=user, password='123abc!@#', url=url) {
def result = connect(user, '123abc!@#', url) {
sql "SELECT * FROM ${tableName}"
}
connect(user=user, password='123abc!@#', url=url) {
connect(user, '123abc!@#', url) {
test {
sql "SELECT * FROM ${viewName}"
exception "does not have privilege for"
Expand Down
4 changes: 2 additions & 2 deletions regression-test/suites/account_p0/test_role.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ suite("test_role", "account") {
sql """GRANT SELECT_PRIV ON ${context.config.defaultDb} TO ROLE '${role}'"""
sql """GRANT SELECT_PRIV ON ${dbName} TO ROLE '${role}'"""
sql """CREATE USER '${user}' IDENTIFIED BY '${pwd}' DEFAULT ROLE '${role}'"""
def result1 = connect(user=user, password="${pwd}", url=context.config.jdbcUrl) {
def result1 = connect(user, "${pwd}", context.config.jdbcUrl) {
sql "show databases like '${dbName}'"
}
assertEquals(result1.size(), 1)

sql """REVOKE SELECT_PRIV ON ${dbName} FROM ROLE '${role}'"""
def result2 = connect(user=user, password="${pwd}", url=context.config.jdbcUrl) {
def result2 = connect(user, "${pwd}", context.config.jdbcUrl) {
sql "show databases like '${dbName}'"
}
assertEquals(result2.size(), 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ suite("test_account_management_grant_auth","p0,auth_call") {
sql """grant select_priv on regression_test to ${user}"""
sql """create database ${dbName}"""

connect(user=user, password="${pwd}", url=context.config.jdbcUrl) {
connect(user, "${pwd}", context.config.jdbcUrl) {
test {
sql """CREATE USER ${user_derive} IDENTIFIED BY '${pwd}';"""
exception "denied"
Expand All @@ -69,7 +69,7 @@ suite("test_account_management_grant_auth","p0,auth_call") {
}
}
sql """grant grant_priv on *.*.* to '${user}'"""
connect(user=user, password="${pwd}", url=context.config.jdbcUrl) {
connect(user, "${pwd}", context.config.jdbcUrl) {
sql """CREATE USER ${user_derive} IDENTIFIED BY '${pwd}';"""
sql """ALTER USER ${user_derive} IDENTIFIED BY "${pwd}";"""
sql """SET PASSWORD FOR '${user_derive}' = PASSWORD('${pwd}')"""
Expand All @@ -85,7 +85,7 @@ suite("test_account_management_grant_auth","p0,auth_call") {
}
sql """revoke grant_priv on *.*.* from '${user}'"""
sql """grant admin_priv on *.*.* to '${user}'"""
connect(user=user, password="${pwd}", url=context.config.jdbcUrl) {
connect(user, "${pwd}", context.config.jdbcUrl) {
sql """CREATE USER ${user_derive} IDENTIFIED BY '${pwd}';"""
sql """ALTER USER ${user_derive} IDENTIFIED BY "${pwd}";"""
sql """SET PASSWORD FOR '${user_derive}' = PASSWORD('${pwd}')"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ suite("test_account_management_role_auth","p0,auth_call") {
sql """create database ${dbName}"""
sql """GRANT '${role}' TO ${user};"""

connect(user=user, password="${pwd}", url=context.config.jdbcUrl) {
connect(user, "${pwd}", context.config.jdbcUrl) {
test {
sql """CREATE ROLE ${role_derive}"""
exception "denied"
Expand All @@ -60,7 +60,7 @@ suite("test_account_management_role_auth","p0,auth_call") {
}
}
sql """grant grant_priv on *.*.* to ROLE '${role}'"""
connect(user=user, password="${pwd}", url=context.config.jdbcUrl) {
connect(user, "${pwd}", context.config.jdbcUrl) {
sql """CREATE ROLE ${role_derive}"""
sql """ALTER ROLE ${role_derive} COMMENT "this is my first role";"""
sql """DROP ROLE ${role_derive}"""
Expand Down
Loading
Loading