Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-11634

Write command authentication returning wrong fields on error

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.5.4
    • None
    • ALL
    • Hide

      //
      // Ensures that mongod respects the batch write protocols
      //
      var request;
      var result;
       
      print("START batch_write_command_auth.js");
       
      var port = allocatePorts(1)[0];
      var dbName = "batch_write_protocol_auth";
       
      var mongoInstance = startMongod( "--auth", "--port", port, "--dbpath", "/data/db/" + dbName, "--nohttpinterface", "--bind_ip", "127.0.0.1" );
      var db = mongoInstance.getDB("test");
       
      // Get the collection name
      var collectionName = "batch_write_protocol";
      var coll = db.getCollection(collectionName);
       
      // Get the test db we are running against and make sure it's gone
      var testDb = db[dbName];
      testDb.drop();
       
      // Drop all users on the db
      db.dropAllUsers();
       
      // Add an admin user
      db.getSisterDB( "admin" ).addUser({user: "super", pwd: "super", roles: ["__system"] });
      db.getSisterDB("admin").auth("super", "super");
      // Add a standard user
      db.addUser({user: "guest" , pwd: "guest", roles: jsTest.readOnlyUserRoles});
      // Add a read only user
      db.addUser({user: "eliot" , pwd: "eliot", roles: jsTest.basicUserRoles });
      // Log out
      db.getSisterDB("admin").logout();
       
      /**
       * Attempt to execute write batches without any authentication performed
       */
       
      //
      // Single document insert, w:1 write concern specified, ordered:false
      request = {insert : collectionName
      	, documents: [{a:1}]
      	, writeConcern:{w:1}
      	, ordered:false};
      result = coll.runCommand(request);
      jsTest.log(JSON.stringify(result, null, 2))
      assert.eq(0, result.ok);
      assert.eq(13, result.errCode);
      assert.eq('string', typeof result.errmsg);

      Show
      // // Ensures that mongod respects the batch write protocols // var request; var result;   print("START batch_write_command_auth.js");   var port = allocatePorts(1)[0]; var dbName = "batch_write_protocol_auth";   var mongoInstance = startMongod( "--auth", "--port", port, "--dbpath", "/data/db/" + dbName, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); var db = mongoInstance.getDB("test");   // Get the collection name var collectionName = "batch_write_protocol"; var coll = db.getCollection(collectionName);   // Get the test db we are running against and make sure it's gone var testDb = db[dbName]; testDb.drop();   // Drop all users on the db db.dropAllUsers();   // Add an admin user db.getSisterDB( "admin" ).addUser({user: "super", pwd: "super", roles: ["__system"] }); db.getSisterDB("admin").auth("super", "super"); // Add a standard user db.addUser({user: "guest" , pwd: "guest", roles: jsTest.readOnlyUserRoles}); // Add a read only user db.addUser({user: "eliot" , pwd: "eliot", roles: jsTest.basicUserRoles }); // Log out db.getSisterDB("admin").logout();   /** * Attempt to execute write batches without any authentication performed */   // // Single document insert, w:1 write concern specified, ordered:false request = {insert : collectionName , documents: [{a:1}] , writeConcern:{w:1} , ordered:false}; result = coll.runCommand(request); jsTest.log(JSON.stringify(result, null, 2)) assert.eq(0, result.ok); assert.eq(13, result.errCode); assert.eq('string', typeof result.errmsg);

    Description

      When performing an unauthorized write command it returns the wrong fields

      Attachments

        Activity

          People

            greg_10gen Greg Studer
            christkv Christian Amor Kvalheim
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: