File: binlog_grant_alter_user.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (880 lines) | stat: -rw-r--r-- 36,180 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
################### suite/binlog/t/binlog_grant_alter_user.test ###################
# Replication Testing CREATE/ALTER/GRANT USER new syntax with New variable        #
# "log-builtin-as-identified-by-password" default value "OFF"                     #
#                                                                                 # 
# Test for WL#6409                                                                #
# created :2015-01-02                                                             #
# Modified:2015-02-04  WL#6054                                                    #
# Author  : Lalit Choudhary                                                       #
#                                                                                 #
###################################################################################

# Save the initial number of concurrent sessions
--source include/count_sessions.inc
--source include/master-slave.inc
--connection master

--echo #
--echo # WL#6409: CREATE/ALTER USER
--echo #

--echo # CREATE USER
--echo
CREATE USER user1;
query_vertical SELECT host,user,plugin
FROM mysql.user WHERE user = 'user1';

--echo
--error ER_PARSE_ERROR
CREATE USER user3@%;

# Sequence of the attributes. provide password first and auth_plugin later on
--error ER_PARSE_ERROR
CREATE USER user3@localhost BY 'auth_string' WITH 'mysql_native_password';

CREATE USER "user2"@'%';
query_vertical SELECT host,user,plugin
FROM mysql.user WHERE user='user2';

--echo
CREATE USER u1@localhost;
query_vertical SELECT user,plugin FROM mysql.user WHERE USER='u1';

CREATE USER u2@localhost IDENTIFIED BY 'auth_string' ACCOUNT LOCK;
query_vertical SELECT user,plugin FROM mysql.user WHERE USER='u2';

--echo
--error ER_PARSE_ERROR
CREATE USER user5@localhost IDENTIFIED  AS 'auth_string';

CREATE USER u3@localhost IDENTIFIED WITH 'mysql_native_password';
query_vertical SELECT user,plugin FROM mysql.user WHERE USER='u3';

CREATE USER u4@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string';
query_vertical SELECT user,plugin FROM mysql.user WHERE USER='u4';

# Testing connection
--connect(con1, localhost, u4,'auth_string')
SELECT USER();
connection default;
disconnect con1;

--echo
CREATE USER user4@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string';
query_vertical SELECT user,plugin FROM mysql.user WHERE USER='user4';
--echo
CREATE USER user6@localhost IDENTIFIED WITH 'mysql_native_password';
query_vertical SELECT user,plugin FROM mysql.user WHERE USER='user6';
--echo
CREATE USER user7@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string#%y'
                            PASSWORD EXPIRE NEVER ACCOUNT UNLOCK;
query_vertical SELECT user,plugin FROM mysql.user WHERE USER='user7';
--echo
# Testing connection
--connect(con1, localhost, user7, 'auth_string#%y')
SELECT USER();
connection default;
disconnect con1;

CREATE USER user8@localhost IDENTIFIED WITH 'mysql_native_password'
                            AS '*67092806AE91BFB6BE72DE6C7BE2B7CCA8CFA9DF';
query_vertical SELECT user,plugin FROM mysql.user WHERE USER='user8';

# Testing connection
--connect(con1, localhost, user8,'auth_string')
SELECT USER();
connection default;
disconnect con1;

# Tesing with mysql_native_password plugin.
CREATE USER tu1@localhost IDENTIFIED WITH 'mysql_native_password';
query_vertical SELECT user,plugin,password_expired,
password_expired  FROM mysql.user WHERE USER='tu1';

CREATE USER tu2@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_@13*';
query_vertical SELECT user,plugin,
password_expired FROM mysql.user WHERE USER='tu2';

--echo
CREATE USER tu3@localhost IDENTIFIED WITH 'mysql_native_password' BY '%auth_O0s-tring';
query_vertical SELECT user,plugin,password_expired
FROM mysql.user WHERE USER='tu3';

--echo

