| 1 |
# |
| 2 |
## Preamble |
| 3 |
# |
| 4 |
# |
| 5 |
## Testcase prepare |
| 6 |
# |
| 7 |
call mtr.add_suppression("Plugin mysqlx reported: '.*: Unsuccessful login attempt"); |
| 8 |
CREATE DATABASE xdb; |
| 9 |
CREATE DATABASE ydb; |
| 10 |
CREATE USER 'user_with_access_to_xdb'@'%'; |
| 11 |
CREATE USER 'user_with_access_to_ydb'@'%'; |
| 12 |
GRANT SELECT ON xdb.* TO 'user_with_access_to_xdb'@'%'; |
| 13 |
GRANT SELECT ON ydb.* TO 'user_with_access_to_ydb'@'%'; |
| 14 |
# |
| 15 |
## Testcase execute |
| 16 |
# |
| 17 |
# |
| 18 |
## Test group 1. |
| 19 |
## |
| 20 |
## Authenticate using plain X Protocol flows to schema that: |
| 21 |
## |
| 22 |
## * account has permissions |
| 23 |
## * account has not permissions |
| 24 |
## * account has permissions still db-doesn't exist |
| 25 |
# |
| 26 |
connecting... |
| 27 |
active session is now 'non_root_user' |
| 28 |
Login OK |
| 29 |
closing session non_root_user |
| 30 |
Mysqlx.Ok { |
| 31 |
msg: "bye!" |
| 32 |
} |
| 33 |
switched to session default |
| 34 |
connecting... |
| 35 |
active session is now 'non_root_user' |
| 36 |
Got expected error: Access denied for user 'user_with_access_to_ydb'@'%' to database 'xdb' (code 1044) |
| 37 |
aborting session non_root_user |
| 38 |
switched to session default |
| 39 |
connecting... |
| 40 |
active session is now 'root_user' |
| 41 |
Got expected error: Unknown database 'non_existing_schema' (code 1049) |
| 42 |
aborting session root_user |
| 43 |
switched to session default |
| 44 |
Mysqlx.Ok { |
| 45 |
msg: "bye!" |
| 46 |
} |
| 47 |
# |
| 48 |
## Test group 2. |
| 49 |
## |
| 50 |
## Authenticate using an account which has permissions |
| 51 |
## to selected schema. |
| 52 |
# |
| 53 |
|
| 54 |
# Using MySQL client |
| 55 |
# Checking if requested schema was selected. |
| 56 |
IF(DATABASE()='xdb','Success','Failure') |
| 57 |
Success |
| 58 |
|
| 59 |
# Using mysqlxtest |
| 60 |
# Checking if requested schema was selected. |
| 61 |
RUN SELECT IF(DATABASE()='xdb','Success','Failure') |
| 62 |
IF(DATABASE()='xdb','Success','Failure') |
| 63 |
Success |
| 64 |
0 rows affected |
| 65 |
Mysqlx.Ok { |
| 66 |
msg: "bye!" |
| 67 |
} |
| 68 |
ok |
| 69 |
# |
| 70 |
## Test group 3. |
| 71 |
## |
| 72 |
## Authenticate using an account which has not permissions |
| 73 |
## to selected schema. |
| 74 |
# |
| 75 |
|
| 76 |
# Using MySQL client |
| 77 |
# Checking if requested schema was selected. |
| 78 |
EXPECTED_ERROR_CODE(42000): Access denied for user 'user_with_access_to_xdb'@'%' to database 'ydb' |
| 79 |
|
| 80 |
# Using mysqlxtest |
| 81 |
# Checking if requested schema was selected. |
| 82 |
in main, line 0:ERROR: Access denied for user 'user_with_access_to_xdb'@'%' to database 'ydb' (EXPECTED_ERROR_CODE) |
| 83 |
not ok |
| 84 |
# |
| 85 |
## Test group 4. |
| 86 |
## |
| 87 |
## Authenticate using an valid account to non existing |
| 88 |
## schema. |
| 89 |
# |
| 90 |
|
| 91 |
# Using MySQL client |
| 92 |
# Checking if requested schema was selected. |
| 93 |
EXPECTED_ERROR_CODE(42000): Unknown database 'non_existing_schema' |
| 94 |
|
| 95 |
# Using mysqlxtest |
| 96 |
# Checking if requested schema was selected. |
| 97 |
in main, line 0:ERROR: Unknown database 'non_existing_schema' (EXPECTED_ERROR_CODE) |
| 98 |
not ok |
| 99 |
# |
| 100 |
## Cleanup |
| 101 |
# |
| 102 |
DROP USER 'user_with_access_to_xdb'@'%'; |
| 103 |
DROP USER 'user_with_access_to_ydb'@'%'; |
| 104 |
DROP DATABASE xdb; |
| 105 |
DROP DATABASE ydb; |