...

Text file src/go.mongodb.org/mongo-driver/testdata/auth/connection-string.yml

Documentation: go.mongodb.org/mongo-driver/testdata/auth

     1tests:
     2    -
     3        description: "should use the default source and mechanism"
     4        uri: "mongodb://user:password@localhost"
     5        valid: true
     6        credential:
     7            username: "user"
     8            password: "password"
     9            source: "admin"
    10            mechanism: ~
    11            mechanism_properties: ~
    12    -
    13        description: "should use the database when no authSource is specified"
    14        uri: "mongodb://user:password@localhost/foo"
    15        valid: true
    16        credential:
    17            username: "user"
    18            password: "password"
    19            source: "foo"
    20            mechanism: ~
    21            mechanism_properties: ~
    22    -
    23        description: "should use the authSource when specified"
    24        uri: "mongodb://user:password@localhost/foo?authSource=bar"
    25        valid: true
    26        credential:
    27            username: "user"
    28            password: "password"
    29            source: "bar"
    30            mechanism: ~
    31            mechanism_properties: ~
    32    -
    33        description: "should recognise the mechanism (GSSAPI)"
    34        uri: "mongodb://user%40DOMAIN.COM@localhost/?authMechanism=GSSAPI"
    35        valid: true
    36        credential:
    37            username: "user@DOMAIN.COM"
    38            password: ~
    39            source: "$external"
    40            mechanism: "GSSAPI"
    41            mechanism_properties:
    42                SERVICE_NAME: "mongodb"
    43    -
    44        description: "should ignore the database (GSSAPI)"
    45        uri: "mongodb://user%40DOMAIN.COM@localhost/foo?authMechanism=GSSAPI"
    46        valid: true
    47        credential:
    48            username: "user@DOMAIN.COM"
    49            password: ~
    50            source: "$external"
    51            mechanism: "GSSAPI"
    52            mechanism_properties:
    53                SERVICE_NAME: "mongodb"
    54    -
    55        description: "should accept valid authSource (GSSAPI)"
    56        uri: "mongodb://user%40DOMAIN.COM@localhost/?authMechanism=GSSAPI&authSource=$external"
    57        valid: true
    58        credential:
    59            username: "user@DOMAIN.COM"
    60            password: ~
    61            source: "$external"
    62            mechanism: "GSSAPI"
    63            mechanism_properties:
    64                SERVICE_NAME: "mongodb"
    65    -
    66        description: "should accept generic mechanism property (GSSAPI)"
    67        uri: "mongodb://user%40DOMAIN.COM@localhost/?authMechanism=GSSAPI&authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true"
    68        valid: true
    69        credential:
    70            username: "user@DOMAIN.COM"
    71            password: ~
    72            source: "$external"
    73            mechanism: "GSSAPI"
    74            mechanism_properties:
    75                SERVICE_NAME: "other"
    76                CANONICALIZE_HOST_NAME: true
    77    -
    78        description: "should accept the password (GSSAPI)"
    79        uri: "mongodb://user%40DOMAIN.COM:password@localhost/?authMechanism=GSSAPI&authSource=$external"
    80        valid: true
    81        credential:
    82            username: "user@DOMAIN.COM"
    83            password: "password"
    84            source: "$external"
    85            mechanism: "GSSAPI"
    86            mechanism_properties:
    87                SERVICE_NAME: "mongodb"
    88    -
    89        description: "must raise an error when the authSource is empty"
    90        uri: "mongodb://user:password@localhost/foo?authSource="
    91        valid: false
    92    -
    93        description: "must raise an error when the authSource is empty without credentials"
    94        uri: "mongodb://localhost/admin?authSource="
    95        valid: false
    96    -
    97        description: "should throw an exception if authSource is invalid (GSSAPI)"
    98        uri: "mongodb://user%40DOMAIN.COM@localhost/?authMechanism=GSSAPI&authSource=foo"
    99        valid: false
   100    -
   101        description: "should throw an exception if no username (GSSAPI)"
   102        uri: "mongodb://localhost/?authMechanism=GSSAPI"
   103        valid: false
   104    -
   105        description: "should recognize the mechanism (MONGODB-CR)"
   106        uri: "mongodb://user:password@localhost/?authMechanism=MONGODB-CR"
   107        valid: true
   108        credential:
   109            username: "user"
   110            password: "password"
   111            source: "admin"
   112            mechanism: "MONGODB-CR"
   113            mechanism_properties: ~
   114    -
   115        description: "should use the database when no authSource is specified (MONGODB-CR)"
   116        uri: "mongodb://user:password@localhost/foo?authMechanism=MONGODB-CR"
   117        valid: true
   118        credential:
   119            username: "user"
   120            password: "password"
   121            source: "foo"
   122            mechanism: "MONGODB-CR"
   123            mechanism_properties: ~
   124    -
   125        description: "should use the authSource when specified (MONGODB-CR)"
   126        uri: "mongodb://user:password@localhost/foo?authMechanism=MONGODB-CR&authSource=bar"
   127        valid: true
   128        credential:
   129            username: "user"
   130            password: "password"
   131            source: "bar"
   132            mechanism: "MONGODB-CR"
   133            mechanism_properties: ~
   134    -
   135        description: "should throw an exception if no username is supplied (MONGODB-CR)"
   136        uri: "mongodb://localhost/?authMechanism=MONGODB-CR"
   137        valid: false
   138    -
   139        description: "should recognize the mechanism (MONGODB-X509)"
   140        uri: "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/?authMechanism=MONGODB-X509"
   141        valid: true
   142        credential:
   143            username: "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry"
   144            password: ~
   145            source: "$external"
   146            mechanism: "MONGODB-X509"
   147            mechanism_properties: ~
   148    -
   149        description: "should ignore the database (MONGODB-X509)"
   150        uri: "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/foo?authMechanism=MONGODB-X509"
   151        valid: true
   152        credential:
   153            username: "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry"
   154            password: ~
   155            source: "$external"
   156            mechanism: "MONGODB-X509"
   157            mechanism_properties: ~
   158    -
   159        description: "should accept valid authSource (MONGODB-X509)"
   160        uri: "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/?authMechanism=MONGODB-X509&authSource=$external"
   161        valid: true
   162        credential:
   163            username: "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry"
   164            password: ~
   165            source: "$external"
   166            mechanism: "MONGODB-X509"
   167            mechanism_properties: ~
   168    -
   169        description: "should recognize the mechanism with no username (MONGODB-X509)"
   170        uri: "mongodb://localhost/?authMechanism=MONGODB-X509"
   171        valid: true
   172        credential:
   173            username: ~
   174            password: ~
   175            source: "$external"
   176            mechanism: "MONGODB-X509"
   177            mechanism_properties: ~
   178    -
   179        description: "should recognize the mechanism with no username when auth source is explicitly specified (MONGODB-X509)"
   180        uri: "mongodb://localhost/?authMechanism=MONGODB-X509&authSource=$external"
   181        valid: true
   182        credential:
   183            username: ~
   184            password: ~
   185            source: "$external"
   186            mechanism: "MONGODB-X509"
   187            mechanism_properties: ~
   188    -
   189        description: "should throw an exception if supplied a password (MONGODB-X509)"
   190        uri: "mongodb://user:password@localhost/?authMechanism=MONGODB-X509"
   191        valid: false
   192    -
   193        description: "should throw an exception if authSource is invalid (MONGODB-X509)"
   194        uri: "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/foo?authMechanism=MONGODB-X509&authSource=bar"
   195        valid: false
   196    -
   197        description: "should recognize the mechanism (PLAIN)"
   198        uri: "mongodb://user:password@localhost/?authMechanism=PLAIN"
   199        valid: true
   200        credential:
   201          username: "user"
   202          password: "password"
   203          source: "$external"
   204          mechanism: "PLAIN"
   205          mechanism_properties: ~
   206    -
   207        description: "should use the database when no authSource is specified (PLAIN)"
   208        uri: "mongodb://user:password@localhost/foo?authMechanism=PLAIN"
   209        valid: true
   210        credential:
   211            username: "user"
   212            password: "password"
   213            source: "foo"
   214            mechanism: "PLAIN"
   215            mechanism_properties: ~
   216    -
   217        description: "should use the authSource when specified (PLAIN)"
   218        uri: "mongodb://user:password@localhost/foo?authMechanism=PLAIN&authSource=bar"
   219        valid: true
   220        credential:
   221            username: "user"
   222            password: "password"
   223            source: "bar"
   224            mechanism: "PLAIN"
   225            mechanism_properties: ~
   226    -
   227        description: "should throw an exception if no username (PLAIN)"
   228        uri: "mongodb://localhost/?authMechanism=PLAIN"
   229        valid: false
   230    -
   231        description: "should recognize the mechanism (SCRAM-SHA-1)"
   232        uri: "mongodb://user:password@localhost/?authMechanism=SCRAM-SHA-1"
   233        valid: true
   234        credential:
   235            username: "user"
   236            password: "password"
   237            source: "admin"
   238            mechanism: "SCRAM-SHA-1"
   239            mechanism_properties: ~
   240    -
   241        description: "should use the database when no authSource is specified (SCRAM-SHA-1)"
   242        uri: "mongodb://user:password@localhost/foo?authMechanism=SCRAM-SHA-1"
   243        valid: true
   244        credential:
   245            username: "user"
   246            password: "password"
   247            source: "foo"
   248            mechanism: "SCRAM-SHA-1"
   249            mechanism_properties: ~
   250    -
   251        description: "should accept valid authSource (SCRAM-SHA-1)"
   252        uri: "mongodb://user:password@localhost/foo?authMechanism=SCRAM-SHA-1&authSource=bar"
   253        valid: true
   254        credential:
   255            username: "user"
   256            password: "password"
   257            source: "bar"
   258            mechanism: "SCRAM-SHA-1"
   259            mechanism_properties: ~
   260    -
   261        description: "should throw an exception if no username (SCRAM-SHA-1)"
   262        uri: "mongodb://localhost/?authMechanism=SCRAM-SHA-1"
   263        valid: false
   264    -
   265        description: "should recognize the mechanism (SCRAM-SHA-256)"
   266        uri: "mongodb://user:password@localhost/?authMechanism=SCRAM-SHA-256"
   267        valid: true
   268        credential:
   269            username: "user"
   270            password: "password"
   271            source: "admin"
   272            mechanism: "SCRAM-SHA-256"
   273            mechanism_properties: ~
   274    -
   275        description: "should use the database when no authSource is specified (SCRAM-SHA-256)"
   276        uri: "mongodb://user:password@localhost/foo?authMechanism=SCRAM-SHA-256"
   277        valid: true
   278        credential:
   279            username: "user"
   280            password: "password"
   281            source: "foo"
   282            mechanism: "SCRAM-SHA-256"
   283            mechanism_properties: ~
   284    -
   285        description: "should accept valid authSource (SCRAM-SHA-256)"
   286        uri: "mongodb://user:password@localhost/foo?authMechanism=SCRAM-SHA-256&authSource=bar"
   287        valid: true
   288        credential:
   289            username: "user"
   290            password: "password"
   291            source: "bar"
   292            mechanism: "SCRAM-SHA-256"
   293            mechanism_properties: ~
   294    -
   295        description: "should throw an exception if no username (SCRAM-SHA-256)"
   296        uri: "mongodb://localhost/?authMechanism=SCRAM-SHA-256"
   297        valid: false
   298    -
   299        description: "URI with no auth-related info doesn't create credential"
   300        uri: "mongodb://localhost/"
   301        valid: true
   302        credential: ~
   303    -
   304        description: "database in URI path doesn't create credentials"
   305        uri: "mongodb://localhost/foo"
   306        valid: true
   307        credential: ~
   308    -
   309        description: "authSource without username doesn't create credential (default mechanism)"
   310        uri: "mongodb://localhost/?authSource=foo"
   311        valid: true
   312        credential: ~
   313    -
   314        description: "should throw an exception if no username provided (userinfo implies default mechanism)"
   315        uri: "mongodb://@localhost.com/"
   316        valid: false
   317    -
   318        description: "should throw an exception if no username/password provided (userinfo implies default mechanism)"
   319        uri: "mongodb://:@localhost.com/"
   320        valid: false
   321    -
   322        description: "should recognise the mechanism (MONGODB-AWS)"
   323        uri: "mongodb://localhost/?authMechanism=MONGODB-AWS"
   324        valid: true
   325        credential:
   326            username: ~
   327            password: ~
   328            source: "$external"
   329            mechanism: "MONGODB-AWS"
   330            mechanism_properties: ~
   331    -
   332        description: "should recognise the mechanism when auth source is explicitly specified (MONGODB-AWS)"
   333        uri: "mongodb://localhost/?authMechanism=MONGODB-AWS&authSource=$external"
   334        valid: true
   335        credential:
   336            username: ~
   337            password: ~
   338            source: "$external"
   339            mechanism: "MONGODB-AWS"
   340            mechanism_properties: ~
   341    -
   342        description: "should throw an exception if username and no password (MONGODB-AWS)"
   343        uri: "mongodb://user@localhost/?authMechanism=MONGODB-AWS"
   344        valid: false
   345        credential: ~
   346    -
   347      description: "should use username and password if specified (MONGODB-AWS)"
   348      uri: "mongodb://user%21%40%23%24%25%5E%26%2A%28%29_%2B:pass%21%40%23%24%25%5E%26%2A%28%29_%2B@localhost/?authMechanism=MONGODB-AWS"
   349      valid: true
   350      credential:
   351          username: "user!@#$%^&*()_+"
   352          password: "pass!@#$%^&*()_+"
   353          source: "$external"
   354          mechanism: "MONGODB-AWS"
   355          mechanism_properties: ~
   356    -
   357      description: "should use username, password and session token if specified (MONGODB-AWS)"
   358      uri: "mongodb://user:password@localhost/?authMechanism=MONGODB-AWS&authMechanismProperties=AWS_SESSION_TOKEN:token%21%40%23%24%25%5E%26%2A%28%29_%2B"
   359      valid: true
   360      credential:
   361          username: "user"
   362          password: "password"
   363          source: "$external"
   364          mechanism: "MONGODB-AWS"
   365          mechanism_properties:
   366              AWS_SESSION_TOKEN: "token!@#$%^&*()_+"

View as plain text