{
  "tests": [
    {
      "description": "User info for single IPv4 host without database",
      "uri": "mongodb://alice:foo@127.0.0.1",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "ipv4",
          "host": "127.0.0.1",
          "port": null
        }
      ],
      "auth": {
        "username": "alice",
        "password": "foo",
        "db": null
      },
      "options": null
    },
    {
      "description": "User info for single IPv4 host with database",
      "uri": "mongodb://alice:foo@127.0.0.1/test",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "ipv4",
          "host": "127.0.0.1",
          "port": null
        }
      ],
      "auth": {
        "username": "alice",
        "password": "foo",
        "db": "test"
      },
      "options": null
    },
    {
      "description": "User info for single IP literal host without database",
      "uri": "mongodb://bob:bar@[::1]:27018",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "ip_literal",
          "host": "::1",
          "port": 27018
        }
      ],
      "auth": {
        "username": "bob",
        "password": "bar",
        "db": null
      },
      "options": null
    },
    {
      "description": "User info for single IP literal host with database",
      "uri": "mongodb://bob:bar@[::1]:27018/admin",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "ip_literal",
          "host": "::1",
          "port": 27018
        }
      ],
      "auth": {
        "username": "bob",
        "password": "bar",
        "db": "admin"
      },
      "options": null
    },
    {
      "description": "User info for single hostname without database",
      "uri": "mongodb://eve:baz@example.com",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "hostname",
          "host": "example.com",
          "port": null
        }
      ],
      "auth": {
        "username": "eve",
        "password": "baz",
        "db": null
      },
      "options": null
    },
    {
      "description": "User info for single hostname with database",
      "uri": "mongodb://eve:baz@example.com/db2",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "hostname",
          "host": "example.com",
          "port": null
        }
      ],
      "auth": {
        "username": "eve",
        "password": "baz",
        "db": "db2"
      },
      "options": null
    },
    {
      "description": "User info for multiple hosts without database",
      "uri": "mongodb://alice:secret@127.0.0.1,example.com:27018",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "ipv4",
          "host": "127.0.0.1",
          "port": null
        },
        {
          "type": "hostname",
          "host": "example.com",
          "port": 27018
        }
      ],
      "auth": {
        "username": "alice",
        "password": "secret",
        "db": null
      },
      "options": null
    },
    {
      "description": "User info for multiple hosts with database",
      "uri": "mongodb://alice:secret@example.com,[::1]:27019/admin",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "hostname",
          "host": "example.com",
          "port": null
        },
        {
          "type": "ip_literal",
          "host": "::1",
          "port": 27019
        }
      ],
      "auth": {
        "username": "alice",
        "password": "secret",
        "db": "admin"
      },
      "options": null
    },
    {
      "description": "Username without password",
      "uri": "mongodb://alice@127.0.0.1",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "ipv4",
          "host": "127.0.0.1",
          "port": null
        }
      ],
      "auth": {
        "username": "alice",
        "password": null,
        "db": null
      },
      "options": null
    },
    {
      "description": "Username with empty password",
      "uri": "mongodb://alice:@127.0.0.1",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "ipv4",
          "host": "127.0.0.1",
          "port": null
        }
      ],
      "auth": {
        "username": "alice",
        "password": "",
        "db": null
      },
      "options": null
    },
    {
      "description": "Escaped username and database without password",
      "uri": "mongodb://%40l%3Ace%2F%3D@example.com/my%3Ddb",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "hostname",
          "host": "example.com",
          "port": null
        }
      ],
      "auth": {
        "username": "@l:ce/=",
        "password": null,
        "db": "my=db"
      },
      "options": null
    },
    {
      "description": "Escaped user info and database (MONGODB-CR)",
      "uri": "mongodb://%24am:f%3Azzb%40z%2Fz%3D@127.0.0.1/admin%3F?authMechanism=MONGODB-CR",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "ipv4",
          "host": "127.0.0.1",
          "port": null
        }
      ],
      "auth": {
        "username": "$am",
        "password": "f:zzb@z/z=",
        "db": "admin?"
      },
      "options": {
        "authmechanism": "MONGODB-CR"
      }
    },
    {
      "description": "Subdelimiters in user/pass don't need escaping (MONGODB-CR)",
      "uri": "mongodb://!$&'()*+,;=:!$&'()*+,;=@127.0.0.1/admin?authMechanism=MONGODB-CR",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "ipv4",
          "host": "127.0.0.1",
          "port": null
        }
      ],
      "auth": {
        "username": "!$&'()*+,;=",
        "password": "!$&'()*+,;=",
        "db": "admin"
      },
      "options": {
        "authmechanism": "MONGODB-CR"
      }
    },
    {
      "description": "Escaped username (MONGODB-X509)",
      "uri": "mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/?authMechanism=MONGODB-X509",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "hostname",
          "host": "localhost",
          "port": null
        }
      ],
      "auth": {
        "username": "CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry",
        "password": null,
        "db": null
      },
      "options": {
        "authmechanism": "MONGODB-X509"
      }
    },
    {
      "description": "Escaped username (GSSAPI)",
      "uri": "mongodb://user%40EXAMPLE.COM:secret@localhost/?authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true&authMechanism=GSSAPI",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "hostname",
          "host": "localhost",
          "port": null
        }
      ],
      "auth": {
        "username": "user@EXAMPLE.COM",
        "password": "secret",
        "db": null
      },
      "options": {
        "authmechanism": "GSSAPI",
        "authmechanismproperties": {
          "SERVICE_NAME": "other",
          "CANONICALIZE_HOST_NAME": true
        }
      }
    },
    {
      "description": "At-signs in options aren't part of the userinfo",
      "uri": "mongodb://alice:secret@example.com/admin?replicaset=my@replicaset",
      "valid": true,
      "warning": false,
      "hosts": [
        {
          "type": "hostname",
          "host": "example.com",
          "port": null
        }
      ],
      "auth": {
        "username": "alice",
        "password": "secret",
        "db": "admin"
      },
      "options": {
        "replicaset": "my@replicaset"
      }
    }
  ]
}