summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/server7428.js
blob: 7b5278a10e1e67e5c958fa119c6b4cf4656896f4 (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
// Regression test for SERVER-7428.

// TODO(spencer): move this test out of slowNightly directory once there is a better place for tests
// that start their own mongod's but aren't slow

// Verify that the copyDatabase command works appropriately when the
// target mongo instance has authentication enabled.

(function() {

    // Setup fromDb with no auth
    var fromDb = MongoRunner.runMongod();

    // Setup toDb with auth
    var toDb = MongoRunner.runMongod({auth: ""});
    var admin = toDb.getDB("admin");
    admin.createUser({user: "foo", pwd: "bar", roles: jsTest.adminUserRoles});
    admin.auth("foo", "bar");

    admin.copyDatabase('test', 'test', fromDb.host);

    MongoRunner.stopMongod(fromDb);
    MongoRunner.stopMongod(toDb);
})();