Skip to content

Commit

Permalink
(test)[auth]Add call auth module case
Browse files Browse the repository at this point in the history
  • Loading branch information
zfr9527 committed Oct 14, 2024
1 parent 49e123c commit 5df8e1c
Show file tree
Hide file tree
Showing 66 changed files with 5,422 additions and 0 deletions.
17 changes: 17 additions & 0 deletions regression-test/data/auth_call/multi_load_cm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
3 changes: 3 additions & 0 deletions regression-test/data/auth_call/multi_load_data_1.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1,111
2,222
3,333
2 changes: 2 additions & 0 deletions regression-test/data/auth_call/multi_load_data_2.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
4,444
5,555
2 changes: 2 additions & 0 deletions regression-test/data/auth_call/routine_load_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1,2
3,5
17 changes: 17 additions & 0 deletions regression-test/data/auth_call/stream_load_cm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
3 changes: 3 additions & 0 deletions regression-test/data/auth_call/stream_load_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1,111
2,222
3,333
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,28 @@ class Suite implements GroovyInterceptable {
Assert.assertEquals("SUCCESS", status)
}

void waitingMVTaskFinishedByMvName(String dbName, String tableName) {
Thread.sleep(2000)
String showTasks = "SHOW ALTER TABLE MATERIALIZED VIEW from ${dbName} where TableName='${tableName}' ORDER BY CreateTime ASC"
String status = "NULL"
List<List<Object>> result
long startTime = System.currentTimeMillis()
long timeoutTimestamp = startTime + 5 * 60 * 1000 // 5 min
do {
result = sql(showTasks)
logger.info("result: " + result.toString())
if (!result.isEmpty()) {
status = result.last().get(8)
}
logger.info("The state of ${showTasks} is ${status}")
Thread.sleep(1000);
} while (timeoutTimestamp > System.currentTimeMillis() && (status != 'FINISHED'))
if (status != "FINISHED") {
logger.info("status is not success")
}
Assert.assertEquals("FINISHED", status)
}

