File: validate_password_plugin.test

package info (click to toggle)
percona-xtrabackup 2.2.3-2.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 293,260 kB
  • ctags: 146,881
  • sloc: cpp: 1,051,960; ansic: 570,217; java: 54,595; perl: 53,495; pascal: 44,194; sh: 27,826; yacc: 15,314; python: 12,142; xml: 7,848; sql: 4,125; makefile: 1,459; awk: 785; lex: 758
file content (207 lines) | stat: -rw-r--r-- 8,751 bytes parent folder | download
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
--source include/not_embedded.inc
--source include/have_validate_password_plugin.inc

call mtr.add_suppression("Dictionary file not specified");
let $MYSQL_ERRMSG_BASEDIR=`select @@lc_messages_dir`;

# plugin is not installed so even 'pass' (very weak)
# is accepted as a password
CREATE USER 'base_user'@'localhost' IDENTIFIED BY 'pass';
GRANT ALL ON mysql.* TO 'user1'@'localhost' IDENTIFIED BY 'pass';

--replace_regex /\.dll/.so/
eval INSTALL PLUGIN validate_password SONAME '$VALIDATE_PASSWORD';

# test for all the three password policy
# policy: LOW, MEDIUM, STRONG

--echo # password policy LOW (which only check for password length)
--echo # default case: password length should be minimum 8

SET @@global.validate_password_policy=LOW;
--error ER_NOT_VALID_PASSWORD
CREATE USER 'user'@'localhost' IDENTIFIED BY '';
--error ER_NOT_VALID_PASSWORD
SET PASSWORD FOR 'base_user'@'localhost'= PASSWORD('aweg');
SET PASSWORD FOR 'base_user'@'localhost'= PASSWORD('password3');
SET PASSWORD FOR 'base_user'@'localhost'= PASSWORD('password');
--error ER_NOT_VALID_PASSWORD
SET PASSWORD FOR 'base_user'@'localhost'= PASSWORD('passwor');
SET @@global.validate_password_length= 12;
--error ER_NOT_VALID_PASSWORD
UPDATE mysql.user SET PASSWORD= PASSWORD('password') WHERE user='base_user';
--error ER_NOT_VALID_PASSWORD
UPDATE mysql.user SET PASSWORD= PASSWORD('afrgtyhlp98') WHERE user='base_user';
UPDATE mysql.user SET PASSWORD= PASSWORD('iuyt567nbvfA') WHERE user='base_user';
GRANT USAGE ON *.* TO 'base_user'@'localhost' IDENTIFIED BY 'password1234';
SET @@global.validate_password_mixed_case_count= 0;
SET @@global.validate_password_number_count= 0;
SET @@global.validate_password_special_char_count= 0;
SET @@global.validate_password_length= 0;
UPDATE mysql.user SET PASSWORD= PASSWORD('') WHERE user='base_user';
UPDATE mysql.user SET PASSWORD= PASSWORD('p') WHERE user='base_user';
UPDATE mysql.user SET PASSWORD= PASSWORD('password') WHERE user='base_user';
SET @@global.validate_password_length= -2;
-- Error ER_WRONG_TYPE_FOR_VAR
SET @@global.validate_password_length= 3.5;

# test to check maximum value of password_length

SET @@global.validate_password_length= 2147483647;
SET @@global.validate_password_length= 2147483648;
PREPARE stmt1 FROM 'UPDATE mysql.user SET PASSWORD=(?) where USER = ?';
SET @a = REPEAT('a',2147483647);
SET @b = 'user@localhost';
EXECUTE stmt1 USING @a,@b;
DEALLOCATE PREPARE stmt1;
SET @@global.validate_password_length= 4294967295;
SET @@global.validate_password_length= 8;
PREPARE stmt1 FROM 'UPDATE mysql.user SET PASSWORD=(?) where USER = ?';
SET @a = REPEAT('a',1048576);
SET @b = 'user@localhost';
EXECUTE stmt1 USING @a,@b;
DEALLOCATE PREPARE stmt1;

--echo # password policy MEDIUM (check for mixed_case, digits, special_chars)
--echo # default case : atleast 1 mixed_case, 1 digit, 1 special_char

