summaryrefslogtreecommitdiff
path: root/jstests/tool/dumpauth.js
blob: 17cf5c19de7be12ab5f03fb83c2f7f867d8f9476 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// 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");