...

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

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

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

View as plain text