CREATE USER u5@localhost REQUIRE SSL;
query_vertical SELECT user,plugin,ssl_type
FROM mysql.user WHERE USER='u5';

CREATE USER u6@localhost IDENTIFIED BY 'auth_string' REQUIRE X509;
query_vertical SELECT user,plugin,ssl_type
FROM mysql.user WHERE USER='u6';

CREATE USER tu4@localhost IDENTIFIED WITH 'mysql_native_password' BY 'djgsj743$' REQUIRE SSL;
query_vertical SELECT user,plugin,ssl_type FROM mysql.user WHERE USER='tu4';

CREATE USER tu5@localhost IDENTIFIED WITH 'mysql_native_password' BY 'dwh@#ghd$!' REQUIRE X509;
query_vertical SELECT user,plugin,ssl_type FROM mysql.user WHERE USER='tu5';

CREATE USER u7@localhost IDENTIFIED WITH 'mysql_native_password'
            REQUIRE CIPHER 'cipher';
query_vertical SELECT user,plugin,ssl_type,ssl_cipher,
x509_issuer,x509_subject FROM mysql.user WHERE USER='u7';

CREATE USER u8@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string'
            REQUIRE ISSUER '/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=CA';
query_vertical SELECT user,plugin,ssl_type,ssl_cipher,
x509_issuer,x509_subject FROM mysql.user WHERE USER='u8';


CREATE USER u9@localhost REQUIRE SUBJECT 'sub';
query_vertical SELECT user,plugin,ssl_type,ssl_cipher,
x509_issuer,x509_subject FROM mysql.user WHERE USER='u9';

CREATE USER u10@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string#y'
            REQUIRE CIPHER "ECDHE-RSA-AES128-GCM-SHA256" AND
            SUBJECT "/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=Client"
            ISSUER "/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=CA";
query_vertical SELECT user,plugin,ssl_type,ssl_cipher,
x509_issuer,x509_subject FROM mysql.user WHERE USER='u10';

# Testing connection
--connect(con1, localhost, u10,'auth_string#y',,,,SSL)
SELECT USER();
connection default;
disconnect con1;

CREATE USER tu6@localhost IDENTIFIED WITH 'mysql_native_password' BY '#hGrt0O6'
            REQUIRE CIPHER "ECDHE-RSA-AES128-GCM-SHA256" AND
            SUBJECT "/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=Client"
            ISSUER "/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=CA"
            WITH MAX_QUERIES_PER_HOUR 2 MAX_USER_CONNECTIONS 2;
query_vertical SELECT user,plugin,ssl_type,ssl_cipher,x509_issuer,
x509_subject,max_questions,max_user_connections FROM mysql.user WHERE USER='tu6';


CREATE USER u11@localhost WITH MAX_QUERIES_PER_HOUR 2;
query_vertical SELECT user,plugin,max_questions
FROM mysql.user WHERE USER='u11';

CREATE USER u12@localhost IDENTIFIED BY 'auth_string'  WITH MAX_QUERIES_PER_HOUR 2;
query_vertical SELECT user,plugin,max_questions
FROM mysql.user WHERE USER='u12';

CREATE USER u13@localhost IDENTIFIED WITH 'mysql_native_password'
            WITH MAX_CONNECTIONS_PER_HOUR 2;
query_vertical SELECT user,plugin,max_connections
FROM mysql.user WHERE USER='u13';

CREATE USER u14@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string'
            WITH MAX_USER_CONNECTIONS 2 ACCOUNT LOCK;
query_vertical SELECT user,plugin,max_user_connections
FROM mysql.user WHERE USER='u14';

CREATE USER u15@localhost,
            u16@localhost IDENTIFIED BY 'auth_string',
            u17@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string';
query_vertical SELECT user,plugin FROM mysql.user WHERE USER='u15';
query_vertical SELECT user,plugin FROM mysql.user WHERE USER='u16';
query_vertical SELECT user,plugin FROM mysql.user WHERE USER='u17';
CREATE USER u18@localhost,
            u19@localhost IDENTIFIED BY 'auth_string',
            u20@localhost IDENTIFIED WITH 'mysql_native_password',
            u21@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string',
            u22@localhost IDENTIFIED WITH 'mysql_native_password',
            u23@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_&string'
            REQUIRE SUBJECT '/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=Client'
            WITH MAX_QUERIES_PER_HOUR 2 MAX_USER_CONNECTIONS 2 ACCOUNT UNLOCK;
query_vertical SELECT user,plugin,ssl_type,ssl_cipher,
x509_issuer,x509_subject,max_questions,max_user_connections FROM mysql.user WHERE USER='u18';
query_vertical SELECT user,plugin,ssl_type,ssl_cipher,
x509_issuer,x509_subject,max_questions,max_user_connections FROM mysql.user WHERE USER='u19';
query_vertical SELECT user,plugin,ssl_type,ssl_cipher,
x509_issuer,x509_subject,max_questions,max_user_connections FROM mysql.user WHERE USER='u20';
query_vertical SELECT user,plugin,ssl_type,ssl_cipher,
x509_issuer,x509_subject,max_questions,max_user_connections FROM mysql.user WHERE USER='u22';
query_vertical SELECT user,plugin,ssl_type,ssl_cipher,
x509_issuer,x509_subject,max_questions,max_user_connections FROM mysql.user WHERE USER='u23';

DROP USER tu1@localhost,tu2@localhost,tu3@localhost,tu4@localhost,tu5@localhost,
          tu6@localhost,user1@'%',user2@'%',user4@localhost,user6@localhost,
          user7@localhost,user8@localhost, u1@localhost,u2@localhost,u3@localhost,
          u4@localhost,u5@localhost,u6@localhost, u7@localhost, u8@localhost,
          u9@localhost, u10@localhost,u11@localhost, u12@localhost,u13@localhost,
          u14@localhost,u15@localhost,u16@localhost,u17@localhost,u18@localhost,
          u19@localhost, u20@localhost,u21@localhost,u22@localhost,u23@localhost;

--echo # ALTER USER

CREATE USER u1@localhost;
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime
FROM mysql.user WHERE USER='u1';

--echo # Its a no op
ALTER USER u1@localhost;
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime
FROM mysql.user WHERE USER='u1';

CREATE USER u2@localhost IDENTIFIED BY 'password_string';
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u2';
ALTER USER u2@localhost IDENTIFIED BY 'new_auth_string';
# Look for auth_string and password last changed field
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u2';
# Testing connection
--connect(con1, localhost, u2, new_auth_string)
SELECT USER();
connection default;
disconnect con1;
--echo
CREATE USER u3@localhost IDENTIFIED WITH 'mysql_native_password' ACCOUNT LOCK;
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u3';

ALTER USER u3@localhost IDENTIFIED WITH 'mysql_native_password'
                        AS '*67092806AE91BFB6BE72DE6C7BE2B7CCA8CFA9DF'
                        PASSWORD EXPIRE NEVER ACCOUNT UNLOCK;
# Look for plugin,auth_string and password expired field
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u3';

# Testing connection
--connect(con1, localhost, u3, 'auth_string')
SELECT USER();
connection default;
disconnect con1;

ALTER USER u3@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string';
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u3';

ALTER USER u3@localhost
           REQUIRE SUBJECT '/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=Client'
           WITH MAX_QUERIES_PER_HOUR 2 MAX_USER_CONNECTIONS 2
           PASSWORD EXPIRE NEVER;

--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u3';

CREATE USER u4@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string'
            ACCOUNT LOCK PASSWORD EXPIRE DEFAULT;
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u4';
ALTER USER u4@localhost IDENTIFIED WITH 'mysql_native_password'
           BY 'auth_string' ACCOUNT UNLOCK;
# Look for plugin,auth_string field
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u4';

