| 1 |
## Test cases for authorization plugins |
| 2 |
|
| 3 |
--source include/xplugin_preamble.inc |
| 4 |
--source include/xplugin_create_user.inc |
| 5 |
|
| 6 |
|
| 7 |
# |
| 8 |
## Setup |
| 9 |
# |
| 10 |
|
| 11 |
call mtr.add_suppression("Maximum number of authentication attempts reached"); |
| 12 |
call mtr.add_suppression("Access denied for user .*"); |
| 13 |
|
| 14 |
--write_file $MYSQL_TMP_DIR/auth_seq.xpl |
| 15 |
-->import connection_auth_mechanism_memory_helpers.macro |
| 16 |
-->import connection.macro |
| 17 |
|
| 18 |
-->echo # |
| 19 |
-->echo ## Try to authenticate two times, last one succesfull |
| 20 |
-->echo # |
| 21 |
newsession seq -; |
| 22 |
|
| 23 |
callmacro Verify_its_xprotocol_connection; |
| 24 |
callmacro Enable_ssl_on_xprotocol_and_transmision_layer; |
| 25 |
|
| 26 |
expecterror ER_ACCESS_DENIED_ERROR; |
| 27 |
login xuser_native native test sha256_memory; |
| 28 |
|
| 29 |
login xuser_native native test plain; |
| 30 |
closesession; |
| 31 |
|
| 32 |
|
| 33 |
-->echo # |
| 34 |
-->echo ## 1. User must be able to perform authentication sequence with different mechanism |
| 35 |
-->echo ## |
| 36 |
-->echo ## * Try to authenticate three times, last one succesfull |
| 37 |
-->echo ## |
| 38 |
-->echo ## Requirements: PROTO1 |
| 39 |
-->echo # |
| 40 |
-->echo |
| 41 |
|
| 42 |
newsession seq -; |
| 43 |
callmacro Verify_its_xprotocol_connection; |
| 44 |
|
| 45 |
callmacro Enable_ssl_on_xprotocol_and_transmision_layer; |
| 46 |
|
| 47 |
expecterror ER_ACCESS_DENIED_ERROR; |
| 48 |
login xuser_sha256 sha256 test sha256_memory; |
| 49 |
|
| 50 |
expecterror ER_ACCESS_DENIED_ERROR; |
| 51 |
login xuser_sha256 sha256 test mysql41; |
| 52 |
|
| 53 |
login xuser_sha256 sha256 test plain; |
| 54 |
closesession; |
| 55 |
|
| 56 |
|
| 57 |
-->echo # |
| 58 |
-->echo ## 2. Server must disconnect user that tries too many authentications |
| 59 |
-->echo ## |
| 60 |
-->echo ## * Try to authenticate three times, after last error connection is disconnected |
| 61 |
-->echo ## |
| 62 |
-->echo ## Requirements: PROTO2 |
| 63 |
-->echo # |
| 64 |
-->echo |
| 65 |
|
| 66 |
newsession seq -; |
| 67 |
|
| 68 |
callmacro Verify_its_xprotocol_connection; |
| 69 |
callmacro Enable_ssl_on_xprotocol_and_transmision_layer; |
| 70 |
|
| 71 |
expecterror ER_ACCESS_DENIED_ERROR; |
| 72 |
login xuser_cache2 wrong_pass test sha256_memory; |
| 73 |
|
| 74 |
expecterror ER_ACCESS_DENIED_ERROR; |
| 75 |
login xuser_cache2 wrong_pass test mysql41; |
| 76 |
|
| 77 |
expecterror ER_ACCESS_DENIED_ERROR; |
| 78 |
login xuser_cache2 wrong_pass test plain; |
| 79 |
peerdisc 30000 30000; |
| 80 |
|
| 81 |
|
| 82 |
-->echo |
| 83 |
-->echo ####################################################################### |
| 84 |
-->echo ## 3. After succesfull authentication, user must be able to reset session and use |
| 85 |
-->echo ## authentication sequence |
| 86 |
-->echo ## |
| 87 |
-->echo ## * Establish a session, reset it, try to do the sequence ending succesful |
| 88 |
-->echo ## * Establish a session, reset it, try to do the sequence ending with failure |
| 89 |
-->echo ## |
| 90 |
-->echo ## Requirements: PROTO3 |
| 91 |
-->echo # |
| 92 |
-->echo |
| 93 |
-->echo ####################################################################### |
| 94 |
-->echo # Sequence succesfull |
| 95 |
newsession seq -; |
| 96 |
callmacro Verify_its_xprotocol_connection; |
| 97 |
callmacro Enable_ssl_on_xprotocol_and_transmision_layer; |
| 98 |
login xuser_sha256 sha256 test sha256_memory; |
| 99 |
|
| 100 |
Mysqlx.Session.Reset { |
| 101 |
} |
| 102 |
recvtype Mysqlx.Ok; |
| 103 |
|
| 104 |
expecterror ER_ACCESS_DENIED_ERROR; |
| 105 |
login xuser_sha256 sha256 test mysql41; |
| 106 |
|
| 107 |
login xuser_sha256 sha256 test sha256_memory; |
| 108 |
|
| 109 |
closesession; |
| 110 |
|
| 111 |
-->echo |
| 112 |
-->echo ####################################################################### |
| 113 |
-->echo # Sequence failed |
| 114 |
newsession seq -; |
| 115 |
callmacro Verify_its_xprotocol_connection; |
| 116 |
callmacro Enable_ssl_on_xprotocol_and_transmision_layer; |
| 117 |
login xuser_sha256 sha256 test sha256_memory; |
| 118 |
|
| 119 |
Mysqlx.Session.Reset { |
| 120 |
} |
| 121 |
recvtype Mysqlx.Ok; |
| 122 |
|
| 123 |
expecterror ER_ACCESS_DENIED_ERROR; |
| 124 |
login xuser_sha256 wrong_pass test mysql41; |
| 125 |
|
| 126 |
expecterror ER_ACCESS_DENIED_ERROR; |
| 127 |
login xuser_sha256 wrong_pass test sha256_memory; |
| 128 |
|
| 129 |
expecterror ER_ACCESS_DENIED_ERROR; |
| 130 |
login xuser_sha256 wrong_pass test plain; |
| 131 |
|
| 132 |
peerdisc 30000 30000; |
| 133 |
|
| 134 |
EOF |
| 135 |
|
| 136 |
--write_file $MYSQL_TMP_DIR/auth_errors.xpl |
| 137 |
-->import connection.macro |
| 138 |
callmacro Verify_its_xprotocol_connection; |
| 139 |
|
| 140 |
expecterror ER_ACCESS_DENIED_ERROR; |
| 141 |
login locked_user pass test sha256_memory; |
| 142 |
|
| 143 |
expecterror ER_ACCESS_DENIED_ERROR; |
| 144 |
login locked_user pass test mysql41; |
| 145 |
|
| 146 |
EOF |
| 147 |
|
| 148 |
# |
| 149 |
## Error handling part |
| 150 |
# |
| 151 |
|
| 152 |
CREATE USER user_to_lock@localhost IDENTIFIED WITH 'caching_sha2_password' BY 'xxx'; |
| 153 |
GRANT ALL ON *.* TO user_to_lock@localhost; |
| 154 |
|
| 155 |
# Cache user password |
| 156 |
exec $MYSQLXTEST -u user_to_lock -p "xxx" --ssl-mode=required --execute "select 1"; |
| 157 |
|
| 158 |
ALTER USER user_to_lock@localhost ACCOUNT LOCK; |
| 159 |
|
| 160 |
# Use mysqlxclient library that is going to choose first error from the sequence |
| 161 |
|
| 162 |
exec $MYSQLXTEST -u user_to_lock -p "xxx" --ssl-mode=DISABLED --cached-auth --mysql41-auth --expect-error ER_ACCOUNT_HAS_BEEN_LOCKED; |
| 163 |
|
| 164 |
# Use raw protocol message and show that first error in the sequence is ACCOUNT_LOCKED |
| 165 |
|
| 166 |
exec $MYSQLXTEST -u user_to_lock -p "xxx" --no-auth --file=$MYSQL_TMP_DIR/auth_errors.xpl 2>&1; |
| 167 |
|
| 168 |
# |
| 169 |
## Authentication sequence part |
| 170 |
# |
| 171 |
|
| 172 |
--let $MYSQLXTEST=$MYSQLXTEST -ux_root --ssl-cipher='ECDHE-RSA-AES128-GCM-SHA256' |
| 173 |
|
| 174 |
--source ../include/create_mysql_accounts_for_xplugin_tests.inc |
| 175 |
|
| 176 |
|
| 177 |
exec $MYSQLXTEST --file=$MYSQL_TMP_DIR/auth_seq.xpl 2>&1; |
| 178 |
|
| 179 |
# |
| 180 |
## Postamble |
| 181 |
# |
| 182 |
--source ../include/xplugin_cleanup.inc |
| 183 |
--source ../include/remove_mysql_accounts_for_xplugin_tests.inc |
| 184 |
DROP USER user_to_lock@localhost; |