Files
mongo/jstests/auth/auth3.js

33 lines
892 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");
2011-11-11 12:14:23 -05:00
var x = admin.$cmd.sys.inprog.findOne();
assert(!("inprog" in x), tojson(x));
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));
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");
2011-11-11 12:14:23 -05:00
assert("inprog" in admin.currentOp());
assert("info" in admin.killOp(123));
assert.eq(admin.fsyncUnlock().errmsg, "not locked");
})();