Skip to content

Commit 5d9bb59

Browse files
committed
test: sync auth spec tests
1 parent 3655e9e commit 5d9bb59

File tree

2 files changed

+26
-98
lines changed

2 files changed

+26
-98
lines changed

test/spec/auth/legacy/connection-string.json

Lines changed: 11 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -480,54 +480,9 @@
480480
"AWS_SESSION_TOKEN": "token!@#$%^&*()_+"
481481
}
482482
}
483-
},
484-
{
485-
"description": "should recognise the mechanism and request callback (MONGODB-OIDC)",
486-
"uri": "mongodb://localhost/?authMechanism=MONGODB-OIDC",
487-
"callback": ["oidcRequest"],
488-
"valid": true,
489-
"credential": {
490-
"username": null,
491-
"password": null,
492-
"source": "$external",
493-
"mechanism": "MONGODB-OIDC",
494-
"mechanism_properties": {
495-
"OIDC_TOKEN_CALLBACK": true
496-
}
497-
}
498483
},
499484
{
500-
"description": "should recognise the mechanism when auth source is explicitly specified and with request callback (MONGODB-OIDC)",
501-
"uri": "mongodb://localhost/?authMechanism=MONGODB-OIDC&authSource=$external",
502-
"callback": ["oidcRequest"],
503-
"valid": true,
504-
"credential": {
505-
"username": null,
506-
"password": null,
507-
"source": "$external",
508-
"mechanism": "MONGODB-OIDC",
509-
"mechanism_properties": {
510-
"OIDC_TOKEN_CALLBACK": true
511-
}
512-
}
513-
},
514-
{
515-
"description": "should recognise the mechanism and username with request callback (MONGODB-OIDC)",
516-
"uri": "mongodb://principalName@localhost/?authMechanism=MONGODB-OIDC",
517-
"callback": ["oidcRequest"],
518-
"valid": true,
519-
"credential": {
520-
"username": "principalName",
521-
"password": null,
522-
"source": "$external",
523-
"mechanism": "MONGODB-OIDC",
524-
"mechanism_properties": {
525-
"OIDC_TOKEN_CALLBACK": true
526-
}
527-
}
528-
},
529-
{
530-
"description": "should recognise the mechanism with aws device (MONGODB-OIDC)",
485+
"description": "should recognise the mechanism with aws provider (MONGODB-OIDC)",
531486
"uri": "mongodb://localhost/?authMechanism=MONGODB-OIDC&authMechanismProperties=PROVIDER_NAME:aws",
532487
"valid": true,
533488
"credential": {
@@ -536,12 +491,12 @@
536491
"source": "$external",
537492
"mechanism": "MONGODB-OIDC",
538493
"mechanism_properties": {
539-
"PROVIDER_NAME": "aws"
494+
"PROVIDER_NAME": "aws"
540495
}
541496
}
542497
},
543498
{
544-
"description": "should recognise the mechanism when auth source is explicitly specified and with aws device (MONGODB-OIDC)",
499+
"description": "should recognise the mechanism when auth source is explicitly specified and with provider (MONGODB-OIDC)",
545500
"uri": "mongodb://localhost/?authMechanism=MONGODB-OIDC&authSource=$external&authMechanismProperties=PROVIDER_NAME:aws",
546501
"valid": true,
547502
"credential": {
@@ -550,39 +505,31 @@
550505
"source": "$external",
551506
"mechanism": "MONGODB-OIDC",
552507
"mechanism_properties": {
553-
"PROVIDER_NAME": "aws"
508+
"PROVIDER_NAME": "aws"
554509
}
555510
}
556511
},
557512
{
558-
"description": "should throw an exception if username and password are specified (MONGODB-OIDC)",
559-
"uri": "mongodb://user:pass@localhost/?authMechanism=MONGODB-OIDC",
560-
"callback": ["oidcRequest"],
513+
"description": "should throw an exception if supplied a password (MONGODB-OIDC)",
514+
"uri": "mongodb://user:pass@localhost/?authMechanism=MONGODB-OIDC&authMechanismProperties=PROVIDER_NAME:aws",
561515
"valid": false,
562516
"credential": null
563517
},
564518
{
565-
"description": "should throw an exception if username and deviceName are specified (MONGODB-OIDC)",
566-
"uri": "mongodb://principalName@localhost/?authMechanism=MONGODB-OIDC&PROVIDER_NAME:gcp",
519+
"description": "should throw an exception if username is specified for aws (MONGODB-OIDC)",
520+
"uri": "mongodb://principalName@localhost/?authMechanism=MONGODB-OIDC&PROVIDER_NAME:aws",
567521
"valid": false,
568522
"credential": null
569523
},
570524
{
571-
"description": "should throw an exception if specified deviceName is not supported (MONGODB-OIDC)",
572-
"uri": "mongodb://localhost/?authMechanism=MONGODB-OIDC&authMechanismProperties=PROVIDER_NAME:unexisted",
573-
"valid": false,
574-
"credential": null
575-
},
576-
{
577-
"description": "should throw an exception if neither deviceName nor callbacks specified (MONGODB-OIDC)",
578-
"uri": "mongodb://localhost/?authMechanism=MONGODB-OIDC",
525+
"description": "should throw an exception if specified provider is not supported (MONGODB-OIDC)",
526+
"uri": "mongodb://localhost/?authMechanism=MONGODB-OIDC&authMechanismProperties=PROVIDER_NAME:invalid",
579527
"valid": false,
580528
"credential": null
581529
},
582530
{
583-
"description": "should throw an exception when only refresh callback is specified (MONGODB-OIDC)",
531+
"description": "should throw an exception if neither provider nor callbacks specified (MONGODB-OIDC)",
584532
"uri": "mongodb://localhost/?authMechanism=MONGODB-OIDC",
585-
"callback": ["oidcRefresh"],
586533
"valid": false,
587534
"credential": null
588535
},

