Files
mongo/jstests/auth/auth3.js

33 lines
814 B
JavaScript
Raw Normal View History

(function() {
'use strict'
var conn = MongoRunner.runMongod({ auth: "" });
2011-11-11 12:14:23 -05:00
var admin = conn.getDB("admin");
var errorCodeUnauthorized = 13;
2011-11-11 12:14:23 -05:00
admin.createUser({user:"foo",pwd: "bar", roles: jsTest.adminUserRoles});
2011-11-11 12:14:23 -05:00
print("make sure curop, killop, and unlock fail");
var x = admin.$cmd.sys.inprog.findOne();
assert(!("inprog" in x), tojson(x));
2015-04-02 18:37:06 -04:00
assert.eq(x.code, errorCodeUnauthorized, tojson(x));
2011-11-11 12:14:23 -05:00
x = admin.killOp(123);
assert(!("info" in x), tojson(x));
2015-04-06 18:49:59 -04:00
assert.eq(x.code, errorCodeUnauthorized, tojson(x));
2011-11-11 12:14:23 -05:00
x = admin.fsyncUnlock();
assert(x.errmsg != "not locked", tojson(x));
assert.eq(x.code, errorCodeUnauthorized, tojson(x));
2011-11-11 12:14:23 -05:00
conn.getDB("admin").auth("foo","bar");
assert("inprog" in admin.currentOp());
assert("info" in admin.killOp(123));
assert.eq(admin.fsyncUnlock().errmsg, "not locked");
})();