2011-09-07 18:10:34 +02:00
|
|
|
// test read/write permissions
|
|
|
|
|
2018-06-20 22:56:05 +02:00
|
|
|
m = MongoRunner.runMongod({auth: "", bind_ip: "127.0.0.1"});
|
2016-03-09 18:17:50 +01:00
|
|
|
db = m.getDB("admin");
|
2011-09-07 18:10:34 +02:00
|
|
|
|
2014-04-22 00:43:25 +02:00
|
|
|
// These statements throw because the localhost exception does not allow
|
|
|
|
// these operations: it only allows the creation of the first admin user
|
|
|
|
// and necessary setup operations.
|
2016-03-09 18:17:50 +01:00
|
|
|
assert.throws(function() {
|
|
|
|
db.users.count();
|
|
|
|
});
|
|
|
|
assert.throws(function() {
|
|
|
|
db.shutdownServer();
|
|
|
|
});
|
2011-09-07 18:10:34 +02:00
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
db.createUser({user: "eliot", pwd: "eliot", roles: ["root"]});
|
2011-09-07 18:10:34 +02:00
|
|
|
|
2014-04-22 00:43:25 +02:00
|
|
|
// These statements throw because we have a user but have not authenticated
|
|
|
|
// as that user.
|
2016-03-09 18:17:50 +01:00
|
|
|
assert.throws(function() {
|
|
|
|
db.users.count();
|
|
|
|
});
|
|
|
|
assert.throws(function() {
|
|
|
|
db.shutdownServer();
|
|
|
|
});
|
2011-09-07 18:10:34 +02:00
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
db.auth("eliot", "eliot");
|
2011-09-07 18:10:34 +02:00
|
|
|
|
2016-03-09 18:17:50 +01:00
|
|
|
users = db.getCollection("system.users");
|
|
|
|
assert.eq(1, users.count());
|
2011-09-07 18:10:34 +02:00
|
|
|
|
|
|
|
db.shutdownServer();
|
2018-07-05 07:59:19 +02:00
|
|
|
waitProgram(m.pid);
|