diff options
author | clang-format-7.0.1 <adam.martin@10gen.com> | 2019-07-26 18:20:35 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-07-27 11:02:23 -0400 |
commit | 134a4083953270e8a11430395357fb70a29047ad (patch) | |
tree | dd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/core/list_sessions.js | |
parent | 1e46b5049003f427047e723ea5fab15b5a9253ca (diff) | |
download | mongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz |
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/core/list_sessions.js')
-rw-r--r-- | jstests/core/list_sessions.js | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/jstests/core/list_sessions.js b/jstests/core/list_sessions.js index 9b04d3c1aa5..65345ca7c01 100644 --- a/jstests/core/list_sessions.js +++ b/jstests/core/list_sessions.js @@ -8,65 +8,65 @@ // Basic tests for the $listSessions aggregation stage. (function() { - 'use strict'; - load('jstests/aggregation/extras/utils.js'); +'use strict'; +load('jstests/aggregation/extras/utils.js'); - const admin = db.getSiblingDB('admin'); - const config = db.getSiblingDB('config'); - const pipeline = [{'$listSessions': {}}]; - function listSessions() { - return config.system.sessions.aggregate(pipeline); - } +const admin = db.getSiblingDB('admin'); +const config = db.getSiblingDB('config'); +const pipeline = [{'$listSessions': {}}]; +function listSessions() { + return config.system.sessions.aggregate(pipeline); +} - // Start a new session and capture its sessionId. - const myid = assert.commandWorked(admin.runCommand({startSession: 1})).id.id; - assert(myid !== undefined); +// Start a new session and capture its sessionId. +const myid = assert.commandWorked(admin.runCommand({startSession: 1})).id.id; +assert(myid !== undefined); - // Sync cache to collection and ensure it arrived. - assert.commandWorked(admin.runCommand({refreshLogicalSessionCacheNow: 1})); - var resultArrayMine; - assert.soon(function() { - const resultArray = listSessions().toArray(); - if (resultArray.length < 1) { - return false; - } - resultArrayMine = resultArray - .map(function(sess) { - return sess._id; - }) - .filter(function(id) { - return 0 == bsonWoCompare({x: id.id}, {x: myid}); - }); - return resultArrayMine.length == 1; - }, "Failed to locate session in collection"); +// Sync cache to collection and ensure it arrived. +assert.commandWorked(admin.runCommand({refreshLogicalSessionCacheNow: 1})); +var resultArrayMine; +assert.soon(function() { + const resultArray = listSessions().toArray(); + if (resultArray.length < 1) { + return false; + } + resultArrayMine = resultArray + .map(function(sess) { + return sess._id; + }) + .filter(function(id) { + return 0 == bsonWoCompare({x: id.id}, {x: myid}); + }); + return resultArrayMine.length == 1; +}, "Failed to locate session in collection"); - // Try asking for the session by username. - const myusername = (function() { - if (0 == bsonWoCompare({x: resultArrayMine[0].uid}, {x: computeSHA256Block("")})) { - // Code for "we're running in no-auth mode" - return {user: "", db: ""}; - } - const connstats = assert.commandWorked(db.runCommand({connectionStatus: 1})); - const authUsers = connstats.authInfo.authenticatedUsers; - assert(authUsers !== undefined); - assert.eq(authUsers.length, 1); - assert(authUsers[0].user !== undefined); - assert(authUsers[0].db !== undefined); - return {user: authUsers[0].user, db: authUsers[0].db}; - })(); - function listMySessions() { - return config.system.sessions.aggregate([{'$listSessions': {users: [myusername]}}]); +// Try asking for the session by username. +const myusername = (function() { + if (0 == bsonWoCompare({x: resultArrayMine[0].uid}, {x: computeSHA256Block("")})) { + // Code for "we're running in no-auth mode" + return {user: "", db: ""}; } - const myArray = listMySessions() - .toArray() - .map(function(sess) { - return sess._id; - }) - .filter(function(id) { - return 0 == bsonWoCompare({x: id.id}, {x: myid}); - }); - assert.eq(0, bsonWoCompare(myArray, resultArrayMine)); + const connstats = assert.commandWorked(db.runCommand({connectionStatus: 1})); + const authUsers = connstats.authInfo.authenticatedUsers; + assert(authUsers !== undefined); + assert.eq(authUsers.length, 1); + assert(authUsers[0].user !== undefined); + assert(authUsers[0].db !== undefined); + return {user: authUsers[0].user, db: authUsers[0].db}; +})(); +function listMySessions() { + return config.system.sessions.aggregate([{'$listSessions': {users: [myusername]}}]); +} +const myArray = listMySessions() + .toArray() + .map(function(sess) { + return sess._id; + }) + .filter(function(id) { + return 0 == bsonWoCompare({x: id.id}, {x: myid}); + }); +assert.eq(0, bsonWoCompare(myArray, resultArrayMine)); - // Make sure pipelining other collections fail. - assertErrorCode(admin.system.collections, pipeline, ErrorCodes.InvalidNamespace); +// Make sure pipelining other collections fail. +assertErrorCode(admin.system.collections, pipeline, ErrorCodes.InvalidNamespace); })(); |