Debian Codegraph @

mysql-test/suite/auth_sec/include/multiple_passwords.inc

raw
1 # Parameters:
2 # $auth_plugin - Authentication plugin
3 # $ssl_option - To supply extra ssl argument
4
5 --echo #-----------------------------------------------------------------------
6 --echo # Setup : Create users
7
8 --connection default
9 # Create test users
10 --eval CREATE USER arthurdent@localhost IDENTIFIED WITH '$auth_plugin' BY 'abcd'
11
12 --echo #-----------------------------------------------------------------------
13 --echo # Second password tests
14
15 ALTER USER arthurdent@localhost IDENTIFIED BY 'efgh' RETAIN CURRENT PASSWORD;
16
17 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pefgh -e "SELECT CURRENT_USER()" 2>&1
18 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT --ssl-mode=$ssl_option -uarthurdent -pefgh -e "SELECT CURRENT_USER()" 2>&1
19 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pabcd -e "SELECT CURRENT_USER()" 2>&1
20 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT --ssl-mode=$ssl_option -uarthurdent -pabcd -e "SELECT CURRENT_USER()" 2>&1
21
22 # Remove old password
23 ALTER USER arthurdent@localhost DISCARD OLD PASSWORD;
24
25 --error 1
26 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pabcd -e "SELECT CURRENT_USER()" 2>&1
27 --error 1
28 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT --ssl-mode=$ssl_option -uarthurdent -pabcd -e "SELECT CURRENT_USER()" 2>&1
29 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pefgh -e "SELECT CURRENT_USER()" 2>&1
30 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT --ssl-mode=$ssl_option -uarthurdent -pefgh -e "SELECT CURRENT_USER()" 2>&1
31
32 # Set it again
33 ALTER USER arthurdent@localhost IDENTIFIED BY 'ijkl' RETAIN CURRENT PASSWORD;
34
35 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pefgh -e "SELECT CURRENT_USER()" 2>&1
36 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT --ssl-mode=$ssl_option -uarthurdent -pefgh -e "SELECT CURRENT_USER()" 2>&1
37 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pijkl -e "SELECT CURRENT_USER()" 2>&1
38 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT --ssl-mode=$ssl_option -uarthurdent -pijkl -e "SELECT CURRENT_USER()" 2>&1
39
40 # Change current password without removing another
41 ALTER USER arthurdent@localhost IDENTIFIED BY 'mnop';
42
43 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pefgh -e "SELECT CURRENT_USER()" 2>&1
44 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT --ssl-mode=$ssl_option -uarthurdent -pefgh -e "SELECT CURRENT_USER()" 2>&1
45 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pmnop -e "SELECT CURRENT_USER()" 2>&1
46 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT --ssl-mode=$ssl_option -uarthurdent -pmnop -e "SELECT CURRENT_USER()" 2>&1
47
48 # Discard old password
49 ALTER USER arthurdent@localhost DISCARD OLD PASSWORD;
50 # Use SET PASSWORD to retain current password
51 SET PASSWORD FOR arthurdent@localhost = 'qrst' RETAIN CURRENT PASSWORD;
52
53 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pmnop -e "SELECT CURRENT_USER()" 2>&1
54 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT --ssl-mode=$ssl_option -uarthurdent -pmnop -e "SELECT CURRENT_USER()" 2>&1
55 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pqrst -e "SELECT CURRENT_USER()" 2>&1
56 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT --ssl-mode=$ssl_option -uarthurdent -pqrst -e "SELECT CURRENT_USER()" 2>&1
57
58 #Password expiry
59 ALTER USER arthurdent@localhost DISCARD OLD PASSWORD;
60 ALTER USER arthurdent@localhost IDENTIFIED BY 'abcd';
61 ALTER USER arthurdent@localhost IDENTIFIED BY 'efgh' RETAIN CURRENT PASSWORD;
62 ALTER USER arthurdent@localhost PASSWORD EXPIRE;
63
64 --error 1
65 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pabcd --connect-expired-password -e "SELECT 1" 2>&1
66 --error 1
67 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pefgh --connect-expired-password -e "SELECT 1" 2>&1
68
69 # user() function tests
70 ALTER USER arthurdent@localhost IDENTIFIED BY 'abcd';
71 GRANT APPLICATION_PASSWORD_ADMIN ON *.* TO arthurdent@localhost;
72
73 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pabcd -e "ALTER USER USER() IDENTIFIED BY 'efgh' RETAIN CURRENT PASSWORD" 2>&1
74 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pefgh -e "SELECT 1" 2>&1
75 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pabcd -e "ALTER USER USER() DISCARD OLD PASSWORD" 2>&1
76 --error 1
77 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pabcd -e "SELECT 1" 2>&1
78 --exec $MYSQL --host=127.0.0.1 -P $MASTER_MYPORT -uarthurdent -pefgh -e "SELECT 1" 2>&1
79
80 --echo #-----------------------------------------------------------------------
81 --echo # Cleanup
82
83 # Drop test users
84
85 --connection default
86 # Drop test users
87 DROP USER arthurdent@localhost;
88
89 --echo #-----------------------------------------------------------------------