Files
mongo/jstests/tool/dumpauth.js
Gabriel Russell 223b4e28b6 TOOLS-833 disable unreliable dump to stdout test
o Its actually not ok to run any programs with runMongoProgram
  that write binary data to standard output
2015-07-23 15:25:36 -04:00

27 lines
782 B
JavaScript

// dumpauth.js
// test mongodump with authentication
var m = MongoRunner.runMongod({auth: "", bind_ip: "127.0.0.1"});
var dbName = "admin"
var colName = "testcol"
db = m.getDB(dbName);
db.createUser({user: "testuser" , pwd: "testuser", roles: jsTest.adminUserRoles});
assert( db.auth( "testuser" , "testuser" ) , "auth failed" );
t = db[colName];
t.drop();
for(var i = 0; i < 100; i++) {
t.save({ "x": i });
}
x = runMongoProgram( "mongodump",
"--db", dbName,
"--authenticationDatabase=admin",
"-u", "testuser",
"-p", "testuser",
"-h", "127.0.0.1:"+m.port,
"--collection", colName);
assert.eq(x, 0, "mongodump should succeed with authentication");