CREATE USER u5@localhost REQUIRE SSL;
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u5';

ALTER USER u5@localhost IDENTIFIED WITH 'mysql_native_password';
# Look for plugin,auth_string, password expired field
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u5';

# Testing connection
--connect(con1, localhost, u5,,,,,SSL)
SET PASSWORD='new_auth_string';
SELECT USER();
connection default;
disconnect con1;

CREATE USER u6@localhost IDENTIFIED BY 'auth_string' REQUIRE X509 ACCOUNT UNLOCK ACCOUNT LOCK PASSWORD EXPIRE INTERVAL 80 DAY;
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u6';
ALTER USER u6@localhost IDENTIFIED WITH 'mysql_native_password' BY 'new_auth_string' REQUIRE SSL ACCOUNT UNLOCK;
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u6';

CREATE USER u7@localhost IDENTIFIED WITH 'mysql_native_password'
            BY 'auth_string' REQUIRE CIPHER 'ECDHE-RSA-AES128-GCM-SHA256';
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u7';
ALTER USER u7@localhost IDENTIFIED WITH 'mysql_native_password' BY 'new_auth_string'
            REQUIRE ISSUER '/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=CA' ACCOUNT UNLOCK;
# Look for plugin,auth_string, password expired, SSL type field
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u7';

# Testing connection
--connect(con1, localhost, u7,'new_auth_string',,,,SSL)
SELECT USER();
connection default;
disconnect con1;

CREATE USER u8@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string'
            REQUIRE ISSUER '/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=CA';
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u8';
ALTER USER u8@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string'
            REQUIRE CIPHER "ECDHE-RSA-AES128-GCM-SHA256";
# Look for plugin,auth_string, password expired, SSL fields
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u8';
# Testing connection
--connect(con1, localhost, u8,'auth_string',,,,SSL)
SELECT USER();
connection default;
disconnect con1;

CREATE USER tu1@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string'
            REQUIRE ISSUER 'issuer';
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='tu1';
ALTER USER tu1@localhost IDENTIFIED WITH 'mysql_native_password'
            REQUIRE CIPHER "ECDHE-RSA-AES128-GCM-SHA256";
# Look for plugin,auth_string, password expired, SSL fields
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='tu1';

CREATE USER u9@localhost REQUIRE SUBJECT 'sub';
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u9';
ALTER USER u9@localhost REQUIRE ISSUER "/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=CA";
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u9';

ALTER USER u9@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string77hg'
                        REQUIRE ISSUER "/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=CA";
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u9';

CREATE USER u10@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string'
            REQUIRE CIPHER "ECDHE-RSA-AES128-GCM-SHA256" AND
            SUBJECT "/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=Client"
            ISSUER "/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=CA";
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u10';
ALTER USER u10@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string'
            REQUIRE SSL;
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u10';

# Testing connection
--connect(con1, localhost, u10,'auth_string',,,,SSL)
SELECT USER();
connection default;
disconnect con1;

CREATE USER u11@localhost WITH MAX_QUERIES_PER_HOUR 2;
--replace_column 8 #
query_vertical SELECT user,max_questions FROM mysql.user WHERE USER='u11';
ALTER USER u11@localhost WITH MAX_QUERIES_PER_HOUR 6;
--replace_column 8 #
query_vertical SELECT user,max_questions FROM mysql.user WHERE USER='u11';

CREATE USER u12@localhost IDENTIFIED BY 'auth_string'
                          WITH MAX_QUERIES_PER_HOUR 2;
--replace_column 8 #
query_vertical SELECT user,max_questions FROM mysql.user WHERE USER='u12';
ALTER USER u12@localhost IDENTIFIED WITH 'mysql_native_password'
                         WITH MAX_QUERIES_PER_HOUR 8;
--replace_column 8 #
query_vertical SELECT user,max_questions FROM mysql.user WHERE USER='u12';

