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

Write command authentication returning wrong fields on error

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.5.4
    • Component/s: None
    • Labels:
    • 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);

      When performing an unauthorized write command it returns the wrong fields

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

              Created:
              Updated:
              Resolved: