diff options
author | Spencer T Brody <spencer@mongodb.com> | 2014-04-01 14:07:20 -0400 |
---|---|---|
committer | Spencer T Brody <spencer@mongodb.com> | 2014-04-03 12:54:51 -0400 |
commit | abf252cfe8833ab15dc8d62e8e05a30108484508 (patch) | |
tree | af291cf527983ac6ef0929a8f7eeb92c331cdc3b | |
parent | 93b962665da9d3163cacaf55817d8d60a957a32a (diff) | |
download | mongo-abf252cfe8833ab15dc8d62e8e05a30108484508.tar.gz |
SERVER-13441 getUser and getRole shell helpers shouldn't throw when user/role not found
-rw-r--r-- | jstests/auth/user_defined_roles_on_secondaries.js | 2 | ||||
-rw-r--r-- | jstests/core/role_management_helpers.js | 8 | ||||
-rw-r--r-- | jstests/core/user_management_helpers.js | 2 | ||||
-rw-r--r-- | src/mongo/shell/db.js | 4 |
4 files changed, 8 insertions, 8 deletions
diff --git a/jstests/auth/user_defined_roles_on_secondaries.js b/jstests/auth/user_defined_roles_on_secondaries.js index eb51445616a..1ef357fb2d8 100644 --- a/jstests/auth/user_defined_roles_on_secondaries.js +++ b/jstests/auth/user_defined_roles_on_secondaries.js @@ -129,7 +129,7 @@ rstest.nodes.forEach(function (node) { // Verify that dropping roles propagates. rstest.getMaster().getDB("db1").dropRole("r2", { w: 2}); rstest.nodes.forEach(function (node) { - assert.throws(function() { node.getDB("db1").getRole("r2") }, [], node); + assert.eq(null, node.getDB("db1").getRole("r2")); var role = node.getDB("db1").getRole("r3"); assert.eq(1, role.roles.length, node); assertListContainsRole(role.roles, {role: "r1", db: "db1"}, node); diff --git a/jstests/core/role_management_helpers.js b/jstests/core/role_management_helpers.js index 1cb821975ef..761bd61e77b 100644 --- a/jstests/core/role_management_helpers.js +++ b/jstests/core/role_management_helpers.js @@ -123,15 +123,15 @@ function assertHasPrivilege(privilegeArray, privilege) { // Test dropRole db.dropRole('roleC'); - assert.throws(function() {db.getRole('roleC')}); + assert.eq(null, db.getRole('roleC')); roleObj = db.getRole("roleB", {showPrivileges: true}); assert.eq(0, roleObj.privileges.length); assert.eq(0, roleObj.roles.length); // Test dropAllRoles db.dropAllRoles(); - assert.throws(function() {db.getRole('roleA')}); - assert.throws(function() {db.getRole('roleB')}); - assert.throws(function() {db.getRole('roleC')}); + assert.eq(null, db.getRole('roleA')); + assert.eq(null, db.getRole('roleB')); + assert.eq(null, db.getRole('roleC')); }(db));
\ No newline at end of file diff --git a/jstests/core/user_management_helpers.js b/jstests/core/user_management_helpers.js index 50707f584ab..b79f15e1816 100644 --- a/jstests/core/user_management_helpers.js +++ b/jstests/core/user_management_helpers.js @@ -65,7 +65,7 @@ function assertHasRole(rolesArray, roleName, roleDB) { // Test dropUser db.dropUser('andy'); - assert.throws(function() {printjson(db.getUser('andy'));}); + assert.eq(null, db.getUser('andy')); // Test dropAllUsers db.dropAllUsers() diff --git a/src/mongo/shell/db.js b/src/mongo/shell/db.js index d656a7703f8..e9572e7d8cb 100644 --- a/src/mongo/shell/db.js +++ b/src/mongo/shell/db.js @@ -1261,7 +1261,7 @@ DB.prototype.getUser = function(username, args) { } if (res.users.length == 0) { - throw Error("User " + username + "@" + db.getName() + " not found"); + return null; } return res.users[0]; } @@ -1388,7 +1388,7 @@ DB.prototype.getRole = function(rolename, args) { } if (res.roles.length == 0) { - throw Error("Role " + rolename + "@" + db.getName() + " not found"); + return null; } return res.roles[0]; } |