void waitingPartitionIsExpected(String tableName, String partitionName, boolean expectedStatus) {
Thread.sleep(2000);
String showPartitions = "show partitions from ${tableName}"
Expand Down
2 changes: 2 additions & 0 deletions regression-test/suites/auth_call/data/multi_table_csv.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test_dml_multi_routine_load_auth_tb1|49|2023-08-08|FALSE|\N|16275|-2144851675|-2303421957908954634|-46526938720058765|-13141.142578|-686632233.230200|229942298.0|-152553823.0|2022-09-01 00:16:01|2023-03-25|2022-09-07 14:59:03|s||yvuILR2iNxfe8RRml|{"student": true, "name": "Alice", "grade": 9, "subjects": ["math", "science", "history"]}|true|1|2|3|4|5|6.0|7.0|888888888|999999999|2023-08-24|2023-08-24 12:00:00|2023-08-24|2023-08-24 12:00:00|我能吞下玻璃而不伤身体|我能吞下玻璃而不伤身体|我能吞下玻璃而不伤身体|{}
test_dml_multi_routine_load_auth_tb2|49|2023-08-08|FALSE|\N|16275|-2144851675|-2303421957908954634|-46526938720058765|-13141.142578|-686632233.230200|229942298.0|-152553823.0|2022-09-01 00:16:01|2023-03-25|2022-09-07 14:59:03|s||yvuILR2iNxfe8RRml|{"student": true, "name": "Alice", "grade": 9, "subjects": ["math", "science", "history"]}|true|1|2|3|4|5|6.0|7.0|888888888|999999999|2023-08-24|2023-08-24 12:00:00|2023-08-24|2023-08-24 12:00:00|我能吞下玻璃而不伤身体|我能吞下玻璃而不伤身体|我能吞下玻璃而不伤身体|{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
CREATE TABLE test_dml_multi_routine_load_auth_tb1
(
k00 INT NOT NULL,
k01 DATE NOT NULL,
k02 BOOLEAN NULL,
k03 TINYINT NULL,
k04 SMALLINT NULL,
k05 INT NULL,
k06 BIGINT NULL,
k07 LARGEINT NULL,
k08 FLOAT NULL,
k09 DOUBLE NULL,
k10 DECIMAL(9,1) NULL,
k11 DECIMALV3(9,1) NULL,
k12 DATETIME NULL,
k13 DATEV2 NULL,
k14 DATETIMEV2 NULL,
k15 CHAR NULL,
k16 VARCHAR NULL,
k17 STRING NULL,
k18 JSON NULL,

INDEX idx_inverted_k104 (`k05`) USING INVERTED,
INDEX idx_inverted_k110 (`k11`) USING INVERTED,
INDEX idx_inverted_k113 (`k13`) USING INVERTED,
INDEX idx_inverted_k114 (`k14`) USING INVERTED,
INDEX idx_inverted_k117 (`k17`) USING INVERTED PROPERTIES("parser" = "english"),
INDEX idx_ngrambf_k115 (`k15`) USING NGRAM_BF PROPERTIES("gram_size"="3", "bf_size"="256"),
INDEX idx_ngrambf_k116 (`k16`) USING NGRAM_BF PROPERTIES("gram_size"="3", "bf_size"="256"),
INDEX idx_ngrambf_k117 (`k17`) USING NGRAM_BF PROPERTIES("gram_size"="3", "bf_size"="256"),

INDEX idx_bitmap_k104 (`k02`) USING BITMAP

)
DUPLICATE KEY(k00)
PARTITION BY RANGE(k01)
(
PARTITION p1 VALUES [('2023-08-01'), ('2023-08-11')),
PARTITION p2 VALUES [('2023-08-11'), ('2023-08-21')),
PARTITION p3 VALUES [('2023-08-21'), ('2023-09-01'))
)
DISTRIBUTED BY HASH(k00) BUCKETS 32
PROPERTIES (
"bloom_filter_columns"="k05",
"replication_num" = "1"
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
CREATE TABLE test_dml_multi_routine_load_auth_tb2
(
k00 INT NOT NULL,
k01 DATE NOT NULL,
k02 BOOLEAN NULL,
k03 TINYINT NULL,
k04 SMALLINT NULL,
k05 INT NULL,
k06 BIGINT NULL,
k07 LARGEINT NULL,
k08 FLOAT NULL,
k09 DOUBLE NULL,
k10 DECIMAL(9,1) NULL,
k11 DECIMALV3(9,1) NULL,
k12 DATETIME NULL,
k13 DATEV2 NULL,
k14 DATETIMEV2 NULL,
k15 CHAR NULL,
k16 VARCHAR NULL,
k17 STRING NULL,
k18 JSON NULL,

INDEX idx_inverted_k104 (`k05`) USING INVERTED,
INDEX idx_inverted_k110 (`k11`) USING INVERTED,
INDEX idx_inverted_k113 (`k13`) USING INVERTED,
INDEX idx_inverted_k114 (`k14`) USING INVERTED,
INDEX idx_inverted_k117 (`k17`) USING INVERTED PROPERTIES("parser" = "english"),
INDEX idx_ngrambf_k115 (`k15`) USING NGRAM_BF PROPERTIES("gram_size"="3", "bf_size"="256"),
INDEX idx_ngrambf_k116 (`k16`) USING NGRAM_BF PROPERTIES("gram_size"="3", "bf_size"="256"),
INDEX idx_ngrambf_k117 (`k17`) USING NGRAM_BF PROPERTIES("gram_size"="3", "bf_size"="256"),

INDEX idx_bitmap_k104 (`k02`) USING BITMAP

)
DUPLICATE KEY(k00)
PARTITION BY RANGE(k01)
(
PARTITION p1 VALUES [('2023-08-01'), ('2023-08-11')),
PARTITION p2 VALUES [('2023-08-11'), ('2023-08-21')),
PARTITION p3 VALUES [('2023-08-21'), ('2023-09-01'))
)
DISTRIBUTED BY HASH(k00) BUCKETS 32
PROPERTIES (
"bloom_filter_columns"="k05",
"replication_num" = "1"
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import org.junit.Assert;
import org.codehaus.groovy.runtime.IOGroovyMethods

suite("test_account_management_grant_auth","p0,auth_call") {

String user = 'test_account_management_grant_auth_user'
String pwd = 'C123_567p'
String dbName = 'test_account_management_grant_auth_db'
String user_derive = 'test_account_management_grant_user_derive_role'
String role_derive = 'test_account_management_grant_role_derive_role'

try_sql("DROP USER ${user}")
try_sql("DROP USER ${user_derive}")
try_sql """drop database if exists ${dbName}"""

sql """CREATE USER '${user}' IDENTIFIED BY '${pwd}'"""
sql """grant select_priv on regression_test to ${user}"""
sql """create database ${dbName}"""

connect(user=user, password="${pwd}", url=context.config.jdbcUrl) {
test {
sql """CREATE USER ${user_derive} IDENTIFIED BY '${pwd}';"""
exception "denied"
}
test {
sql """ALTER USER ${user_derive} IDENTIFIED BY "${pwd}";"""
exception "denied"
}
test {
sql """SET PASSWORD FOR '${user_derive}' = PASSWORD('${pwd}')"""
exception "denied"
}
test {
sql """SET PROPERTY FOR '${user_derive}' 'max_user_connections' = '1000';"""
exception "denied"
}
test {
sql """DROP user ${user_derive}"""
exception "denied"
}
test {
sql """SET LDAP_ADMIN_PASSWORD = PASSWORD('${pwd}')"""
exception "denied"
}
}
sql """grant grant_priv on *.*.* to '${user}'"""
connect(user=user, password="${pwd}", url=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}')"""
test {
sql """SET PROPERTY FOR '${user_derive}' 'max_user_connections' = '1000';"""
exception "denied"
}
sql """DROP user ${user_derive}"""
test {
sql """SET LDAP_ADMIN_PASSWORD = PASSWORD('${pwd}')"""
exception "denied"
}
}
sql """revoke grant_priv on *.*.* from '${user}'"""
sql """grant admin_priv on *.*.* to '${user}'"""
connect(user=user, password="${pwd}", url=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}')"""
sql """SET PROPERTY FOR '${user_derive}' 'max_user_connections' = '1000';"""
sql """DROP user ${user_derive}"""
sql """SET LDAP_ADMIN_PASSWORD = PASSWORD('${pwd}')"""
}

sql """drop database if exists ${dbName}"""
try_sql("DROP USER ${user}")
try_sql("DROP role ${user_derive}")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import org.junit.Assert;
import org.codehaus.groovy.runtime.IOGroovyMethods

suite("test_account_management_role_auth","p0,auth_call") {

String user = 'test_account_management_role_auth_user'
String role = 'test_account_management_role_auth_role'
String pwd = 'C123_567p'
String dbName = 'test_account_management_role_auth_db'

String role_derive = 'test_account_management_role_auth_derive_role'

try_sql("DROP USER ${user}")
try_sql("DROP role ${role}")
try_sql("DROP role ${role_derive}")
try_sql """drop database if exists ${dbName}"""
sql """CREATE ROLE ${role}"""
sql """CREATE USER '${user}' IDENTIFIED BY '${pwd}'"""
sql """grant select_priv on regression_test to ${user}"""
sql """create database ${dbName}"""
sql """GRANT '${role}' TO ${user};"""

connect(user=user, password="${pwd}", url=context.config.jdbcUrl) {
test {
sql """CREATE ROLE ${role_derive}"""
exception "denied"
}
test {
sql """ALTER ROLE ${role_derive} COMMENT "this is my first role";"""
exception "denied"
}
test {
sql """DROP ROLE ${role_derive}"""
exception "denied"
}
}
sql """grant grant_priv on *.*.* to ROLE '${role}'"""
connect(user=user, password="${pwd}", url=context.config.jdbcUrl) {
sql """CREATE ROLE ${role_derive}"""
sql """ALTER ROLE ${role_derive} COMMENT "this is my first role";"""
sql """DROP ROLE ${role_derive}"""
}

sql """drop database if exists ${dbName}"""
try_sql("DROP USER ${user}")
try_sql("DROP role ${role}")
try_sql("DROP role ${role_derive}")
}
Loading

0 comments on commit 5df8e1c

Please sign in to comment.