@@ -73,9 +73,11 @@ mod add {
73
73
async fn test_add_user ( ) -> common_exception:: Result < ( ) > {
74
74
let test_user_name = "test_user" ;
75
75
let test_password = "test_password" ;
76
+ let test_hostname = "localhost" ;
76
77
let auth_type = AuthType :: Sha256 ;
77
78
let user_info = UserInfo :: new (
78
79
test_user_name. to_string ( ) ,
80
+ test_hostname. to_string ( ) ,
79
81
Vec :: from ( test_password) ,
80
82
auth_type. clone ( ) ,
81
83
) ;
@@ -131,6 +133,7 @@ mod add {
131
133
132
134
let user_info = UserInfo :: new (
133
135
test_user_name. to_string ( ) ,
136
+ test_hostname. to_string ( ) ,
134
137
Vec :: from ( test_password) ,
135
138
auth_type. clone ( ) ,
136
139
) ;
@@ -161,6 +164,7 @@ mod add {
161
164
let user_mgr = UserMgr :: new ( kv, "tenant1" ) ;
162
165
let user_info = UserInfo :: new (
163
166
test_user_name. to_string ( ) ,
167
+ test_hostname. to_string ( ) ,
164
168
Vec :: from ( test_password) ,
165
169
auth_type,
166
170
) ;
@@ -184,10 +188,12 @@ mod get {
184
188
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
185
189
async fn test_get_user_seq_match ( ) -> common_exception:: Result < ( ) > {
186
190
let test_user_name = "test" ;
191
+ let test_host_name = "localhost" ;
187
192
let test_key = format ! ( "__fd_users/tenant1/{}" , test_user_name) ;
188
193
189
194
let user_info = UserInfo :: new (
190
195
test_user_name. to_string ( ) ,
196
+ test_host_name. to_string ( ) ,
191
197
Vec :: from ( "pass" ) ,
192
198
AuthType :: Sha256 ,
193
199
) ;
@@ -214,10 +220,12 @@ mod get {
214
220
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
215
221
async fn test_get_user_do_not_care_seq ( ) -> common_exception:: Result < ( ) > {
216
222
let test_user_name = "test" ;
223
+ let test_host_name = "localhost" ;
217
224
let test_key = format ! ( "__fd_users/tenant1/{}" , test_user_name) ;
218
225
219
226
let user_info = UserInfo :: new (
220
227
test_user_name. to_string ( ) ,
228
+ test_host_name. to_string ( ) ,
221
229
Vec :: from ( "pass" ) ,
222
230
AuthType :: Sha256 ,
223
231
) ;
@@ -316,17 +324,21 @@ mod get_users {
316
324
317
325
type FakeKeys = Vec < ( String , SeqV < Vec < u8 > > ) > ;
318
326
type UserInfos = Vec < SeqV < UserInfo > > ;
327
+
319
328
fn prepare ( ) -> common_exception:: Result < ( FakeKeys , UserInfos ) > {
320
329
let mut names = vec ! [ ] ;
330
+ let mut host_names = vec ! [ ] ;
321
331
let mut keys = vec ! [ ] ;
322
332
let mut res = vec ! [ ] ;
323
333
let mut user_infos = vec ! [ ] ;
324
334
for i in 0 ..9 {
325
335
let name = format ! ( "test_user_{}" , i) ;
326
336
names. push ( name. clone ( ) ) ;
337
+ let host_name = format ! ( "test_host_name_{}" , i) ;
338
+ host_names. push ( host_name. clone ( ) ) ;
327
339
let key = format ! ( "{}/{}" , "tenant1" , name) ;
328
340
keys. push ( key) ;
329
- let user_info = UserInfo :: new ( name, Vec :: from ( "pass" ) , AuthType :: Sha256 ) ;
341
+ let user_info = UserInfo :: new ( name, host_name , Vec :: from ( "pass" ) , AuthType :: Sha256 ) ;
330
342
res. push ( (
331
343
"fake_key" . to_string ( ) ,
332
344
SeqV :: new ( i, serde_json:: to_vec ( & user_info) ?) ,
@@ -389,7 +401,6 @@ mod get_users {
389
401
}
390
402
391
403
mod drop {
392
-
393
404
use super :: * ;
394
405
395
406
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
@@ -447,6 +458,7 @@ mod update {
447
458
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
448
459
async fn test_update_user_normal_partial_update ( ) -> common_exception:: Result < ( ) > {
449
460
let test_user_name = "name" ;
461
+ let test_host_name = "localhost" ;
450
462
let test_key = format ! ( "__fd_users/tenant1/{}" , test_user_name) ;
451
463
let test_seq = None ;
452
464
@@ -455,6 +467,7 @@ mod update {
455
467
456
468
let user_info = UserInfo :: new (
457
469
test_user_name. to_string ( ) ,
470
+ test_host_name. to_string ( ) ,
458
471
Vec :: from ( old_pass) ,
459
472
old_auth_type,
460
473
) ;
@@ -479,6 +492,7 @@ mod update {
479
492
let new_pass = "new pass" ;
480
493
let new_user_info = UserInfo :: new (
481
494
test_user_name. to_string ( ) ,
495
+ test_host_name. to_string ( ) ,
482
496
Vec :: from ( new_pass) ,
483
497
AuthType :: DoubleSha1 ,
484
498
) ;
@@ -501,6 +515,7 @@ mod update {
501
515
502
516
let res = user_mgr. update_user (
503
517
test_user_name. to_string ( ) ,
518
+ Some ( new_user_info. host_name ) ,
504
519
Some ( new_user_info. password ) ,
505
520
None ,
506
521
test_seq,
@@ -513,6 +528,7 @@ mod update {
513
528
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
514
529
async fn test_update_user_normal_full_update ( ) -> common_exception:: Result < ( ) > {
515
530
let test_user_name = "name" ;
531
+ let test_host_name = "localhost" ;
516
532
let test_key = format ! ( "__fd_users/tenant1/{}" , test_user_name) ;
517
533
let test_seq = None ;
518
534
@@ -524,6 +540,7 @@ mod update {
524
540
525
541
let new_user_info = UserInfo :: new (
526
542
test_user_name. to_string ( ) ,
543
+ test_host_name. to_string ( ) ,
527
544
Vec :: from ( new_pass) ,
528
545
new_auth_type. clone ( ) ,
529
546
) ;
@@ -547,6 +564,7 @@ mod update {
547
564
548
565
let res = user_mgr. update_user (
549
566
test_user_name. to_string ( ) ,
567
+ Some ( test_host_name. to_string ( ) ) ,
550
568
Some ( new_user_info. password ) ,
551
569
Some ( new_auth_type) ,
552
570
test_seq,
@@ -565,7 +583,7 @@ mod update {
565
583
let user_mgr = UserMgr :: new ( kv, "tenant1" ) ;
566
584
567
585
let new_password: Option < Vec < u8 > > = None ;
568
- let res = user_mgr. update_user ( test_name. to_string ( ) , new_password, None , None ) ;
586
+ let res = user_mgr. update_user ( test_name. to_string ( ) , None , new_password, None , None ) ;
569
587
assert ! ( res. await . is_ok( ) ) ;
570
588
Ok ( ( ) )
571
589
}
@@ -589,6 +607,7 @@ mod update {
589
607
590
608
let res = user_mgr. update_user (
591
609
test_user_name. to_string ( ) ,
610
+ None ,
592
611
Some ( Vec :: from ( "new_pass" . as_bytes ( ) ) ) ,
593
612
None ,
594
613
test_seq,
@@ -625,6 +644,7 @@ mod update {
625
644
626
645
let res = user_mgr. update_user (
627
646
test_user_name. to_string ( ) ,
647
+ Some ( String :: from ( "localhost" ) ) ,
628
648
Some ( Vec :: from ( "new_pass" . as_bytes ( ) ) ) ,
629
649
Some ( AuthType :: Sha256 ) ,
630
650
test_seq,
0 commit comments