ALTER USER u12@localhost IDENTIFIED WITH 'mysql_native_password'
                         WITH MAX_QUERIES_PER_HOUR 1000;
--replace_column 8 #
query_vertical SELECT user,max_questions FROM mysql.user WHERE USER='u12';

CREATE USER u13@localhost IDENTIFIED WITH 'mysql_native_password'
                          WITH MAX_CONNECTIONS_PER_HOUR 2;
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u13';
ALTER USER u13@localhost PASSWORD EXPIRE;
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u13';

CREATE USER u14@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string'
            WITH MAX_USER_CONNECTIONS 2;
--replace_column 9 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u14';
ALTER USER u14@localhost WITH MAX_USER_CONNECTIONS 12
                         PASSWORD EXPIRE INTERVAL 365 DAY;
--replace_column 9 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u14';

CREATE USER tu2@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string'
            WITH MAX_USER_CONNECTIONS 2 ;
--replace_column 10 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,max_questions,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='tu2';
ALTER USER tu2@localhost WITH MAX_USER_CONNECTIONS 12 MAX_QUERIES_PER_HOUR 543
                         PASSWORD EXPIRE INTERVAL 365 DAY;
--replace_column 10 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,max_questions,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='tu2';

# Testing connection
--connect(con1, localhost, tu2,'auth_string')
SELECT USER();
connection default;
disconnect con1;

CREATE USER u15@localhost,
            u16@localhost IDENTIFIED WITH 'mysql_native_password',
            u17@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string';
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u15';
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u16';
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u17';
ALTER USER u15@localhost IDENTIFIED WITH 'mysql_native_password',
           u16@localhost,
           u17@localhost IDENTIFIED BY 'new_auth_string'
           PASSWORD EXPIRE DEFAULT;
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u15';
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u16';
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u17';

CREATE USER u18@localhost,
            u19@localhost IDENTIFIED BY 'auth_string',
            u20@localhost IDENTIFIED WITH 'mysql_native_password',
            u21@localhost IDENTIFIED WITH 'mysql_native_password' BY '!Y_TOdh6)',
            u22@localhost IDENTIFIED WITH 'mysql_native_password',
            u23@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_&string'
            REQUIRE SUBJECT '/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=Client'
            WITH MAX_QUERIES_PER_HOUR 2 MAX_USER_CONNECTIONS 2;
--replace_column 10 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,
max_questions,password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u18';
--replace_column 10 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,
max_questions,password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u19';
--replace_column 10 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,
max_questions,password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u20';
--replace_column 10 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,
max_questions,password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u21';
--replace_column 10 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,
max_questions,password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u22';
--replace_column 10 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,
max_questions,password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u23';

ALTER USER u18@localhost, u19@localhost,
           u20@localhost, u21@localhost,
           u22@localhost, u23@localhost
           REQUIRE SUBJECT '/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=Client'
           WITH MAX_QUERIES_PER_HOUR 2 MAX_USER_CONNECTIONS 2
           PASSWORD EXPIRE NEVER;
--replace_column 10 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,
max_questions,password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u18';
--replace_column 10 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,
max_questions,password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u19';
--replace_column 10 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,
max_questions,password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u20';
--replace_column 10 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,
max_questions,password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u21';
--replace_column 10 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,
max_questions,password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u22';
--replace_column 10 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,max_user_connections,
max_questions,password_last_changed,password_lifetime FROM mysql.user
WHERE USER='u23';

DROP USER tu1@localhost,tu2@localhost,u1@localhost, u2@localhost, u3@localhost,
          u4@localhost,u5@localhost,u6@localhost, u7@localhost, u8@localhost,
          u9@localhost,u10@localhost,u11@localhost,u12@localhost,u13@localhost,
          u14@localhost,u15@localhost,u16@localhost,u17@localhost,u18@localhost,
          u19@localhost,u20@localhost,u21@localhost,u22@localhost,u23@localhost;

--echo # ALTER USER with current user

