| 1 |
## Password expired handling |
| 2 |
|
| 3 |
## Preamble |
| 4 |
--source include/xplugin_preamble.inc |
| 5 |
--source include/xplugin_create_user.inc |
| 6 |
## Test starts here |
| 7 |
SELECT password_last_changed into @passwordchanged from mysql.user where host='localhost' and user='x_root'; |
| 8 |
create user foo@localhost; |
| 9 |
alter user foo@localhost password expire; |
| 10 |
create user xplugin@localhost identified by 'xplugin'; |
| 11 |
grant all on *.* to xplugin@localhost; |
| 12 |
alter user xplugin@localhost password expire; |
| 13 |
|
| 14 |
## |
| 15 |
--echo |
| 16 |
--echo Test: Expired password with no support for sandbox mode (should fail) |
| 17 |
--write_file $MYSQL_TMP_DIR/connection_expire.xpl |
| 18 |
-->import connection.macro |
| 19 |
-->callmacro Verify_its_xprotocol_connection |
| 20 |
|
| 21 |
-->expecterror ER_MUST_CHANGE_PASSWORD_LOGIN |
| 22 |
-->login foo |
| 23 |
EOF |
| 24 |
--exec $MYSQLXTEST -hlocalhost --no-auth --file=$MYSQL_TMP_DIR/connection_expire.xpl 2>&1 |
| 25 |
--remove_file $MYSQL_TMP_DIR/connection_expire.xpl |
| 26 |
|
| 27 |
### |
| 28 |
--echo |
| 29 |
--echo Test: Expired password with support for sandbox mode (should succeed) |
| 30 |
--write_file $MYSQL_TMP_DIR/connection_expire.xpl |
| 31 |
-->import connection.macro |
| 32 |
-->callmacro Verify_its_xprotocol_connection |
| 33 |
|
| 34 |
Mysqlx.Connection.CapabilitiesSet { |
| 35 |
capabilities { |
| 36 |
capabilities { |
| 37 |
name: "client.pwd_expire_ok" |
| 38 |
value { |
| 39 |
type: SCALAR |
| 40 |
scalar { |
| 41 |
type: V_BOOL |
| 42 |
v_bool: true |
| 43 |
} |
| 44 |
} |
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 |
# OK |
| 49 |
-->recv |
| 50 |
|
| 51 |
-->login foo |
| 52 |
EOF |
| 53 |
--exec $MYSQLXTEST -hlocalhost --no-auth --file=$MYSQL_TMP_DIR/connection_expire.xpl 2>&1 |
| 54 |
|
| 55 |
--write_file $MYSQL_TMP_DIR/connection_expire_x_root.xpl |
| 56 |
-->import connection.macro |
| 57 |
-->callmacro Verify_its_xprotocol_connection |
| 58 |
Mysqlx.Connection.CapabilitiesSet { |
| 59 |
capabilities { |
| 60 |
capabilities { |
| 61 |
name: "client.pwd_expire_ok" |
| 62 |
value { |
| 63 |
type: SCALAR |
| 64 |
scalar { |
| 65 |
type: V_BOOL |
| 66 |
v_bool: true |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
# OK |
| 73 |
-->recv |
| 74 |
|
| 75 |
-->login x_root |
| 76 |
EOF |
| 77 |
|
| 78 |
--write_file $MYSQL_TMP_DIR/connection_expire_x_root_wrongpwd.xpl |
| 79 |
-->import connection.macro |
| 80 |
-->callmacro Verify_its_xprotocol_connection |
| 81 |
Mysqlx.Connection.CapabilitiesSet { |
| 82 |
capabilities { |
| 83 |
capabilities { |
| 84 |
name: "client.pwd_expire_ok" |
| 85 |
value { |
| 86 |
type: SCALAR |
| 87 |
scalar { |
| 88 |
type: V_BOOL |
| 89 |
v_bool: true |
| 90 |
} |
| 91 |
} |
| 92 |
} |
| 93 |
} |
| 94 |
} |
| 95 |
-->recv |
| 96 |
|
| 97 |
-->expecterror ER_ACCESS_DENIED_ERROR |
| 98 |
-->login x_root x_root1 |
| 99 |
EOF |
| 100 |
|
| 101 |
--write_file $MYSQL_TMP_DIR/connection_expire_user.xpl |
| 102 |
-->expecterror %EXPECT_ERROR% |
| 103 |
-->sql |
| 104 |
select user(),current_user(); |
| 105 |
-->endsql |
| 106 |
EOF |
| 107 |
|
| 108 |
|
| 109 |
--write_file $MYSQL_TMP_DIR/connection_expire_user_xplugin.xpl |
| 110 |
-->stmtsql select user(),current_user(); |
| 111 |
-->expecterror %EXPECT_ERROR% |
| 112 |
-->recvresult |
| 113 |
|
| 114 |
-->stmtsql create database xplugin; |
| 115 |
-->expecterror %EXPECT_ERROR% |
| 116 |
-->recvresult |
| 117 |
|
| 118 |
-->sql |
| 119 |
set password = 'xplugin'; |
| 120 |
create database xplugin; |
| 121 |
drop database xplugin; |
| 122 |
select user(),current_user(); |
| 123 |
alter user xplugin@localhost password expire; |
| 124 |
-->endsql |
| 125 |
EOF |
| 126 |
|
| 127 |
|
| 128 |
--write_file $MYSQL_TMP_DIR/connection_expect_expired_user_xplugin.xpl |
| 129 |
-->expecterror ER_MUST_CHANGE_PASSWORD_LOGIN |
| 130 |
-->newsession bla xplugin xplugin |
| 131 |
EOF |
| 132 |
|
| 133 |
|
| 134 |
--write_file $MYSQL_TMP_DIR/connection_expire_user_xplugin_collection.xpl |
| 135 |
Mysqlx.Sql.StmtExecute { |
| 136 |
stmt: "create database xplugin;" |
| 137 |
} |
| 138 |
-->recvtype Mysqlx.Error |
| 139 |
|
| 140 |
-->stmtadmin create_collection {"schema":"xplugin" ,"name":"table2"} |
| 141 |
-->expecterror %EXPECT_ERROR% |
| 142 |
-->recvresult |
| 143 |
EOF |
| 144 |
|
| 145 |
--write_file $MYSQL_TMP_DIR/connection_expire_empty.xpl |
| 146 |
-->echo Empty |
| 147 |
EOF |
| 148 |
|
| 149 |
|
| 150 |
--echo Test: try connecting with non-x_root user when its password expird and x_root user password expired,expect password expired notice |
| 151 |
alter user x_root@localhost password expire; |
| 152 |
--exec $MYSQLXTEST --expect-error ER_MUST_CHANGE_PASSWORD_LOGIN -ufoo --file $MYSQL_TMP_DIR/connection_expire_empty.xpl 2>&1 |
| 153 |
|
| 154 |
--echo Test: try connecting with Expired password using x_root user and expect password expire notice |
| 155 |
--exec $MYSQLXTEST -hlocalhost --no-auth --file=$MYSQL_TMP_DIR/connection_expire_x_root.xpl 2>&1 |
| 156 |
|
| 157 |
--echo Test: try connecting with non-x_root user when its password expird and x_root user password expired,expect password expired notice |
| 158 |
--exec $MYSQLXTEST -hlocalhost --no-auth --file=$MYSQL_TMP_DIR/connection_expire.xpl 2>&1 |
| 159 |
|
| 160 |
--echo Test: try connecting with x_root user whose password expired with wrong password and expect invalid user or password error |
| 161 |
--exec $MYSQLXTEST -hlocalhost --no-auth --file=$MYSQL_TMP_DIR/connection_expire_x_root_wrongpwd.xpl 2>&1 |
| 162 |
|
| 163 |
##try login with password expired user when server started with disconnect_on_expired_password=off option |
| 164 |
set password for x_root@localhost = ''; |
| 165 |
let $restart_parameters = restart: --disconnect_on_expired_password=off; |
| 166 |
--source include/restart_mysqld.inc |
| 167 |
--echo Test: expect expired Notice for connection |
| 168 |
--exec $MYSQLXTEST -ufoo -v%EXPECT_ERROR%=ER_MUST_CHANGE_PASSWORD --file=$MYSQL_TMP_DIR/connection_expire_user.xpl 2>&1 |
| 169 |
|
| 170 |
##try login with password expired user when server started with skip-disconnect_on_expired_password option |
| 171 |
set password for x_root@localhost = ''; |
| 172 |
let $restart_parameters = restart: --skip-disconnect_on_expired_password; |
| 173 |
--source include/restart_mysqld.inc |
| 174 |
--echo Test: expect expired Notice for connection |
| 175 |
--exec $MYSQLXTEST -ufoo -v%EXPECT_ERROR%=ER_MUST_CHANGE_PASSWORD --file=$MYSQL_TMP_DIR/connection_expire_user.xpl 2>&1 |
| 176 |
|
| 177 |
###try execute statements with password exipired user once connected,connect should be successful with --skip-disconnect_on_expired_password |
| 178 |
--exec $MYSQLXTEST -uxplugin -pxplugin -v%EXPECT_ERROR%=ER_MUST_CHANGE_PASSWORD --file=$MYSQL_TMP_DIR/connection_expire_user_xplugin.xpl 2>&1 |
| 179 |
|
| 180 |
###try execute statements with password exipired user once connected,connect should be successful with --disconnect_on_expired_password and statement execution should be failed until password reset |
| 181 |
let $restart_parameters = restart: --disconnect_on_expired_password; |
| 182 |
--source include/restart_mysqld.inc |
| 183 |
--exec $MYSQLXTEST --connect-expired-password -uxplugin -pxplugin -v%EXPECT_ERROR%=ER_MUST_CHANGE_PASSWORD --file=$MYSQL_TMP_DIR/connection_expire_user_xplugin.xpl 2>&1 |
| 184 |
|
| 185 |
## Connect with expired password without advertising connect on expired (should get kicked out) |
| 186 |
--exec $MYSQLXTEST --no-auth --file=$MYSQL_TMP_DIR/connection_expect_expired_user_xplugin.xpl 2>&1 |
| 187 |
|
| 188 |
##try executing xplugin collection with password expired user,expect error |
| 189 |
--exec $MYSQLXTEST --connect-expired-password -uxplugin -pxplugin -v%EXPECT_ERROR%=ER_MUST_CHANGE_PASSWORD --file=$MYSQL_TMP_DIR/connection_expire_user_xplugin_collection.xpl 2>&1 |
| 190 |
|
| 191 |
|
| 192 |
## Cleanup |
| 193 |
drop user foo@localhost; |
| 194 |
drop user xplugin@localhost; |
| 195 |
update mysql.user set password_last_changed = @passwordchanged where host = 'localhost' and user='x_root'; |
| 196 |
flush privileges; |
| 197 |
--source ../include/xplugin_cleanup.inc |
| 198 |
|