diff options
Diffstat (limited to 'jstests/replsets/auth1.js')
-rw-r--r-- | jstests/replsets/auth1.js | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/jstests/replsets/auth1.js b/jstests/replsets/auth1.js index 60e4b95..71ab2d9 100644 --- a/jstests/replsets/auth1.js +++ b/jstests/replsets/auth1.js @@ -3,17 +3,27 @@ load("jstests/replsets/rslib.js"); var name = "rs_auth1"; -var port = allocatePorts(4); -var path = "jstests/replsets/"; +var port = allocatePorts(5); +var path = "jstests/libs/"; + + +print("try starting mongod with auth"); +var m = runMongoProgram( "mongod", "--auth", "--port", port[4], "--dbpath", "/data/db/wrong-auth"); + +assert.throws(function() { + m.getDB("local").auth("__system", ""); +}); + +stopMongod(port[4]); + - print("reset permissions"); run("chmod", "644", path+"key1"); run("chmod", "644", path+"key2"); print("try starting mongod"); -var m = runMongoProgram( "mongod", "--keyFile", path+"key1", "--port", port[0], "--dbpath", "/data/db/" + name); +m = runMongoProgram( "mongod", "--keyFile", path+"key1", "--port", port[0], "--dbpath", "/data/db/" + name); print("should fail with wrong permissions"); @@ -81,6 +91,10 @@ function doQueryOn(p) { doQueryOn(slave); master.adminCommand({logout:1}); + +print("unauthorized:"); +printjson(master.adminCommand({replSetGetStatus : 1})); + doQueryOn(master); @@ -125,11 +139,12 @@ master.auth("bar", "baz"); for (var i=0; i<1000; i++) { master.foo.insert({x:i, foo : "bar"}); } -master.runCommand({getlasterror:1, w:3, wtimeout:60000}); +var result = master.runCommand({getlasterror:1, w:2, wtimeout:60000}); +printjson(result); print("resync"); -rs.restart(0); +rs.restart(0, {"keyFile" : path+"key1"}); print("add some more data 2"); @@ -159,7 +174,7 @@ master.getSisterDB("admin").auth("foo", "bar"); print("shouldn't ever sync"); -for (var i = 0; i<30; i++) { +for (var i = 0; i<10; i++) { print("iteration: " +i); var results = master.adminCommand({replSetGetStatus:1}); printjson(results); @@ -177,9 +192,15 @@ conn = new MongodRunner(port[3], "/data/db/"+name+"-3", null, null, ["--replSet" conn.start(); wait(function() { + try { var results = master.adminCommand({replSetGetStatus:1}); printjson(results); return results.members[3].state == 2; + } + catch (e) { + print(e); + } + return false; }); print("make sure it has the config, too"); |