CREATE USER u1@localhost IDENTIFIED BY 'abc';
--connect(con1, localhost, u1, abc)
SELECT USER();
connection default;
ALTER USER u1@localhost PASSWORD EXPIRE;
disconnect con1;

--connect(con1, localhost, u1, abc)
--error ER_MUST_CHANGE_PASSWORD
SELECT USER();
SET PASSWORD = 'def';
--disable_warnings
disconnect con1;
--enable_warnings

--connect(con1, localhost, u1, def)
SELECT USER();
connection default;
ALTER USER u1@localhost PASSWORD EXPIRE;
disconnect con1;

--connect(con1, localhost, u1, def)
--error ER_MUST_CHANGE_PASSWORD
SELECT USER();
# Password set to current user
--disable_ps_protocol
--error ER_PARSE_ERROR
ALTER USER IDENTIFIED BY 'npwd';
ALTER USER USER() IDENTIFIED BY 'abc';
--enable_ps_protocol
disconnect con1;

--connect(con1, localhost, u1, abc)
SELECT USER();
connection default;
ALTER USER u1@localhost PASSWORD EXPIRE;
disconnect con1;

--connect(con1, localhost, u1, abc)
--error ER_MUST_CHANGE_PASSWORD
SELECT USER();
connection default;
ALTER USER u1@localhost IDENTIFIED BY 'def';
disconnect con1;

--connect(con1, localhost, u1, def)
SELECT USER();
connection default;
DROP USER u1@localhost;
disconnect con1;

--echo # ALTER USER with current user is allowed to set only credential information

CREATE USER u1@localhost, u2@localhost IDENTIFIED BY 'abc';
GRANT ALL ON *.* TO u2@localhost;

--connect(con1, localhost, u2, abc)
--error ER_PARSE_ERROR
ALTER USER USER() IDENTIFIED WITH 'sha256_password';
--error ER_PARSE_ERROR
ALTER USER USER() IDENTIFIED BY 'def', u2@localhost PASSWORD EXPIRE;
--error ER_PARSE_ERROR
ALTER USER USER() IDENTIFIED BY 'def' PASSWORD EXPIRE;
--error ER_PARSE_ERROR
ALTER USER ;
ALTER USER u2@localhost IDENTIFIED BY 'auth_string' PASSWORD EXPIRE INTERVAL 45 DAY;
--replace_column 8 #
query_vertical SELECT user,ssl_type,ssl_cipher,x509_issuer,x509_subject,
plugin,password_expired,
password_last_changed,password_lifetime FROM mysql.user WHERE USER='u2';
connection default;
disconnect con1;
DROP USER u1@localhost, u2@localhost;

--echo # SHOW CREATE USER

CREATE USER u1@localhost;
SHOW CREATE USER u1@localhost;

CREATE USER u2@localhost IDENTIFIED BY 'auth_string';
--replace_regex /AS '(.*)' REQUIRE/AS '<non-deterministic-password-hash>' REQUIRE/
SHOW CREATE USER u2@localhost;
--echo # DDL output for SHOW CREATE USER u2@localhost and recreating user
DROP USER u2@localhost;
CREATE USER 'u2'@'localhost' IDENTIFIED WITH 'mysql_native_password'
            AS '*67092806AE91BFB6BE72DE6C7BE2B7CCA8CFA9DF' REQUIRE NONE;

--connect(con1,localhost,u2,auth_string)
SELECT USER();
connection default;
disconnect con1;
--echo

CREATE USER u3@localhost IDENTIFIED WITH 'mysql_native_password';
SHOW CREATE USER u3@localhost;

CREATE USER u4@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string';
--replace_regex /AS '(.*)' REQUIRE/AS '<non-deterministic-password-hash>' REQUIRE/
SHOW CREATE USER u4@localhost;

CREATE USER user1@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string';
--replace_regex /AS '(.*)' REQUIRE/AS '<non-deterministic-password-hash>' REQUIRE/
SHOW CREATE USER user1@localhost;