test/spec/auth/legacy/connection-string.yml

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -350,62 +350,43 @@ tests:
350350
mechanism: MONGODB-AWS
351351
mechanism_properties:
352352
AWS_SESSION_TOKEN: token!@#$%^&*()_+
353-
- description: should recognise the mechanism and request callback (MONGODB-OIDC)
354-
uri: mongodb://localhost/?authMechanism=MONGODB-OIDC
355-
callback:
356-
- oidcRequest
353+
- description: should recognise the mechanism with aws provider (MONGODB-OIDC)
354+
uri: mongodb://localhost/?authMechanism=MONGODB-OIDC&authMechanismProperties=PROVIDER_NAME:aws
357355
valid: true
358356
credential:
359357
username:
360358
password:
361359
source: "$external"
362360
mechanism: MONGODB-OIDC
363361
mechanism_properties:
364-
OIDC_TOKEN_CALLBACK: true
365-
- description: should recognise the mechanism when auth source is explicitly specified
366-
and with request callback (MONGODB-OIDC)
367-
uri: mongodb://localhost/?authMechanism=MONGODB-OIDC&authSource=$external
368-
callback:
369-
- oidcRequest
362+
PROVIDER_NAME: aws
363+
- description: should recognise the mechanism when auth source is explicitly specified and with provider (MONGODB-OIDC)
364+
uri: mongodb://localhost/?authMechanism=MONGODB-OIDC&authSource=$external&authMechanismProperties=PROVIDER_NAME:aws
370365
valid: true
371366
credential:
372367
username:
373368
password:
374369
source: "$external"
375370
mechanism: MONGODB-OIDC
376371
mechanism_properties:
377-
OIDC_TOKEN_CALLBACK: true
378-
- description: should recognise the mechanism and username with request callback (MONGODB-OIDC)
379-
uri: mongodb://principalName@localhost/?authMechanism=MONGODB-OIDC
380-
callback:
381-
- oidcRequest
382-
valid: true
372+
PROVIDER_NAME: aws
373+
- description: should throw an exception if supplied a password (MONGODB-OIDC)
374+
uri: mongodb://user:pass@localhost/?authMechanism=MONGODB-OIDC&authMechanismProperties=PROVIDER_NAME:aws
375+
valid: false
383376
credential:
384-
username: principalName
385-
password:
386-
source: "$external"
387-
mechanism: MONGODB-OIDC
388-
mechanism_properties:
389-
OIDC_TOKEN_CALLBACK: true
390-
- description: should throw an exception if username and password are specified (MONGODB-OIDC)
391-
uri: mongodb://user:pass@localhost/?authMechanism=MONGODB-OID
392-
callback:
393-
- oidcRequest
377+
- description: should throw an exception if username is specified for aws (MONGODB-OIDC)
378+
uri: mongodb://principalName@localhost/?authMechanism=MONGODB-OIDC&PROVIDER_NAME:aws
394379
valid: false
395380
credential:
396-
- description: should throw an exception if neither deviceName nor callbacks specified
397-
(MONGODB-OIDC)
398-
uri: mongodb://localhost/?authMechanism=MONGODB-OIDC
381+
- description: should throw an exception if specified provider is not supported (MONGODB-OIDC)
382+
uri: mongodb://localhost/?authMechanism=MONGODB-OIDC&authMechanismProperties=PROVIDER_NAME:invalid
399383
valid: false
400384
credential:
401-
- description: should throw an exception when only refresh callback is specified (MONGODB-OIDC)
385+
- description: should throw an exception if neither provider nor callbacks specified (MONGODB-OIDC)
402386
uri: mongodb://localhost/?authMechanism=MONGODB-OIDC
403-
callback:
404-
- oidcRefresh
405387
valid: false
406388
credential:
407-
- description: should throw an exception when unsupported auth property is specified
408-
(MONGODB-OIDC)
389+
- description: should throw an exception when unsupported auth property is specified (MONGODB-OIDC)
409390
uri: mongodb://localhost/?authMechanism=MONGODB-OIDC&authMechanismProperties=UnsupportedProperty:unexisted
410391
valid: false
411392
credential:

0 commit comments

Comments
 (0)