|
| 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_revoke_role", "account") { |
| 19 | + def role= 'revoke_test_role' |
| 20 | + def user = 'revoke_test_user' |
| 21 | + def dbName = 'revoke_test_db' |
| 22 | + def pwd = 'revoke_test_pwd' |
| 23 | + |
| 24 | + try_sql("DROP ROLE ${role}") |
| 25 | + try_sql("DROP USER ${user}") |
| 26 | + try_sql("DROP ROLE ${role}") |
| 27 | + sql """DROP DATABASE IF EXISTS ${dbName}""" |
| 28 | + sql """CREATE DATABASE ${dbName}""" |
| 29 | + |
| 30 | + sql """CREATE ROLE ${role}""" |
| 31 | + sql """CREATE USER ${user} IDENTIFIED BY '${pwd}'""" |
| 32 | + |
| 33 | + sql """GRANT SELECT_PRIV ON ${dbName}.* TO ROLE '${role}'""" |
| 34 | + sql """GRANT '${role}' TO ${user}""" |
| 35 | + |
| 36 | + def result = sql """ SHOW GRANTS FOR ${user} """ |
| 37 | + assertEquals(result.size(), 1) |
| 38 | + assertTrue(result[0][5].contains("internal.default_cluster:${dbName}: Select_priv")) |
| 39 | + |
| 40 | + sql """REVOKE '${role}' from ${user}""" |
| 41 | + result = sql """ SHOW GRANTS FOR ${user} """ |
| 42 | + assertEquals(result.size(), 1) |
| 43 | + assertFalse(result[0][5].contains("internal.default_cluster:${dbName}: Select_priv")) |
| 44 | + |
| 45 | + sql """DROP USER ${user}""" |
| 46 | + sql """DROP ROLE ${role}""" |
| 47 | + sql """DROP DATABASE ${dbName}""" |
| 48 | +} |
| 49 | + |
0 commit comments