summaryrefslogtreecommitdiff
path: root/jstests/auth/auth3.js
blob: 29f61f1c7eea6828797d75c985b53f4cf6d86dac (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
27
28
29
30
31
32
33
(function() {

'use strict';

var conn = MongoRunner.runMongod({auth: ""});

var admin = conn.getDB("admin");
var errorCodeUnauthorized = 13;

admin.createUser({user: "foo", pwd: "bar", roles: jsTest.adminUserRoles});

print("make sure curop, killop, and unlock fail");

var x = admin.currentOp();
assert(!("inprog" in x), tojson(x));
assert.eq(x.code, errorCodeUnauthorized, tojson(x));

x = admin.killOp(123);
assert(!("info" in x), tojson(x));
assert.eq(x.code, errorCodeUnauthorized, tojson(x));

x = admin.fsyncUnlock();
assert(x.errmsg != "fsyncUnlock called when not locked", tojson(x));
assert.eq(x.code, errorCodeUnauthorized, tojson(x));

conn.getDB("admin").auth("foo", "bar");

assert("inprog" in admin.currentOp());
assert("info" in admin.killOp(123));
assert.eq(admin.fsyncUnlock().errmsg, "fsyncUnlock called when not locked");

MongoRunner.stopMongod(conn, null, {user: "foo", pwd: "bar"});
})();