2013-05-29 11:49:53 -04:00
|
|
|
var conn1 = MongoRunner.runMongod({ auth: "",
|
|
|
|
|
smallfiles: "",
|
|
|
|
|
setParameter: "enableLocalhostAuthBypass=true"});
|
|
|
|
|
var conn2 = MongoRunner.runMongod({ auth: "",
|
|
|
|
|
smallfiles: "",
|
|
|
|
|
setParameter: "enableLocalhostAuthBypass=false"});
|
|
|
|
|
|
2014-04-21 18:43:25 -04:00
|
|
|
// Should fail because of localhost exception narrowed (SERVER-12621).
|
|
|
|
|
assert.writeError(conn1.getDB("test").foo.insert({a:1}));
|
|
|
|
|
assert.throws(function() { conn2.getDB("test").foo.findOne(); });
|
|
|
|
|
|
|
|
|
|
// Should succeed due to localhost exception.
|
|
|
|
|
conn1.getDB("admin").createUser({user: "root", pwd: "pass", roles: ["root"]});
|
|
|
|
|
|
|
|
|
|
conn1.getDB("admin").auth("root", "pass");
|
2013-05-29 11:49:53 -04:00
|
|
|
conn1.getDB("test").foo.insert({a:1});
|
2014-04-21 18:43:25 -04:00
|
|
|
|
|
|
|
|
conn1.getDB("admin").dropAllUsers();
|
|
|
|
|
conn1.getDB("admin").logout();
|
|
|
|
|
|
|
|
|
|
assert.throws(function() { conn2.getDB("test").foo.findOne(); });
|
2013-05-29 11:49:53 -04:00
|
|
|
|
|
|
|
|
// Should fail since localhost exception is disabled
|
2014-04-21 18:43:25 -04:00
|
|
|
assert.throws(function() {
|
|
|
|
|
conn2.getDB("admin").createUser({user: "root", pwd: "pass", roles: ["root"]});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
print("SUCCESS Completed disable_localhost_bypass.js");
|