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