summaryrefslogtreecommitdiff
path: root/jstests/replsets/auth2.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/replsets/auth2.js')
-rw-r--r--jstests/replsets/auth2.js36
1 files changed, 19 insertions, 17 deletions
diff --git a/jstests/replsets/auth2.js b/jstests/replsets/auth2.js
index b7776d94572..f7b8d8ab468 100644
--- a/jstests/replsets/auth2.js
+++ b/jstests/replsets/auth2.js
@@ -18,39 +18,41 @@ var testInvalidAuthStates = function() {
rs.waitForState(rs.nodes[0], ReplSetTest.State.SECONDARY);
- rs.restart(1, {"keyFile" : key1});
- rs.restart(2, {"keyFile" : key1});
+ rs.restart(1, {"keyFile": key1});
+ rs.restart(2, {"keyFile": key1});
};
var name = "rs_auth2";
var path = "jstests/libs/";
// These keyFiles have their permissions set to 600 later in the test.
-var key1 = path+"key1";
-var key2 = path+"key2";
+var key1 = path + "key1";
+var key2 = path + "key2";
var rs = new ReplSetTest({name: name, nodes: 3});
var nodes = rs.startSet();
var hostnames = rs.nodeList();
-rs.initiate({ "_id" : name,
- "members" : [
- {"_id" : 0, "host" : hostnames[0], "priority" : 2},
- {"_id" : 1, "host" : hostnames[1], priority: 0},
- {"_id" : 2, "host" : hostnames[2], priority: 0}
- ]});
+rs.initiate({
+ "_id": name,
+ "members": [
+ {"_id": 0, "host": hostnames[0], "priority": 2},
+ {"_id": 1, "host": hostnames[1], priority: 0},
+ {"_id": 2, "host": hostnames[2], priority: 0}
+ ]
+});
var master = rs.getPrimary();
print("add an admin user");
-master.getDB("admin").createUser({user: "foo", pwd: "bar", roles: jsTest.adminUserRoles},
- {w: 3, wtimeout: 30000});
+master.getDB("admin")
+ .createUser({user: "foo", pwd: "bar", roles: jsTest.adminUserRoles}, {w: 3, wtimeout: 30000});
var m = rs.nodes[0];
print("starting 1 and 2 with key file");
rs.stop(1);
-rs.restart(1, {"keyFile" : key1});
+rs.restart(1, {"keyFile": key1});
rs.stop(2);
-rs.restart(2, {"keyFile" : key1});
+rs.restart(2, {"keyFile": key1});
// auth to all nodes with auth
rs.nodes[1].getDB("admin").auth("foo", "bar");
@@ -60,15 +62,15 @@ testInvalidAuthStates();
print("restart mongod with bad keyFile");
rs.stop(0);
-m = rs.restart(0, {"keyFile" : key2});
+m = rs.restart(0, {"keyFile": key2});
-//auth to all nodes
+// auth to all nodes
rs.nodes[0].getDB("admin").auth("foo", "bar");
rs.nodes[1].getDB("admin").auth("foo", "bar");
rs.nodes[2].getDB("admin").auth("foo", "bar");
testInvalidAuthStates();
rs.stop(0);
-m = rs.restart(0, {"keyFile" : key1});
+m = rs.restart(0, {"keyFile": key1});
print("0 becomes a secondary");