--echo

CREATE USER user2@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string';
--replace_regex /AS '(.*)' REQUIRE/AS '<non-deterministic-password-hash>' REQUIRE/
SHOW CREATE USER user2@localhost;
--echo
CREATE USER u5@localhost REQUIRE SSL;
SHOW CREATE USER u5@localhost;

CREATE USER u6@localhost IDENTIFIED BY 'auth_string' REQUIRE X509;
--replace_regex /AS '(.*)' REQUIRE/AS '<non-deterministic-password-hash>' REQUIRE/
SHOW CREATE USER u6@localhost;

CREATE USER u7@localhost IDENTIFIED WITH 'mysql_native_password'
            REQUIRE CIPHER 'cipher';
SHOW CREATE USER u7@localhost;

CREATE USER u8@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string'
            REQUIRE ISSUER 'issuer';
--replace_regex /AS '(.*)' REQUIRE/AS '<non-deterministic-password-hash>' REQUIRE/
SHOW CREATE USER u8@localhost;

CREATE USER u9@localhost REQUIRE SUBJECT 'sub';
SHOW CREATE USER u9@localhost;

CREATE USER u10@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string'
            REQUIRE CIPHER "ECDHE-RSA-AES128-GCM-SHA256" AND
            SUBJECT "/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=Client"
            ISSUER "/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=CA";
--replace_regex /AS '(.*)' REQUIRE/AS '<non-deterministic-password-hash>' REQUIRE/
SHOW CREATE USER u10@localhost;

CREATE USER u11@localhost WITH MAX_QUERIES_PER_HOUR 2;
SHOW CREATE USER u11@localhost;

CREATE USER u12@localhost IDENTIFIED BY 'auth_string'  WITH MAX_QUERIES_PER_HOUR 2;
--replace_regex /AS '(.*)' REQUIRE/AS '<non-deterministic-password-hash>' REQUIRE/
SHOW CREATE USER u12@localhost;

CREATE USER u13@localhost IDENTIFIED WITH 'mysql_native_password'
            WITH MAX_CONNECTIONS_PER_HOUR 2;
SHOW CREATE USER u13@localhost;

CREATE USER u14@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string'
            WITH MAX_USER_CONNECTIONS 2;
--replace_regex /AS '(.*)' REQUIRE/AS '<non-deterministic-password-hash>' REQUIRE/
SHOW CREATE USER u14@localhost;

CREATE USER u15@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string'
            REQUIRE SUBJECT '/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=Client'
            ISSUER "/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=CA"
            CIPHER 'cipher' WITH MAX_QUERIES_PER_HOUR 2 MAX_USER_CONNECTIONS 2;
--replace_regex /AS '(.*)' REQUIRE/AS '<non-deterministic-password-hash>' REQUIRE/
SHOW CREATE USER u15@localhost;

DROP USER user1@localhost,u1@localhost,u2@localhost,u3@localhost,u4@localhost,
          u5@localhost,u6@localhost, u7@localhost, u8@localhost,u9@localhost,
          u10@localhost,u11@localhost,u12@localhost,u13@localhost,u14@localhost,
          u15@localhost;
--echo
--echo # GRANT
--echo
CREATE USER user1@localhost IDENTIFIED WITH 'mysql_native_password'
            AS '*67092806AE91BFB6BE72DE6C7BE2B7CCA8CFA9DF'
            REQUIRE SUBJECT '/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=Client'
            ISSUER "/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=CA"
            WITH MAX_CONNECTIONS_PER_HOUR 1000 MAX_USER_CONNECTIONS 20
                 MAX_QUERIES_PER_HOUR 60 MAX_UPDATES_PER_HOUR 100;

query_vertical SELECT user,plugin,ssl_type,ssl_cipher,
x509_issuer,x509_subject,max_user_connections,
max_questions,max_updates,max_connections FROM mysql.user
WHERE USER='user1';

