@@ -305,7 +305,6 @@ describe('Authentication Spec Prose Tests', function () {
305
305
) ;
306
306
} ) ;
307
307
308
- // todo(NODE-5621): fix the issue with unicode characters.
309
308
describe ( 'Step 4' , function ( ) {
310
309
/**
311
310
* Step 4
@@ -340,9 +339,15 @@ describe('Authentication Spec Prose Tests', function () {
340
339
] ;
341
340
342
341
beforeEach ( async function ( ) {
343
- utilClient = this . configuration . newClient ( ) ;
342
+ utilClient = this . configuration . newClient ( this . configuration . url ( ) ) ;
344
343
const db = utilClient . db ( 'admin' ) ;
345
344
345
+ try {
346
+ await Promise . all ( users . map ( user => db . removeUser ( user . username ) ) ) ;
347
+ } catch ( err ) {
348
+ /** We ensure that users are deleted. No action needed. */
349
+ }
350
+
346
351
const createUserCommands = users . map ( user => ( {
347
352
createUser : user . username ,
348
353
pwd : user . password ,
@@ -354,33 +359,189 @@ describe('Authentication Spec Prose Tests', function () {
354
359
} ) ;
355
360
356
361
afterEach ( async function ( ) {
357
- const db = utilClient . db ( 'admin' ) ;
358
- await Promise . all ( users . map ( user => db . removeUser ( user . username ) ) ) ;
359
362
await utilClient ?. close ( ) ;
363
+ await client ?. close ( ) ;
360
364
} ) ;
361
365
362
- for ( const { username, password } of [
363
- { username : 'IX' , password : 'IX' } ,
364
- { username : 'IX' , password : 'I\u00ADX' } ,
365
- { username : '\u2168' , password : 'IV' } ,
366
- { username : '\u2168' , password : 'I\u00ADV' }
367
- ] ) {
368
- it . skip (
369
- `logs in with username "${ username } " and password "${ password } "` ,
366
+ context ( 'auth credentials in options' , ( ) => {
367
+ it ( 'logs in with non-normalized username and password' , metadata , async function ( ) {
368
+ const options = {
369
+ auth : { username : 'IX' , password : 'IX' } ,
370
+ authSource : 'admin' ,
371
+ authMechanism : 'SCRAM-SHA-256'
372
+ } ;
373
+
374
+ client = this . configuration . newClient ( { } , options ) ;
375
+ const stats = await client . db ( 'admin' ) . stats ( ) ;
376
+ expect ( stats ) . to . exist ;
377
+ } ) ;
378
+
379
+ it (
380
+ 'logs in with non-normalized username and normalized password' ,
370
381
metadata ,
371
382
async function ( ) {
372
383
const options = {
373
- auth : { username, password } ,
384
+ auth : { username : 'IX' , password : 'I\u00ADX' } ,
374
385
authSource : 'admin' ,
375
386
authMechanism : 'SCRAM-SHA-256'
376
387
} ;
377
388
378
- client = this . configuration . newClient ( options ) ;
389
+ client = this . configuration . newClient ( { } , options ) ;
379
390
const stats = await client . db ( 'admin' ) . stats ( ) ;
380
391
expect ( stats ) . to . exist ;
381
392
}
382
- ) . skipReason = 'todo(NODE-5621): fix the issue with unicode characters.' ;
383
- }
393
+ ) ;
394
+
395
+ it (
396
+ 'logs in with normalized username and non-normalized password' ,
397
+ metadata ,
398
+ async function ( ) {
399
+ const options = {
400
+ auth : { username : '\u2168' , password : 'IV' } ,
401
+ authSource : 'admin' ,
402
+ authMechanism : 'SCRAM-SHA-256'
403
+ } ;
404
+
405
+ client = this . configuration . newClient ( { } , options ) ;
406
+ const stats = await client . db ( 'admin' ) . stats ( ) ;
407
+ expect ( stats ) . to . exist ;
408
+ }
409
+ ) ;
410
+
411
+ it ( 'logs in with normalized username and normalized password' , metadata , async function ( ) {
412
+ const options = {
413
+ auth : { username : '\u2168' , password : 'I\u00ADV' } ,
414
+ authSource : 'admin' ,
415
+ authMechanism : 'SCRAM-SHA-256'
416
+ } ;
417
+
418
+ client = this . configuration . newClient ( { } , options ) ;
419
+ const stats = await client . db ( 'admin' ) . stats ( ) ;
420
+ expect ( stats ) . to . exist ;
421
+ } ) ;
422
+ } ) ;
423
+
424
+ context ( 'auth credentials in url' , ( ) => {
425
+ context ( 'encoded' , ( ) => {
426
+ it ( 'logs in with not encoded username and password' , metadata , async function ( ) {
427
+ const options = {
428
+ authSource : 'admin' ,
429
+ authMechanism : 'SCRAM-SHA-256'
430
+ } ;
431
+ client = this . configuration . newClient (
432
+ this . configuration . url ( { username : 'IX' , password : 'IX' } ) ,
433
+ options
434
+ ) ;
435
+ const stats = await client . db ( 'admin' ) . stats ( ) ;
436
+ expect ( stats ) . to . exist ;
437
+ } ) ;
438
+
439
+ it ( 'logs in with not encoded username and encoded password' , metadata , async function ( ) {
440
+ const options = {
441
+ authSource : 'admin' ,
442
+ authMechanism : 'SCRAM-SHA-256'
443
+ } ;
444
+ client = this . configuration . newClient (
445
+ this . configuration . url ( { username : 'IX' , password : 'I%C2%ADX' } ) ,
446
+ options
447
+ ) ;
448
+ const stats = await client . db ( 'admin' ) . stats ( ) ;
449
+ expect ( stats ) . to . exist ;
450
+ } ) ;
451
+
452
+ it ( 'logs in with encoded username and not encoded password' , metadata , async function ( ) {
453
+ const options = {
454
+ authSource : 'admin' ,
455
+ authMechanism : 'SCRAM-SHA-256'
456
+ } ;
457
+ client = this . configuration . newClient (
458
+ this . configuration . url ( { username : '%E2%85%A8' , password : 'IV' } ) ,
459
+ options
460
+ ) ;
461
+ const stats = await client . db ( 'admin' ) . stats ( ) ;
462
+ expect ( stats ) . to . exist ;
463
+ } ) ;
464
+
465
+ it ( 'logs in with encoded username and encoded password' , metadata , async function ( ) {
466
+ const options = {
467
+ authSource : 'admin' ,
468
+ authMechanism : 'SCRAM-SHA-256'
469
+ } ;
470
+ client = this . configuration . newClient (
471
+ this . configuration . url ( { username : '%E2%85%A8' , password : 'I%C2%ADV' } ) ,
472
+ options
473
+ ) ;
474
+ const stats = await client . db ( 'admin' ) . stats ( ) ;
475
+ expect ( stats ) . to . exist ;
476
+ } ) ;
477
+ } ) ;
478
+
479
+ context ( 'normalized' , ( ) => {
480
+ it ( 'logs in with non-normalized username and password' , metadata , async function ( ) {
481
+ const options = {
482
+ authSource : 'admin' ,
483
+ authMechanism : 'SCRAM-SHA-256'
484
+ } ;
485
+ client = this . configuration . newClient (
486
+ this . configuration . url ( { username : 'IX' , password : 'IX' } ) ,
487
+ options
488
+ ) ;
489
+ const stats = await client . db ( 'admin' ) . stats ( ) ;
490
+ expect ( stats ) . to . exist ;
491
+ } ) ;
492
+
493
+ it (
494
+ 'logs in with non-normalized username and normalized password' ,
495
+ metadata ,
496
+ async function ( ) {
497
+ const options = {
498
+ authSource : 'admin' ,
499
+ authMechanism : 'SCRAM-SHA-256'
500
+ } ;
501
+ client = this . configuration . newClient (
502
+ this . configuration . url ( { username : 'IX' , password : 'I\u00ADX' } ) ,
503
+ options
504
+ ) ;
505
+ const stats = await client . db ( 'admin' ) . stats ( ) ;
506
+ expect ( stats ) . to . exist ;
507
+ }
508
+ ) ;
509
+
510
+ it (
511
+ 'logs in with normalized username and non-normalized password' ,
512
+ metadata ,
513
+ async function ( ) {
514
+ const options = {
515
+ authSource : 'admin' ,
516
+ authMechanism : 'SCRAM-SHA-256'
517
+ } ;
518
+ client = this . configuration . newClient (
519
+ this . configuration . url ( { username : '\u2168' , password : 'I\u00ADV' } ) ,
520
+ options
521
+ ) ;
522
+ const stats = await client . db ( 'admin' ) . stats ( ) ;
523
+ expect ( stats ) . to . exist ;
524
+ }
525
+ ) ;
526
+
527
+ it (
528
+ 'logs in with normalized username and normalized password' ,
529
+ metadata ,
530
+ async function ( ) {
531
+ const options = {
532
+ authSource : 'admin' ,
533
+ authMechanism : 'SCRAM-SHA-256'
534
+ } ;
535
+ client = this . configuration . newClient (
536
+ this . configuration . url ( { username : '\u2168' , password : 'I\u00ADV' } ) ,
537
+ options
538
+ ) ;
539
+ const stats = await client . db ( 'admin' ) . stats ( ) ;
540
+ expect ( stats ) . to . exist ;
541
+ }
542
+ ) ;
543
+ } ) ;
544
+ } ) ;
384
545
} ) ;
385
546
} ) ;
386
547
} ) ;
0 commit comments