SET @@global.validate_password_mixed_case_count= 1;
SET @@global.validate_password_number_count= 1;
SET @@global.validate_password_special_char_count= 1;
SET @@global.validate_password_policy=MEDIUM;
SET @@global.validate_password_number_count= 0;
CREATE USER 'user'@'localhost' IDENTIFIED BY 'aedfoiASE$%';
--error ER_NOT_VALID_PASSWORD
SET PASSWORD FOR 'user'@'localhost'= PASSWORD('foiuiuytd78');
SET PASSWORD FOR 'user'@'localhost'= PASSWORD('pasretryFRGH&^98');
SET @@global.validate_password_mixed_case_count= 0;
--error ER_NOT_VALID_PASSWORD
CREATE USER 'user'@'localhost' IDENTIFIED BY 'aedSWEhjui';
SET PASSWORD FOR 'user'@'localhost'= PASSWORD('gruyuHOIU&*(');
SET PASSWORD FOR 'user'@'localhost'= PASSWORD('passwor0987**&');
SET @@global.validate_password_special_char_count= 0;
SET PASSWORD FOR 'base_user'@'localhost'= PASSWORD('piufgklol');
SET PASSWORD FOR 'base_user'@'localhost'= PASSWORD('password1A#');
SET @@global.validate_password_special_char_count= 1;
SET @@global.validate_password_number_count= 1;
SET @@global.validate_password_mixed_case_count= 1;
--error ER_NOT_VALID_PASSWORD
SET PASSWORD FOR 'base_user'@'localhost'= PASSWORD('erftuiik');
SET PASSWORD FOR 'base_user'@'localhost'= PASSWORD('password1A#');
SET @@global.validate_password_number_count= 2;
--error ER_NOT_VALID_PASSWORD
UPDATE mysql.user SET PASSWORD= PASSWORD('password1A#') WHERE user='base_user';
UPDATE mysql.user SET PASSWORD= PASSWORD('password12A#') WHERE user='base_user';
SET @@global.validate_password_number_count= 1;
SET @@global.validate_password_mixed_case_count= 2;
--error ER_NOT_VALID_PASSWORD
UPDATE mysql.user SET PASSWORD= PASSWORD('password1A#') WHERE user='base_user';
UPDATE mysql.user SET PASSWORD= PASSWORD('password1AB#') WHERE user='base_user';
SET @@global.validate_password_mixed_case_count= 1;
SET @@global.validate_password_special_char_count= 2;
--error ER_NOT_VALID_PASSWORD
GRANT USAGE ON *.* TO 'base_user'@'localhost' IDENTIFIED BY 'password1A#';
GRANT USAGE ON *.* TO 'base_user'@'localhost' IDENTIFIED BY 'password1A#$';
SET @@global.validate_password_special_char_count= 1;

--echo # No dictionary file present, no dictionary check
SET @@global.validate_password_policy=STRONG;
SET PASSWORD FOR 'base_user'@'localhost'= PASSWORD('password1A#');
UPDATE mysql.user SET PASSWORD= PASSWORD('password1A#') WHERE user='base_user';

UNINSTALL PLUGIN validate_password;

--echo # restarting the server with dictionary file.

# Write file to make mysql-test-run.pl wait for the server to stop
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect

# Request shutdown
-- send_shutdown

# Call script that will poll the server waiting for it to disapear
-- source include/wait_until_disconnected.inc

--echo # Restart server.

--exec echo "restart:--loose-validate_password_dictionary_file=$MYSQL_ERRMSG_BASEDIR/dictionary.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect

# Turn on reconnect
--enable_reconnect

# Call script that will poll the server waiting for it to be back online again
--source include/wait_until_connected_again.inc

# Turn off reconnect again
--disable_reconnect

--replace_regex /\.dll/.so/
eval INSTALL PLUGIN validate_password SONAME '$VALIDATE_PASSWORD';

--echo # password policy strong
--echo # default_file : dictionary.txt

# file should contain 1 word per line
# error if substring of password is a dictionary word

SET @@global.validate_password_policy=STRONG;
--error ER_NOT_VALID_PASSWORD
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
--error ER_NOT_VALID_PASSWORD
SET PASSWORD FOR 'base_user'@'localhost'= PASSWORD('password1A#');
--error ER_NOT_VALID_PASSWORD
UPDATE mysql.user SET PASSWORD= PASSWORD('pass12345A#') WHERE user='base_user';
--error ER_NOT_VALID_PASSWORD
UPDATE mysql.user SET PASSWORD= PASSWORD('pass0000A#') WHERE user='base_user';
GRANT USAGE ON *.* TO 'base_user'@'localhost' IDENTIFIED BY 'PA00wrd!#';

--echo # test for password_validate_strength function

--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
SELECT VALIDATE_PASSWORD_STRENGTH('password', 0);
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
SELECT VALIDATE_PASSWORD_STRENGTH();
SELECT VALIDATE_PASSWORD_STRENGTH('');
SELECT VALIDATE_PASSWORD_STRENGTH('pass');
SELECT VALIDATE_PASSWORD_STRENGTH('password');
SELECT VALIDATE_PASSWORD_STRENGTH('password0000');
SELECT VALIDATE_PASSWORD_STRENGTH('password1A#');
SELECT VALIDATE_PASSWORD_STRENGTH('PA12wrd!#');
SELECT VALIDATE_PASSWORD_STRENGTH('PA00wrd!#');

# Test for multibyte character set that have greater size when converted
# from uppercase to lowercase.
SET NAMES 'ujis';
SELECT VALIDATE_PASSWORD_STRENGTH('PA12wrd!#');

# default policy is set, all other plugin variables set to default
# Test to ensure that only the privileged user can access the plugin variables
SET @@global.validate_password_policy=MEDIUM;

# New connection
connect (plug_con,localhost,user1,pass);
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
SET @@global.validate_password_policy=LOW;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
SET @@global.validate_password_length= 4;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
SET @@global.validate_password_special_char_count= 0;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
SET @@global.validate_password_mixed_case_count= 0;
# user has the update/create privilege but needs to satisfy password policy
# to update/create new account 
--error ER_NOT_VALID_PASSWORD
CREATE USER 'user2'@'localhost' IDENTIFIED BY 'password';
CREATE USER 'user2'@'localhost' IDENTIFIED BY 'PA00wrd!#';
--error ER_NOT_VALID_PASSWORD
UPDATE mysql.user SET PASSWORD= PASSWORD('password') WHERE user='user2';
UPDATE mysql.user SET PASSWORD= PASSWORD('PA00wrd!#') WHERE user='user2';
DROP USER 'user2'@'localhost';
disconnect plug_con;
--source include/wait_until_disconnected.inc

connection default;
DROP USER 'base_user'@'localhost';
DROP USER 'user1'@'localhost';
DROP USER 'user'@'localhost';
UNINSTALL PLUGIN validate_password;