--echo
GRANT SELECT ON *.* TO user1@localhost;
GRANT SELECT,INSERT,UPDATE ON mysql.* TO user1@localhost;

--echo
SHOW GRANTS FOR user1@localhost;
--echo
REVOKE INSERT,UPDATE ON mysql.* FROM user1@localhost;

SHOW GRANTS FOR user1@localhost;
--echo

GRANT SELECT,INSERT,UPDATE ON *.* TO user2@localhost;
ALTER USER user2@localhost IDENTIFIED BY 'admin'
      REQUIRE SUBJECT '/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=Client'
      ISSUER "/C=SE/ST=Stockholm/L=Stockholm/O=Oracle/OU=MySQL/CN=CA"
      WITH MAX_CONNECTIONS_PER_HOUR 1000 MAX_USER_CONNECTIONS 20
           MAX_QUERIES_PER_HOUR 60 MAX_UPDATES_PER_HOUR 100;

query_vertical SELECT user,plugin,ssl_type,ssl_cipher,
x509_issuer,x509_subject,max_user_connections,
max_questions,max_updates,max_connections FROM mysql.user WHERE USER='user2';

CREATE USER user3@localhost IDENTIFIED BY 'auth_string';

--echo # Cleanup
DROP USER user1@localhost,user2@localhost,user3@localhost;

--echo
--echo # SET PASSWORD Tests
--echo
CREATE USER user1@localhost IDENTIFIED BY 'auth_string';
CREATE USER user2@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string1';

SET PASSWORD FOR user1@localhost='auth_xyz@';
SET PASSWORD FOR user2@localhost='gd636@gj';

--echo
CREATE USER user4@localhost;
ALTER USER user4@localhost PASSWORD EXPIRE;
SET PASSWORD FOR user4@localhost='';

CREATE USER user3@localhost IDENTIFIED  BY 'auth_string';
CREATE USER user5@localhost IDENTIFIED WITH 'mysql_native_password' BY 'auth_string1';

SET PASSWORD FOR user3@localhost='auth_abc';
GRANT SELECT ON *.* TO user3@localhost;

--connect(con1, localhost, user3, auth_abc)
SELECT USER();
SET PASSWORD='auth_xyz';
query_vertical SELECT user,plugin,ssl_type,password_expired,
password_lifetime FROM mysql.user WHERE user='user3';
connection default;
disconnect con1;

--echo
SET PASSWORD FOR user4@localhost='auth_xyz';
query_vertical SELECT user,plugin,ssl_type,password_expired,
password_lifetime FROM mysql.user WHERE user='user4';
--echo
SET PASSWORD FOR user5@localhost='auth_dhsga5';
query_vertical SELECT user,plugin,ssl_type,password_expired,
password_lifetime FROM mysql.user WHERE user='user5';

--echo
CREATE USER user6@localhost IDENTIFIED BY 'auth_string';
query_vertical SELECT user,plugin,password_expired
FROM mysql.user WHERE USER='user6';

ALTER USER user6@localhost IDENTIFIED WITH 'mysql_native_password';
query_vertical SELECT user,plugin,password_expired
FROM mysql.user WHERE USER='user6';

SET PASSWORD FOR user6@localhost='plaintext_password';
query_vertical SELECT user,plugin
FROM mysql.user WHERE USER='user6';

# Testing connection
--connect(con1, localhost, user6, 'plaintext_password')
SELECT USER();
connection default;
disconnect con1;

--echo
--echo # Cleanup
DROP USER user1@localhost,user2@localhost,user3@localhost,
          user4@localhost,user5@localhost,user6@localhost;

--source include/sync_slave_sql_with_master.inc
--echo [On Slave]
--let $mask_user_password_events=1
--let $mask_grant_as_events=1
--source include/show_binlog_events.inc
--let $mask_user_password_events=0
--source include/rpl_end.inc

--echo
--echo End of 5.7 tests!
--echo