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/auth/keyfile_rollover.js | |
parent | 1e46b5049003f427047e723ea5fab15b5a9253ca (diff) | |
download | mongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz |
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/auth/keyfile_rollover.js')
-rw-r--r-- | jstests/auth/keyfile_rollover.js | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/jstests/auth/keyfile_rollover.js b/jstests/auth/keyfile_rollover.js index bbc704797ad..ea66397d8c8 100644 --- a/jstests/auth/keyfile_rollover.js +++ b/jstests/auth/keyfile_rollover.js @@ -11,82 +11,82 @@ TestData.skipGossipingClusterTime = true; (function() { - 'use strict'; +'use strict'; - let rst = new ReplSetTest({nodes: 3, keyFile: "jstests/libs/key1"}); - rst.startSet(); - rst.initiate(); +let rst = new ReplSetTest({nodes: 3, keyFile: "jstests/libs/key1"}); +rst.startSet(); +rst.initiate(); - const runPrimaryTest = function(fn) { - const curPrimary = rst.getPrimary(); - assert(curPrimary.getDB("admin").auth("root", "root")); - try { - fn(curPrimary); - rst.awaitSecondaryNodes(); - } finally { - curPrimary.getDB("admin").logout(); - } - }; +const runPrimaryTest = function(fn) { + const curPrimary = rst.getPrimary(); + assert(curPrimary.getDB("admin").auth("root", "root")); + try { + fn(curPrimary); + rst.awaitSecondaryNodes(); + } finally { + curPrimary.getDB("admin").logout(); + } +}; - // Create a user to login as when auth is enabled later - rst.getPrimary().getDB('admin').createUser({user: 'root', pwd: 'root', roles: ['root']}); - - runPrimaryTest((curPrimary) => { - assert.writeOK(curPrimary.getDB('test').a.insert({a: 1, str: 'TESTTESTTEST'})); - assert.eq(1, curPrimary.getDB('test').a.count(), 'Error interacting with replSet'); - }); +// Create a user to login as when auth is enabled later +rst.getPrimary().getDB('admin').createUser({user: 'root', pwd: 'root', roles: ['root']}); - jsTestLog("Using keyForRollover to transition auth to both keys"); +runPrimaryTest((curPrimary) => { + assert.writeOK(curPrimary.getDB('test').a.insert({a: 1, str: 'TESTTESTTEST'})); + assert.eq(1, curPrimary.getDB('test').a.count(), 'Error interacting with replSet'); +}); - /* - * This rolls over the cluster from one keyfile to another. The first argument is the keyfile - * servers should use, and the second is the keyfile the shell should use to authenticate - * with the servers. - */ - const rolloverKey = function(keyFileForServers, keyFileForAuth) { - // Update the keyFile parameter for the ReplSetTest as a whole - rst.keyFile = keyFileForServers; - // Function to restart a node with a new keyfile parameter and wait for secondaries - // to come back online - const restart = function(node) { - const nodeId = rst.getNodeId(node); - rst.stop(nodeId); - rst.start(nodeId, {keyFile: keyFileForServers}); - authutil.asCluster(rst.nodes, keyFileForAuth, () => { - rst.awaitSecondaryNodes(); - }); - }; +jsTestLog("Using keyForRollover to transition auth to both keys"); - // First we restart the secondaries. - rst.getSecondaries().forEach(function(secondary) { - restart(secondary); - }); - - // Then we restart the primary and wait for it to come back up with an ismaster call. - const primary = rst.getPrimary(); - restart(primary); - assert.soonNoExcept(() => { - authutil.asCluster(rst.nodes, keyFileForAuth, () => { - assert.commandWorked(primary.getDB("admin").runCommand({isMaster: 1})); - }); - return true; +/* + * This rolls over the cluster from one keyfile to another. The first argument is the keyfile + * servers should use, and the second is the keyfile the shell should use to authenticate + * with the servers. + */ +const rolloverKey = function(keyFileForServers, keyFileForAuth) { + // Update the keyFile parameter for the ReplSetTest as a whole + rst.keyFile = keyFileForServers; + // Function to restart a node with a new keyfile parameter and wait for secondaries + // to come back online + const restart = function(node) { + const nodeId = rst.getNodeId(node); + rst.stop(nodeId); + rst.start(nodeId, {keyFile: keyFileForServers}); + authutil.asCluster(rst.nodes, keyFileForAuth, () => { + rst.awaitSecondaryNodes(); }); }; - rolloverKey("jstests/libs/keyForRollover", "jstests/libs/key1"); + // First we restart the secondaries. + rst.getSecondaries().forEach(function(secondary) { + restart(secondary); + }); - runPrimaryTest((curPrimary) => { - assert.writeOK(curPrimary.getDB('test').a.insert({a: 1, str: 'TESTTESTTEST'})); - assert.eq(2, curPrimary.getDB('test').a.count(), 'Error interacting with replSet'); + // Then we restart the primary and wait for it to come back up with an ismaster call. + const primary = rst.getPrimary(); + restart(primary); + assert.soonNoExcept(() => { + authutil.asCluster(rst.nodes, keyFileForAuth, () => { + assert.commandWorked(primary.getDB("admin").runCommand({isMaster: 1})); + }); + return true; }); +}; - jsTestLog("Upgrading set to use key2"); - rolloverKey("jstests/libs/key2", "jstests/libs/key2"); +rolloverKey("jstests/libs/keyForRollover", "jstests/libs/key1"); - runPrimaryTest((curPrimary) => { - assert.writeOK(curPrimary.getDB('test').a.insert({a: 1, str: 'TESTTESTTEST'})); - assert.eq(3, curPrimary.getDB('test').a.count(), 'Error interacting with replSet'); - }); +runPrimaryTest((curPrimary) => { + assert.writeOK(curPrimary.getDB('test').a.insert({a: 1, str: 'TESTTESTTEST'})); + assert.eq(2, curPrimary.getDB('test').a.count(), 'Error interacting with replSet'); +}); + +jsTestLog("Upgrading set to use key2"); +rolloverKey("jstests/libs/key2", "jstests/libs/key2"); + +runPrimaryTest((curPrimary) => { + assert.writeOK(curPrimary.getDB('test').a.insert({a: 1, str: 'TESTTESTTEST'})); + assert.eq(3, curPrimary.getDB('test').a.count(), 'Error interacting with replSet'); +}); - rst.stopSet(); +rst.stopSet(); })(); |