Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1742

users.info method not documentation compliant

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Dev Exp
    • None
    • 3

      The users.info method is documented to return a hash of information for a particular user, but it actually returns an array of hashes:

      (byebug) root_authorized_client.use('admin').database.users.info('dev')
      [{"_id"=>"admin.dev", "user"=>"dev", "db"=>"admin", "roles"=>[{"role"=>"dbAdminAnyDatabase", "db"=>"admin"}, {"role"=>"readWriteAnyDatabase", "db"=>"admin"}, {"role"=>"userAdminAnyDatabase", "db"=>"admin"}, {"role"=>"clusterAdmin", "db"=>"admin"}], "mechanisms"=>["SCRAM-SHA-1"]}]
      

      Furthermore, https://docs.mongodb.com/manual/reference/command/usersInfo/ documents that a list of user names may be given as an argument. Ruby driver accepts an array of user names as an argument to `info` but returns information for only one of them, and which user is picked seems deterministic but is totally unclear:

      (byebug) root_authorized_client.use('admin').database.users.info(['foo'])
      [{"_id"=>"admin.foo", "user"=>"foo", "db"=>"admin", "roles"=>[{"role"=>"dbAdmin", "db"=>"admin"}], "mechanisms"=>["SCRAM-SHA-1", "SCRAM-SHA-256"]}]
      (byebug) root_authorized_client.use('admin').database.users.info(['dev','foo'])
      [{"_id"=>"admin.dev", "user"=>"dev", "db"=>"admin", "roles"=>[{"role"=>"dbAdminAnyDatabase", "db"=>"admin"}, {"role"=>"readWriteAnyDatabase", "db"=>"admin"}, {"role"=>"userAdminAnyDatabase", "db"=>"admin"}, {"role"=>"clusterAdmin", "db"=>"admin"}], "mechanisms"=>["SCRAM-SHA-1"]}, {"_id"=>"admin.foo", "user"=>"foo", "db"=>"admin", "roles"=>[{"role"=>"dbAdmin", "db"=>"admin"}], "mechanisms"=>["SCRAM-SHA-1", "SCRAM-SHA-256"]}]
      (byebug) root_authorized_client.use('admin').database.users.info(['foo','dev'])
      [{"_id"=>"admin.dev", "user"=>"dev", "db"=>"admin", "roles"=>[{"role"=>"dbAdminAnyDatabase", "db"=>"admin"}, {"role"=>"readWriteAnyDatabase", "db"=>"admin"}, {"role"=>"userAdminAnyDatabase", "db"=>"admin"}, {"role"=>"clusterAdmin", "db"=>"admin"}], "mechanisms"=>["SCRAM-SHA-1"]}, {"_id"=>"admin.foo", "user"=>"foo", "db"=>"admin", "roles"=>[{"role"=>"dbAdmin", "db"=>"admin"}], "mechanisms"=>["SCRAM-SHA-1", "SCRAM-SHA-256"]}]
      

      Action items:

      • The method behavior should match its documentation.
      • Investigate whether more of usersInfo functionality can be supported, and how to best expose it.

            Assignee:
            emily.giurleo@mongodb.com Emily Giurleo (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: