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/sharding/authmr.js | |
parent | 1e46b5049003f427047e723ea5fab15b5a9253ca (diff) | |
download | mongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz |
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/sharding/authmr.js')
-rw-r--r-- | jstests/sharding/authmr.js | 217 |
1 files changed, 108 insertions, 109 deletions
diff --git a/jstests/sharding/authmr.js b/jstests/sharding/authmr.js index 0f444f6208d..0d1fb713c97 100644 --- a/jstests/sharding/authmr.js +++ b/jstests/sharding/authmr.js @@ -3,115 +3,114 @@ (function() { - // - // User document declarations. All users in this test are added to the admin database. - // - - var adminUser = { - user: "admin", - pwd: "a", - roles: - ["readWriteAnyDatabase", "dbAdminAnyDatabase", "userAdminAnyDatabase", "clusterAdmin"] - }; - - var test1User = { - user: "test", - pwd: "a", - roles: [{role: 'readWrite', db: 'test1', hasRole: true, canDelegate: false}] - }; - - function assertRemove(collection, pattern) { - assert.writeOK(collection.remove(pattern)); - } - - function assertInsert(collection, obj) { - assert.writeOK(collection.insert(obj)); +// +// User document declarations. All users in this test are added to the admin database. +// + +var adminUser = { + user: "admin", + pwd: "a", + roles: ["readWriteAnyDatabase", "dbAdminAnyDatabase", "userAdminAnyDatabase", "clusterAdmin"] +}; + +var test1User = { + user: "test", + pwd: "a", + roles: [{role: 'readWrite', db: 'test1', hasRole: true, canDelegate: false}] +}; + +function assertRemove(collection, pattern) { + assert.writeOK(collection.remove(pattern)); +} + +function assertInsert(collection, obj) { + assert.writeOK(collection.insert(obj)); +} + +// TODO: Remove 'shardAsReplicaSet: false' when SERVER-32672 is fixed. +var cluster = new ShardingTest({ + name: "authmr", + shards: 1, + mongos: 1, + other: {keyFile: "jstests/libs/key1", shardAsReplicaSet: false} +}); + +// Set up the test data. +(function() { +var adminDB = cluster.getDB('admin'); +var test1DB = adminDB.getSiblingDB('test1'); +var test2DB = adminDB.getSiblingDB('test2'); +var ex; +try { + adminDB.createUser(adminUser); + assert(adminDB.auth(adminUser.user, adminUser.pwd)); + + adminDB.dropUser(test1User.user); + adminDB.createUser(test1User); + + assertInsert(test1DB.foo, {a: 1}); + assertInsert(test1DB.foo, {a: 2}); + assertInsert(test1DB.foo, {a: 3}); + assertInsert(test1DB.foo, {a: 4}); + assertInsert(test2DB.foo, {x: 1}); +} finally { + adminDB.logout(); +} +}()); + +assert.throws(function() { + var adminDB = cluster.getDB('admin'); + var test1DB; + var test2DB; + assert(adminDB.auth(test1User.user, test1User.pwd)); + try { + test1DB = adminDB.getSiblingDB("test1"); + test2DB = adminDB.getSiblingDB("test2"); + + // Sanity check. test1User can count (read) test1, but not test2. + assert.eq(test1DB.foo.count(), 4); + assert.throws(test2DB.foo.count); + + test1DB.foo.mapReduce( + function() { + emit(0, this.a); + var t2 = new Mongo().getDB("test2"); + t2.ad.insert(this); + }, + function(k, vs) { + var t2 = new Mongo().getDB("test2"); + t2.reductio.insert(this); + + return Array.sum(vs); + }, + { + out: "bar", + finalize: function(k, v) { + for (k in this) { + if (this.hasOwnProperty(k)) + print(k + "=" + v); + } + var t2 = new Mongo().getDB("test2"); + t2.absurdum.insert({key: k, value: v}); + } + }); + } finally { + adminDB.logout(); } +}); - // TODO: Remove 'shardAsReplicaSet: false' when SERVER-32672 is fixed. - var cluster = new ShardingTest({ - name: "authmr", - shards: 1, - mongos: 1, - other: {keyFile: "jstests/libs/key1", shardAsReplicaSet: false} - }); - - // Set up the test data. - (function() { - var adminDB = cluster.getDB('admin'); - var test1DB = adminDB.getSiblingDB('test1'); - var test2DB = adminDB.getSiblingDB('test2'); - var ex; - try { - adminDB.createUser(adminUser); - assert(adminDB.auth(adminUser.user, adminUser.pwd)); - - adminDB.dropUser(test1User.user); - adminDB.createUser(test1User); - - assertInsert(test1DB.foo, {a: 1}); - assertInsert(test1DB.foo, {a: 2}); - assertInsert(test1DB.foo, {a: 3}); - assertInsert(test1DB.foo, {a: 4}); - assertInsert(test2DB.foo, {x: 1}); - } finally { - adminDB.logout(); - } - }()); - - assert.throws(function() { - var adminDB = cluster.getDB('admin'); - var test1DB; - var test2DB; - assert(adminDB.auth(test1User.user, test1User.pwd)); - try { - test1DB = adminDB.getSiblingDB("test1"); - test2DB = adminDB.getSiblingDB("test2"); - - // Sanity check. test1User can count (read) test1, but not test2. - assert.eq(test1DB.foo.count(), 4); - assert.throws(test2DB.foo.count); - - test1DB.foo.mapReduce( - function() { - emit(0, this.a); - var t2 = new Mongo().getDB("test2"); - t2.ad.insert(this); - }, - function(k, vs) { - var t2 = new Mongo().getDB("test2"); - t2.reductio.insert(this); - - return Array.sum(vs); - }, - { - out: "bar", - finalize: function(k, v) { - for (k in this) { - if (this.hasOwnProperty(k)) - print(k + "=" + v); - } - var t2 = new Mongo().getDB("test2"); - t2.absurdum.insert({key: k, value: v}); - } - }); - } finally { - adminDB.logout(); - } - }); - - (function() { - var adminDB = cluster.getDB('admin'); - assert(adminDB.auth(adminUser.user, adminUser.pwd)); - try { - var test2DB = cluster.getDB('test2'); - assert.eq(test2DB.reductio.count(), 0, "reductio"); - assert.eq(test2DB.ad.count(), 0, "ad"); - assert.eq(test2DB.absurdum.count(), 0, "absurdum"); - } finally { - adminDB.logout(); - } - }()); - - cluster.stop(); +(function() { +var adminDB = cluster.getDB('admin'); +assert(adminDB.auth(adminUser.user, adminUser.pwd)); +try { + var test2DB = cluster.getDB('test2'); + assert.eq(test2DB.reductio.count(), 0, "reductio"); + assert.eq(test2DB.ad.count(), 0, "ad"); + assert.eq(test2DB.absurdum.count(), 0, "absurdum"); +} finally { + adminDB.logout(); +} +}()); + +cluster.stop(); })(); |