diff options
author | clang-format-7.0.1 <adam.martin@10gen.com> | 2019-07-26 18:42:24 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-07-26 18:42:24 -0400 |
commit | c1a45ebbb0530e3d0201321d725527f1eb83ffce (patch) | |
tree | f523079dc5ded3052eefbdcaae424b7502df5b25 /jstests/auth/usersInfo.js | |
parent | c9599d8610c3da0b7c3da65667aff821063cf5b9 (diff) | |
download | mongo-c1a45ebbb0530e3d0201321d725527f1eb83ffce.tar.gz |
Apply formatting per `clang-format-7.0.1`
Diffstat (limited to 'jstests/auth/usersInfo.js')
-rw-r--r-- | jstests/auth/usersInfo.js | 83 |
1 files changed, 41 insertions, 42 deletions
diff --git a/jstests/auth/usersInfo.js b/jstests/auth/usersInfo.js index fdd4a1b0a5f..81b9b4ee870 100644 --- a/jstests/auth/usersInfo.js +++ b/jstests/auth/usersInfo.js @@ -1,47 +1,46 @@ // Test behavior and edge cases in usersInfo (function() { - 'use strict'; - - function runTest(conn) { - let db = conn.getDB("test"); - let emptyDB = conn.getDB("test2"); - let otherDB = conn.getDB("other"); - - const userCount = 200; - for (let i = 0; i < userCount; ++i) { - assert.commandWorked(db.runCommand({createUser: "user" + i, pwd: "pwd", roles: []})); - } - assert.commandWorked(otherDB.runCommand({createUser: "otherUser", pwd: "pwd", roles: []})); - - // Check info for all users on the "test" database. - const allTestInfo = assert.commandWorked(db.runCommand({usersInfo: 1})); - assert.eq(userCount, allTestInfo.users.length); - - // Check we can find a particular user on the "test" database. - assert.eq(1, assert.commandWorked(db.runCommand({usersInfo: "user12"})).users.length); - assert.eq(1, - assert.commandWorked(db.runCommand({usersInfo: {user: "user12", db: "test"}})) - .users.length); - assert.eq(0, - assert.commandWorked(db.runCommand({usersInfo: {user: "user12", db: "test2"}})) - .users.length); - assert.eq(0, assert.commandWorked(emptyDB.runCommand({usersInfo: "user12"})).users.length); - - // No users are found on a database without users. - assert.eq(0, assert.commandWorked(emptyDB.runCommand({usersInfo: 1})).users.length); - - // Check that we can find records for all users on all databases. - const allInfo = assert.commandWorked(db.runCommand({usersInfo: {forAllDBs: true}})); - assert.eq(userCount + 1, allInfo.users.length); - } +'use strict'; - const m = MongoRunner.runMongod(); - runTest(m); - MongoRunner.stopMongod(m); +function runTest(conn) { + let db = conn.getDB("test"); + let emptyDB = conn.getDB("test2"); + let otherDB = conn.getDB("other"); - // TODO: Remove 'shardAsReplicaSet: false' when SERVER-32672 is fixed. - const st = - new ShardingTest({shards: 1, mongos: 1, config: 1, other: {shardAsReplicaSet: false}}); - runTest(st.s0); - st.stop(); + const userCount = 200; + for (let i = 0; i < userCount; ++i) { + assert.commandWorked(db.runCommand({createUser: "user" + i, pwd: "pwd", roles: []})); + } + assert.commandWorked(otherDB.runCommand({createUser: "otherUser", pwd: "pwd", roles: []})); + + // Check info for all users on the "test" database. + const allTestInfo = assert.commandWorked(db.runCommand({usersInfo: 1})); + assert.eq(userCount, allTestInfo.users.length); + + // Check we can find a particular user on the "test" database. + assert.eq(1, assert.commandWorked(db.runCommand({usersInfo: "user12"})).users.length); + assert.eq(1, + assert.commandWorked(db.runCommand({usersInfo: {user: "user12", db: "test"}})) + .users.length); + assert.eq(0, + assert.commandWorked(db.runCommand({usersInfo: {user: "user12", db: "test2"}})) + .users.length); + assert.eq(0, assert.commandWorked(emptyDB.runCommand({usersInfo: "user12"})).users.length); + + // No users are found on a database without users. + assert.eq(0, assert.commandWorked(emptyDB.runCommand({usersInfo: 1})).users.length); + + // Check that we can find records for all users on all databases. + const allInfo = assert.commandWorked(db.runCommand({usersInfo: {forAllDBs: true}})); + assert.eq(userCount + 1, allInfo.users.length); +} + +const m = MongoRunner.runMongod(); +runTest(m); +MongoRunner.stopMongod(m); + +// TODO: Remove 'shardAsReplicaSet: false' when SERVER-32672 is fixed. +const st = new ShardingTest({shards: 1, mongos: 1, config: 1, other: {shardAsReplicaSet: false}}); +runTest(st.s0); +st.stop(); }()); |