summaryrefslogtreecommitdiff
path: root/jstests/auth/repl.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/auth/repl.js')
-rw-r--r--jstests/auth/repl.js65
1 files changed, 29 insertions, 36 deletions
diff --git a/jstests/auth/repl.js b/jstests/auth/repl.js
index 1ed13ad1400..17ab3c2db20 100644
--- a/jstests/auth/repl.js
+++ b/jstests/auth/repl.js
@@ -3,7 +3,10 @@
var baseName = "jstests_auth_repl";
var rsName = baseName + "_rs";
var rtName = baseName + "_rt";
-var mongoOptions = {auth: null, keyFile: "jstests/libs/key1"};
+var mongoOptions = {
+ auth: null,
+ keyFile: "jstests/libs/key1"
+};
var authErrCode = 13;
var AuthReplTest = function(spec) {
@@ -73,20 +76,15 @@ var AuthReplTest = function(spec) {
var updateRole = function() {
var res = adminPri.runCommand({
updateRole: testRole,
- privileges: [
- { resource: {cluster: true}, actions: ["listDatabases"] }
- ],
+ privileges: [{resource: {cluster: true}, actions: ["listDatabases"]}],
writeConcern: {w: 2, wtimeout: 15000}
});
assert.commandWorked(res);
};
var updateUser = function() {
- var res = adminPri.runCommand({
- updateUser: testUser,
- roles: [testRole2],
- writeConcern: {w: 2, wtimeout: 15000}
- });
+ var res = adminPri.runCommand(
+ {updateUser: testUser, roles: [testRole2], writeConcern: {w: 2, wtimeout: 15000}});
assert.commandWorked(res);
};
@@ -108,11 +106,10 @@ var AuthReplTest = function(spec) {
* Remove test users and roles
*/
var cleanup = function() {
- var res = adminPri.runCommand({dropUser: testUser,
- writeConcern: {w: 2, wtimeout: 15000}});
+ var res = adminPri.runCommand({dropUser: testUser, writeConcern: {w: 2, wtimeout: 15000}});
assert.commandWorked(res);
- res = adminPri.runCommand({dropAllRolesFromDatabase: 1,
- writeConcern: {w: 2, wtimeout: 15000}});
+ res = adminPri.runCommand(
+ {dropAllRolesFromDatabase: 1, writeConcern: {w: 2, wtimeout: 15000}});
assert.commandWorked(res);
};
@@ -137,10 +134,8 @@ var AuthReplTest = function(spec) {
for (var i = 0; i < roles.length; i++) {
var res = adminPri.runCommand({
createRole: roles[i],
- privileges: [
- { resource: {cluster: true}, actions: [ actions[i] ] }
- ],
- roles: [ ],
+ privileges: [{resource: {cluster: true}, actions: [actions[i]]}],
+ roles: [],
writeConcern: {w: numNodes, wtimeout: 15000}
});
assert.commandWorked(res);
@@ -168,11 +163,11 @@ var AuthReplTest = function(spec) {
updateRole();
confirmPrivilegeAfterUpdate();
confirmRolesInfo("listDatabases");
-
+
updateUser();
confirmPrivilegeAfterUpdate();
confirmUsersInfo(testRole2);
-
+
cleanup();
};
@@ -183,31 +178,33 @@ jsTest.log("1 test replica sets");
var rs = new ReplSetTest({name: rsName, nodes: 2});
var nodes = rs.startSet(mongoOptions);
rs.initiate();
-authutil.asCluster(nodes, "jstests/libs/key1", function() { rs.awaitReplication(); });
+authutil.asCluster(nodes,
+ "jstests/libs/key1",
+ function() {
+ rs.awaitReplication();
+ });
var primary = rs.getPrimary();
var secondary = rs.getSecondary();
-var authReplTest = AuthReplTest({
- primaryConn: primary,
- secondaryConn: secondary
-});
+var authReplTest = AuthReplTest({primaryConn: primary, secondaryConn: secondary});
authReplTest.createUserAndRoles(2);
authReplTest.testAll();
rs.stopSet();
-jsTest.log("2 test initial sync");
+jsTest.log("2 test initial sync");
rs = new ReplSetTest({name: rsName, nodes: 1, nodeOptions: mongoOptions});
nodes = rs.startSet();
rs.initiate();
-authutil.asCluster(nodes, "jstests/libs/key1", function() { rs.awaitReplication(); });
+authutil.asCluster(nodes,
+ "jstests/libs/key1",
+ function() {
+ rs.awaitReplication();
+ });
primary = rs.getPrimary();
-var authReplTest = AuthReplTest({
- primaryConn: primary,
- secondaryConn: null
-});
+var authReplTest = AuthReplTest({primaryConn: primary, secondaryConn: null});
authReplTest.createUserAndRoles(1);
// Add a secondary and wait for initial sync
@@ -239,14 +236,10 @@ masterDB.createUser({user: "root", pwd: "pass", roles: ["root"]});
masterDB.auth("root", "pass");
// ensure that master/slave replication is up and running
-masterDB.foo.save({}, { writeConcern: { w: 2, wtimeout: 15000 }});
+masterDB.foo.save({}, {writeConcern: {w: 2, wtimeout: 15000}});
masterDB.foo.drop();
-authReplTest = AuthReplTest({
- primaryConn: master,
- secondaryConn: slave
-});
+authReplTest = AuthReplTest({primaryConn: master, secondaryConn: slave});
authReplTest.createUserAndRoles(2);
authReplTest.testAll();
rt.stop();
-