|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +suite("test_lower_case_meta_with_lower_table_conf_auth", "p0,external,doris,external_docker,external_docker_doris") { |
| 19 | + |
| 20 | + String jdbcUrl = context.config.jdbcUrl |
| 21 | + String jdbcUser = context.config.jdbcUser |
| 22 | + String jdbcPassword = context.config.jdbcPassword |
| 23 | + String s3_endpoint = getS3Endpoint() |
| 24 | + String bucket = getS3BucketName() |
| 25 | + String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar" |
| 26 | + |
| 27 | + String user = "test_catalog_lower_case_auth_user" |
| 28 | + String pwd = 'C123_567p' |
| 29 | + |
| 30 | + sql """drop database if exists internal.external_test_lower_with_conf_auth; """ |
| 31 | + sql """drop database if exists internal.external_test_UPPER_with_conf_auth; """ |
| 32 | + sql """create database if not exists internal.external_test_lower_with_conf_auth; """ |
| 33 | + sql """create database if not exists internal.external_test_UPPER_with_conf_auth; """ |
| 34 | + sql """create table if not exists internal.external_test_lower_with_conf_auth.lower_with_conf |
| 35 | + (id int, name varchar(20)) |
| 36 | + distributed by hash(id) buckets 10 |
| 37 | + properties('replication_num' = '1'); |
| 38 | + """ |
| 39 | + |
| 40 | + sql """create table if not exists internal.external_test_lower_with_conf_auth.UPPER_with_conf |
| 41 | + (id int, name varchar(20)) |
| 42 | + distributed by hash(id) buckets 10 |
| 43 | + properties('replication_num' = '1'); |
| 44 | + """ |
| 45 | + |
| 46 | + sql """create table if not exists internal.external_test_UPPER_with_conf_auth.lower_with_conf |
| 47 | + (id int, name varchar(20)) |
| 48 | + distributed by hash(id) buckets 10 |
| 49 | + properties('replication_num' = '1'); |
| 50 | + """ |
| 51 | + |
| 52 | + sql """create table if not exists internal.external_test_UPPER_with_conf_auth.UPPER_with_conf |
| 53 | + (id int, name varchar(20)) |
| 54 | + distributed by hash(id) buckets 10 |
| 55 | + properties('replication_num' = '1'); |
| 56 | + """ |
| 57 | + |
| 58 | + sql """insert into internal.external_test_lower_with_conf_auth.lower_with_conf values(1, 'lower')""" |
| 59 | + sql """insert into internal.external_test_lower_with_conf_auth.UPPER_with_conf values(1, 'UPPER')""" |
| 60 | + |
| 61 | + sql """insert into internal.external_test_UPPER_with_conf_auth.lower_with_conf values(1, 'lower')""" |
| 62 | + sql """insert into internal.external_test_UPPER_with_conf_auth.UPPER_with_conf values(1, 'UPPER')""" |
| 63 | + |
| 64 | + // |
| 65 | + sql """drop catalog if exists test_lower_false_with_conf0_auth """ |
| 66 | + |
| 67 | + sql """ CREATE CATALOG `test_lower_false_with_conf0_auth` PROPERTIES ( |
| 68 | + "user" = "${jdbcUser}", |
| 69 | + "type" = "jdbc", |
| 70 | + "password" = "${jdbcPassword}", |
| 71 | + "jdbc_url" = "${jdbcUrl}", |
| 72 | + "driver_url" = "${driver_url}", |
| 73 | + "driver_class" = "com.mysql.cj.jdbc.Driver", |
| 74 | + "only_specified_database" = "true", |
| 75 | + "include_database_list" = "external_test_lower_with_conf_auth,external_test_UPPER_with_conf_auth", |
| 76 | + "lower_case_meta_names" = "false" |
| 77 | + )""" |
| 78 | + |
| 79 | + |
| 80 | + sql """ show tables from test_lower_false_with_conf0_auth.external_test_lower_with_conf_auth;""" |
| 81 | + sql """ show tables from test_lower_false_with_conf0_auth.external_test_UPPER_with_conf_auth;""" |
| 82 | + |
| 83 | + try_sql("DROP USER ${user}") |
| 84 | + sql """CREATE USER '${user}' IDENTIFIED BY '${pwd}'""" |
| 85 | + if (isCloudMode()) { |
| 86 | + def clusters = sql " SHOW CLUSTERS; " |
| 87 | + assertTrue(!clusters.isEmpty()) |
| 88 | + def validCluster = clusters[0][0] |
| 89 | + sql """GRANT USAGE_PRIV ON CLUSTER ${validCluster} TO ${user}"""; |
| 90 | + } |
| 91 | + |
| 92 | + sql """grant select_priv on regression_test to ${user}""" |
| 93 | + |
| 94 | + sql """grant select_priv on test_lower_false_with_conf0_auth.external_test_lower_with_conf_auth.lower_with_conf to ${user}""" |
| 95 | + sql """grant select_priv on test_lower_false_with_conf0_auth.external_test_lower_with_conf_auth.UPPER_with_conf to ${user}""" |
| 96 | + sql """grant select_priv on test_lower_false_with_conf0_auth.external_test_UPPER_with_conf_auth.lower_with_conf to ${user}""" |
| 97 | + sql """grant select_priv on test_lower_false_with_conf0_auth.external_test_UPPER_with_conf_auth.UPPER_with_conf to ${user}""" |
| 98 | + |
| 99 | + // db |
| 100 | + connect(user,"${pwd}", context.config.jdbcUrl) { |
| 101 | + def showDbRes = sql """show databases from test_lower_false_with_conf0_auth;""" |
| 102 | + logger.info("showDbRes: " + showDbRes.toString()) |
| 103 | + assertTrue(showDbRes.toString().contains("external_test_lower_with_conf_auth")) |
| 104 | + assertTrue(showDbRes.toString().contains("external_test_UPPER_with_conf_auth")) |
| 105 | + } |
| 106 | + |
| 107 | + // table |
| 108 | + connect(user,"${pwd}", context.config.jdbcUrl) { |
| 109 | + def showTableRes = sql """show tables from test_lower_false_with_conf0_auth.external_test_lower_with_conf_auth;""" |
| 110 | + logger.info("showTableRes: " + showTableRes.toString()) |
| 111 | + assertTrue(showTableRes.toString().contains("lower_with_conf")) |
| 112 | + assertTrue(showTableRes.toString().contains("UPPER_with_conf")) |
| 113 | + } |
| 114 | + |
| 115 | + sql """ drop catalog if exists test_lower_true_with_conf0_auth """ |
| 116 | + sql """ CREATE CATALOG `test_lower_true_with_conf0_auth` PROPERTIES ( |
| 117 | + "user" = "${jdbcUser}", |
| 118 | + "type" = "jdbc", |
| 119 | + "password" = "${jdbcPassword}", |
| 120 | + "jdbc_url" = "${jdbcUrl}", |
| 121 | + "driver_url" = "${driver_url}", |
| 122 | + "driver_class" = "com.mysql.cj.jdbc.Driver", |
| 123 | + "only_specified_database" = "true", |
| 124 | + "include_database_list" = "external_test_lower_with_conf_auth,external_test_UPPER_with_conf_auth", |
| 125 | + "lower_case_meta_names" = "true" |
| 126 | + )""" |
| 127 | + |
| 128 | + sql """ show tables from test_lower_true_with_conf0_auth.external_test_lower_with_conf_auth;""" |
| 129 | + sql """ show tables from test_lower_true_with_conf0_auth.external_test_upper_with_conf_auth;""" |
| 130 | + |
| 131 | + try_sql("DROP USER ${user}") |
| 132 | + sql """CREATE USER '${user}' IDENTIFIED BY '${pwd}'""" |
| 133 | + if (isCloudMode()) { |
| 134 | + def clusters = sql " SHOW CLUSTERS; " |
| 135 | + assertTrue(!clusters.isEmpty()) |
| 136 | + def validCluster = clusters[0][0] |
| 137 | + sql """GRANT USAGE_PRIV ON CLUSTER ${validCluster} TO ${user}"""; |
| 138 | + } |
| 139 | + |
| 140 | + sql """grant select_priv on regression_test to ${user}""" |
| 141 | + |
| 142 | + sql """grant select_priv on test_lower_true_with_conf0_auth.external_test_lower_with_conf_auth.lower_with_conf to ${user}""" |
| 143 | + sql """grant select_priv on test_lower_true_with_conf0_auth.external_test_lower_with_conf_auth.upper_with_conf to ${user}""" |
| 144 | + sql """grant select_priv on test_lower_true_with_conf0_auth.external_test_upper_with_conf_auth.lower_with_conf to ${user}""" |
| 145 | + sql """grant select_priv on test_lower_true_with_conf0_auth.external_test_upper_with_conf_auth.upper_with_conf to ${user}""" |
| 146 | + |
| 147 | + // db |
| 148 | + connect(user,"${pwd}", context.config.jdbcUrl) { |
| 149 | + def showDbRes = sql """show databases from test_lower_true_with_conf0_auth;""" |
| 150 | + logger.info("showDbRes: " + showDbRes.toString()) |
| 151 | + assertTrue(showDbRes.toString().contains("external_test_lower_with_conf_auth")) |
| 152 | + assertTrue(showDbRes.toString().contains("external_test_upper_with_conf_auth")) |
| 153 | + } |
| 154 | + |
| 155 | + // table |
| 156 | + connect(user,"${pwd}", context.config.jdbcUrl) { |
| 157 | + def showTableRes = sql """show tables from test_lower_true_with_conf0_auth.external_test_lower_with_conf_auth;""" |
| 158 | + logger.info("showTableRes: " + showTableRes.toString()) |
| 159 | + assertTrue(showTableRes.toString().contains("lower_with_conf")) |
| 160 | + assertTrue(showTableRes.toString().contains("upper_with_conf")) |
| 161 | + } |
| 162 | + |
| 163 | + sql """ drop catalog if exists test_lower_true_with_conf0_auth """ |
| 164 | + |
| 165 | + |
| 166 | + try_sql("DROP USER ${user}") |
| 167 | + |
| 168 | + sql """drop database if exists internal.external_test_lower_with_conf_auth; """ |
| 169 | +} |
0 commit comments